@svelte-atoms/core 1.0.0-alpha.32 → 1.0.0-alpha.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -33,8 +33,9 @@ export class DatePickerBond extends PopoverBond {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
content() {
|
|
36
|
+
const superProps = super.content();
|
|
36
37
|
return {
|
|
37
|
-
...
|
|
38
|
+
...superProps,
|
|
38
39
|
id: `date-picker-calendar-${this.id}`,
|
|
39
40
|
role: 'dialog',
|
|
40
41
|
'aria-label': 'Choose date'
|
|
@@ -1,67 +1,60 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Content } from '../popover/atoms';
|
|
3
|
-
import {
|
|
4
|
-
Root,
|
|
5
|
-
Header as CalendarHeader,
|
|
6
|
-
Body as CalendarBody,
|
|
7
|
-
Day as CalendarDay
|
|
8
|
-
} from '../calendar/atoms';
|
|
9
|
-
import { DatePickerBond } from './bond.svelte';
|
|
10
|
-
import DatePickerHeader from './date-picker-header.svelte';
|
|
11
|
-
import DatePickerMonths from './date-picker-months.svelte';
|
|
12
|
-
import DatePickerYears from './date-picker-years.svelte';
|
|
13
|
-
import { HtmlAtom } from '../atom';
|
|
14
|
-
import type { CalendarRange, Day as CalendarDayType } from '../calendar/types';
|
|
15
|
-
import type { DatePickerCalendarProps } from './types';
|
|
16
|
-
|
|
17
|
-
const datePickerBond = DatePickerBond.get();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
</HtmlAtom>
|
|
62
|
-
{/snippet}
|
|
63
|
-
</HtmlAtom>
|
|
64
|
-
|
|
65
|
-
<HtmlAtom base={Months} />
|
|
66
|
-
<HtmlAtom base={Years} />
|
|
67
|
-
</Content>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Content } from '../popover/atoms';
|
|
3
|
+
import {
|
|
4
|
+
Root,
|
|
5
|
+
Header as CalendarHeader,
|
|
6
|
+
Body as CalendarBody,
|
|
7
|
+
Day as CalendarDay
|
|
8
|
+
} from '../calendar/atoms';
|
|
9
|
+
import { DatePickerBond } from './bond.svelte';
|
|
10
|
+
import DatePickerHeader from './date-picker-header.svelte';
|
|
11
|
+
import DatePickerMonths from './date-picker-months.svelte';
|
|
12
|
+
import DatePickerYears from './date-picker-years.svelte';
|
|
13
|
+
import { HtmlAtom } from '../atom';
|
|
14
|
+
import type { CalendarRange, Day as CalendarDayType } from '../calendar/types';
|
|
15
|
+
import type { DatePickerCalendarProps } from './types';
|
|
16
|
+
|
|
17
|
+
const datePickerBond = DatePickerBond.get();
|
|
18
|
+
|
|
19
|
+
let {
|
|
20
|
+
class: klass = '',
|
|
21
|
+
preset = 'datepicker.calendar',
|
|
22
|
+
children: childrenProp,
|
|
23
|
+
Header = DatePickerHeader,
|
|
24
|
+
Weekdays = CalendarHeader,
|
|
25
|
+
Body = CalendarBody,
|
|
26
|
+
Day = CalendarDay,
|
|
27
|
+
Months = DatePickerMonths,
|
|
28
|
+
Years = DatePickerYears,
|
|
29
|
+
...restProps
|
|
30
|
+
}: DatePickerCalendarProps = $props();
|
|
31
|
+
|
|
32
|
+
function handleChange(_: CustomEvent, { range, pivote }: { range: CalendarRange; pivote: Date }) {
|
|
33
|
+
if (!datePickerBond) return;
|
|
34
|
+
|
|
35
|
+
datePickerBond.state.props.range = range;
|
|
36
|
+
datePickerBond.state.props.pivote = pivote;
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<Content
|
|
41
|
+
class={['relative overflow-hidden p-0', klass]}
|
|
42
|
+
base={Root}
|
|
43
|
+
onchange={handleChange}
|
|
44
|
+
{preset}
|
|
45
|
+
{...restProps}
|
|
46
|
+
>
|
|
47
|
+
<HtmlAtom base={Header} class="col-span-full" />
|
|
48
|
+
<HtmlAtom base={Weekdays} class="border-0" />
|
|
49
|
+
|
|
50
|
+
<HtmlAtom base={Body}>
|
|
51
|
+
{#snippet children({ day }: { day: CalendarDayType })}
|
|
52
|
+
<HtmlAtom base={Day} {day} class="flex items-center justify-center border-0">
|
|
53
|
+
<span class="value">{day.dayOfMonth}</span>
|
|
54
|
+
</HtmlAtom>
|
|
55
|
+
{/snippet}
|
|
56
|
+
</HtmlAtom>
|
|
57
|
+
|
|
58
|
+
<HtmlAtom base={Months} />
|
|
59
|
+
<HtmlAtom base={Years} />
|
|
60
|
+
</Content>
|