-
-
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
44 changed files
with
835 additions
and
1,306 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
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
30 changes: 0 additions & 30 deletions
30
packages/bits-ui/src/lib/bits/date-picker/components/date-picker-arrow.svelte
This file was deleted.
Oops, something went wrong.
75 changes: 45 additions & 30 deletions
75
packages/bits-ui/src/lib/bits/date-picker/components/date-picker-calendar.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,41 +1,56 @@ | ||
<script lang="ts"> | ||
import { type Month, melt } from "@melt-ui/svelte"; | ||
import type { DateValue } from "@internationalized/date"; | ||
import { getCtx } from "../ctx.js"; | ||
import type { CalendarEvents, CalendarProps } from "../index.js"; | ||
import { createDispatcher } from "$lib/internal/events.js"; | ||
import { useCalendarRoot } from "$lib/bits/calendar/calendar.svelte.js"; | ||
import { useId } from "$lib/internal/useId.svelte.js"; | ||
import { box } from "svelte-toolbelt"; | ||
import type { CalendarProps } from "../index.js"; | ||
import { getDatePickerRootContext } from "../date-picker.svelte.js"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
type $$Props = CalendarProps; | ||
type $$Events = CalendarEvents; | ||
let { | ||
asChild, | ||
children, | ||
child, | ||
id = useId(), | ||
ref = $bindable(null), | ||
...restProps | ||
}: CalendarProps = $props(); | ||
export let asChild: $$Props["asChild"] = false; | ||
export let id: $$Props["id"] = undefined; | ||
export let el: $$Props["el"] = undefined; | ||
const datePickerRootState = getDatePickerRootContext(); | ||
const { | ||
elements: { calendar }, | ||
states: { months: localMonths, weekdays }, | ||
ids, | ||
getCalendarAttrs, | ||
} = getCtx(); | ||
const calendarState = useCalendarRoot({ | ||
id: box.with(() => id), | ||
ref: box.with( | ||
() => ref, | ||
(v) => (ref = v) | ||
), | ||
calendarLabel: datePickerRootState.props.calendarLabel, | ||
fixedWeeks: datePickerRootState.props.fixedWeeks, | ||
isDateDisabled: datePickerRootState.props.isDateDisabled, | ||
isDateUnavailable: datePickerRootState.props.isDateUnavailable, | ||
locale: datePickerRootState.props.locale, | ||
numberOfMonths: datePickerRootState.props.numberOfMonths, | ||
pagedNavigation: datePickerRootState.props.pagedNavigation, | ||
preventDeselect: datePickerRootState.props.preventDeselect, | ||
readonly: datePickerRootState.props.readonly, | ||
type: box.with(() => "single"), | ||
weekStartsOn: datePickerRootState.props.weekStartsOn, | ||
weekdayFormat: datePickerRootState.props.weekdayFormat, | ||
disabled: datePickerRootState.props.disabled, | ||
disableDaysOutsideMonth: datePickerRootState.props.disableDaysOutsideMonth, | ||
maxValue: datePickerRootState.props.maxValue, | ||
minValue: datePickerRootState.props.minValue, | ||
placeholder: datePickerRootState.props.placeholder, | ||
value: datePickerRootState.props.value, | ||
onDateSelect: datePickerRootState.props.onDateSelect, | ||
}); | ||
$: if (id) { | ||
ids.calendar.calendar.set(id); | ||
} | ||
const attrs = getCalendarAttrs("root"); | ||
const dispatch = createDispatcher(); | ||
$: builder = $calendar; | ||
$: Object.assign(builder, attrs); | ||
let months: Month<DateValue>[] = $localMonths; | ||
$: months = $localMonths; | ||
const mergedProps = $derived(mergeProps(restProps, calendarState.props)); | ||
</script> | ||
|
||
{#if asChild} | ||
<slot {builder} {months} weekdays={$weekdays} /> | ||
{@render child?.({ props: mergedProps, ...calendarState.snippetProps })} | ||
{:else} | ||
<div bind:this={ref} use:melt={builder} {...$$restProps} on:m-keydown={dispatch}> | ||
<slot {builder} {months} weekdays={$weekdays} /> | ||
<div {...mergedProps}> | ||
{@render children?.(calendarState.snippetProps)} | ||
</div> | ||
{/if} |
30 changes: 0 additions & 30 deletions
30
packages/bits-ui/src/lib/bits/date-picker/components/date-picker-cell.svelte
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
packages/bits-ui/src/lib/bits/date-picker/components/date-picker-close.svelte
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.