-
-
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
29 changed files
with
2,085 additions
and
1,117 deletions.
There are no files selected for viewing
577 changes: 189 additions & 388 deletions
577
packages/bits-ui/src/lib/bits/calendar/calendar.svelte.ts
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
45 changes: 27 additions & 18 deletions
45
packages/bits-ui/src/lib/bits/range-calendar/components/range-calendar-cell.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,29 +1,38 @@ | ||
<script lang="ts"> | ||
import { getCtx } from "../ctx.js"; | ||
import { useId } from "$lib/internal/useId.svelte.js"; | ||
import { box } from "svelte-toolbelt"; | ||
import type { CellProps } from "../index.js"; | ||
import { useRangeCalendarCell } from "../range-calendar.svelte.js"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
type $$Props = CellProps; | ||
let { | ||
asChild, | ||
children, | ||
child, | ||
id = useId(), | ||
ref = $bindable(null), | ||
date, | ||
month, | ||
...restProps | ||
}: CellProps = $props(); | ||
export let date: $$Props["date"]; | ||
export let asChild: $$Props["asChild"] = false; | ||
export let el: $$Props["el"] = undefined; | ||
const cellState = useRangeCalendarCell({ | ||
id: box.with(() => id), | ||
ref: box.with( | ||
() => ref, | ||
(v) => (ref = v) | ||
), | ||
date: box.with(() => date), | ||
month: box.with(() => month), | ||
}); | ||
const { | ||
helpers: { isDateDisabled, isDateUnavailable }, | ||
getAttrs, | ||
} = getCtx(); | ||
$: attrs = { | ||
...getAttrs("cell"), | ||
"aria-disabled": $isDateDisabled(date) || $isDateUnavailable(date), | ||
role: "gridcell", | ||
}; | ||
const mergedProps = $derived(mergeProps(restProps, cellState.props)); | ||
</script> | ||
|
||
{#if asChild} | ||
<slot {attrs} /> | ||
{@render child?.({ props: mergedProps, ...cellState.snippetProps })} | ||
{:else} | ||
<td bind:this={ref} {...$$restProps} {...attrs}> | ||
<slot {attrs} /> | ||
<td {...mergedProps}> | ||
{@render children?.(cellState.snippetProps)} | ||
</td> | ||
{/if} |
59 changes: 24 additions & 35 deletions
59
packages/bits-ui/src/lib/bits/range-calendar/components/range-calendar-day.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,45 +1,34 @@ | ||
<script lang="ts"> | ||
import { melt } from "@melt-ui/svelte"; | ||
import { getCtx } from "../ctx.js"; | ||
import type { DayEvents, DayProps } from "../index.js"; | ||
import { createDispatcher } from "$lib/internal/events.js"; | ||
import { useId } from "$lib/internal/useId.svelte.js"; | ||
import { box } from "svelte-toolbelt"; | ||
import type { DayProps } from "../index.js"; | ||
import { useRangeCalendarDay } from "../range-calendar.svelte.js"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
type $$Props = DayProps; | ||
type $$Events = DayEvents; | ||
let { | ||
asChild, | ||
children, | ||
child, | ||
id = useId(), | ||
ref = $bindable(null), | ||
...restProps | ||
}: DayProps = $props(); | ||
export let date: $$Props["date"]; | ||
export let month: $$Props["month"]; | ||
export let asChild: $$Props["asChild"] = false; | ||
export let el: $$Props["el"] = undefined; | ||
const dayState = useRangeCalendarDay({ | ||
id: box.with(() => id), | ||
ref: box.with( | ||
() => ref, | ||
(v) => (ref = v) | ||
), | ||
}); | ||
const { | ||
elements: { cell }, | ||
helpers: { isDateDisabled, isDateUnavailable }, | ||
getAttrs, | ||
} = getCtx(); | ||
const attrs = getAttrs("day"); | ||
const dispatch = createDispatcher(); | ||
$: builder = $cell(date, month); | ||
$: Object.assign(builder, attrs); | ||
$: disabled = $isDateDisabled(date); | ||
$: unavailable = $isDateUnavailable(date); | ||
const mergedProps = $derived(mergeProps(restProps, dayState.props)); | ||
</script> | ||
|
||
{#if asChild} | ||
<slot {builder} {disabled} {unavailable} /> | ||
{@render child?.({ props: mergedProps, ...dayState.snippetProps })} | ||
{:else} | ||
<div | ||
bind:this={ref} | ||
use:melt={builder} | ||
{...$$restProps} | ||
on:m-click={dispatch} | ||
on:m-focusin={dispatch} | ||
on:m-mouseenter={dispatch} | ||
> | ||
<slot {builder} {disabled} {unavailable}> | ||
{date.day} | ||
</slot> | ||
<div {...mergedProps}> | ||
{@render children?.(dayState.snippetProps)} | ||
</div> | ||
{/if} |
20 changes: 0 additions & 20 deletions
20
packages/bits-ui/src/lib/bits/range-calendar/components/range-calendar-grid-body.svelte
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
packages/bits-ui/src/lib/bits/range-calendar/components/range-calendar-grid-head.svelte
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
packages/bits-ui/src/lib/bits/range-calendar/components/range-calendar-grid-row.svelte
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
packages/bits-ui/src/lib/bits/range-calendar/components/range-calendar-grid.svelte
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
packages/bits-ui/src/lib/bits/range-calendar/components/range-calendar-head-cell.svelte
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
packages/bits-ui/src/lib/bits/range-calendar/components/range-calendar-header.svelte
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
packages/bits-ui/src/lib/bits/range-calendar/components/range-calendar-heading.svelte
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.