-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export function getSelectedDays(calendar: HTMLElement) { | ||
return Array.from(calendar.querySelectorAll<HTMLElement>("[data-calendar-day][data-selected]")); | ||
return Array.from(calendar.querySelectorAll<HTMLElement>("[data-bits-day][data-selected]")); | ||
} | ||
|
||
export function getSelectedDay(calendar: HTMLElement) { | ||
return calendar.querySelector<HTMLElement>("[data-calendar-day][data-selected]") as HTMLElement; | ||
return calendar.querySelector<HTMLElement>("[data-bits-day][data-selected]") as HTMLElement; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 48 additions & 50 deletions
98
packages/bits-ui/src/tests/range-calendar/RangeCalendarTest.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,59 @@ | ||
<script lang="ts"> | ||
import { RangeCalendar } from "$lib/index.js"; | ||
<script lang="ts" context="module"> | ||
import { RangeCalendar, type WithoutChildren } from "$lib/index.js"; | ||
type $$Props = RangeCalendar.Props; | ||
export type RangeCalendarTestProps = WithoutChildren<RangeCalendar.RootProps>; | ||
</script> | ||
|
||
export let placeholder: $$Props["placeholder"] = undefined; | ||
export let value: $$Props["value"] = undefined; | ||
<script lang="ts"> | ||
let { placeholder, value, ...restProps }: RangeCalendarTestProps = $props(); | ||
</script> | ||
|
||
<main> | ||
<div data-testid="start-value">{value?.start}</div> | ||
<div data-testid="end-value">{value?.end}</div> | ||
<div data-testid="start-value">{String(value?.start)}</div> | ||
<div data-testid="end-value">{String(value?.end)}</div> | ||
|
||
<RangeCalendar.Root | ||
let:months | ||
let:weekdays | ||
bind:placeholder | ||
bind:value | ||
{...$$restProps} | ||
data-testid="calendar" | ||
> | ||
<RangeCalendar.Header data-testid="header"> | ||
<RangeCalendar.PrevButton data-testid="prev-button">Prev</RangeCalendar.PrevButton> | ||
<RangeCalendar.Heading data-testid="heading" /> | ||
<RangeCalendar.NextButton data-testid="next-button">Next</RangeCalendar.NextButton> | ||
</RangeCalendar.Header> | ||
<div> | ||
{#each months as month} | ||
{@const m = month.value.month} | ||
<RangeCalendar.Grid data-testid="grid-{m}"> | ||
<RangeCalendar.GridHead data-testid="grid-head-{m}"> | ||
<RangeCalendar.GridRow data-testid="grid-row-{m}"> | ||
{#each weekdays as day, i} | ||
<RangeCalendar.HeadCell data-testid="weekday-{m}-{i}"> | ||
{day} | ||
</RangeCalendar.HeadCell> | ||
{/each} | ||
</RangeCalendar.GridRow> | ||
</RangeCalendar.GridHead> | ||
<RangeCalendar.GridBody data-testid="grid-body-{m}"> | ||
{#each month.weeks as weekDates, i} | ||
<RangeCalendar.GridRow data-testid="grid-row-{m}-{i}" data-week> | ||
{#each weekDates as date, d} | ||
<RangeCalendar.Cell {date} data-testid="cell-{date.month}-{d}"> | ||
<RangeCalendar.Day | ||
<RangeCalendar.Root bind:placeholder bind:value {...restProps} data-testid="calendar"> | ||
{#snippet children({ months, weekdays })} | ||
<RangeCalendar.Header data-testid="header"> | ||
<RangeCalendar.PrevButton data-testid="prev-button">Prev</RangeCalendar.PrevButton> | ||
<RangeCalendar.Heading data-testid="heading" /> | ||
<RangeCalendar.NextButton data-testid="next-button">Next</RangeCalendar.NextButton> | ||
</RangeCalendar.Header> | ||
<div> | ||
{#each months as month} | ||
{@const m = month.value.month} | ||
<RangeCalendar.Grid data-testid="grid-{m}"> | ||
<RangeCalendar.GridHead data-testid="grid-head-{m}"> | ||
<RangeCalendar.GridRow data-testid="grid-row-{m}"> | ||
{#each weekdays as day, i} | ||
<RangeCalendar.HeadCell data-testid="weekday-{m}-{i}"> | ||
{day} | ||
</RangeCalendar.HeadCell> | ||
{/each} | ||
</RangeCalendar.GridRow> | ||
</RangeCalendar.GridHead> | ||
<RangeCalendar.GridBody data-testid="grid-body-{m}"> | ||
{#each month.weeks as weekDates, i} | ||
<RangeCalendar.GridRow data-testid="grid-row-{m}-{i}" data-week> | ||
{#each weekDates as date, d} | ||
<RangeCalendar.Cell | ||
{date} | ||
month={month.value} | ||
data-testid="date-{date.month}-{date.day}" | ||
data-testid="cell-{date.month}-{d}" | ||
> | ||
{date.day} | ||
</RangeCalendar.Day> | ||
</RangeCalendar.Cell> | ||
{/each} | ||
</RangeCalendar.GridRow> | ||
{/each} | ||
</RangeCalendar.GridBody> | ||
</RangeCalendar.Grid> | ||
{/each} | ||
</div> | ||
<RangeCalendar.Day | ||
data-testid="date-{date.month}-{date.day}" | ||
> | ||
{date.day} | ||
</RangeCalendar.Day> | ||
</RangeCalendar.Cell> | ||
{/each} | ||
</RangeCalendar.GridRow> | ||
{/each} | ||
</RangeCalendar.GridBody> | ||
</RangeCalendar.Grid> | ||
{/each} | ||
</div> | ||
{/snippet} | ||
</RangeCalendar.Root> | ||
</main> |