@svelte-atoms/core 1.0.0-alpha.28 → 1.0.0-alpha.29
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.
- package/README.md +1 -5
- package/dist/components/alert/alert-actions.svelte +43 -43
- package/dist/components/alert/alert-close-button.svelte +70 -70
- package/dist/components/alert/alert-content.svelte +43 -43
- package/dist/components/alert/alert-description.svelte +42 -42
- package/dist/components/alert/alert-icon.svelte +47 -47
- package/dist/components/alert/alert-root.svelte +103 -103
- package/dist/components/alert/alert-title.svelte +42 -42
- package/dist/components/alert/alert.stories.svelte +401 -401
- package/dist/components/atom/html-atom.svelte +6 -4
- package/dist/components/atom/html-atom.svelte.d.ts +1 -1
- package/dist/components/atom/snippet-renderer.svelte +5 -5
- package/dist/components/button/button.stories.svelte +60 -60
- package/dist/components/calendar/calendar-body.svelte +107 -107
- package/dist/components/calendar/calendar-day.svelte +0 -1
- package/dist/components/calendar/calendar-header.svelte +2 -6
- package/dist/components/calendar/calendar-header.svelte.d.ts +0 -1
- package/dist/components/calendar/calendar-root.svelte +0 -2
- package/dist/components/calendar/calendar-week-day.svelte +34 -34
- package/dist/components/calendar/calendar.css +26 -26
- package/dist/components/calendar/calendar.stories.svelte +0 -5
- package/dist/components/calendar/calendar.stories.svelte.d.ts +24 -4
- package/dist/components/datagrid/datagrid-root.svelte +59 -59
- package/dist/components/datagrid/datagrid.css +5 -47
- package/dist/components/datagrid/types.d.ts +1 -1
- package/dist/components/date-picker/atoms.d.ts +0 -4
- package/dist/components/date-picker/atoms.js +0 -4
- package/dist/components/date-picker/date-picker-calendar.svelte +34 -9
- package/dist/components/date-picker/date-picker-calendar.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-header.svelte +59 -64
- package/dist/components/date-picker/date-picker-header.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-months.svelte +36 -44
- package/dist/components/date-picker/date-picker-months.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-root.svelte +3 -2
- package/dist/components/date-picker/date-picker-root.svelte.d.ts +2 -15
- package/dist/components/date-picker/date-picker-years.svelte +88 -97
- package/dist/components/date-picker/date-picker-years.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker.stories.svelte +6 -15
- package/dist/components/date-picker/types.d.ts +53 -1
- package/dist/components/dialog/dialog-content.svelte +62 -62
- package/dist/components/element/html-element.svelte +85 -85
- package/dist/components/element/types.d.ts +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/lazy/index.d.ts +1 -0
- package/dist/components/lazy/index.js +1 -0
- package/dist/components/lazy/lazy.stories.svelte +35 -0
- package/dist/components/lazy/lazy.stories.svelte.d.ts +19 -0
- package/dist/components/lazy/lazy.svelte +28 -0
- package/dist/components/lazy/lazy.svelte.d.ts +5 -0
- package/dist/components/lazy/types.d.ts +10 -0
- package/dist/components/lazy/types.js +1 -0
- package/dist/components/menu/menu-list.svelte +40 -39
- package/dist/components/menu/menu-list.svelte.d.ts +1 -0
- package/dist/components/popover/popover-content.svelte +178 -178
- package/dist/components/popover/popover-root.svelte +48 -48
- package/dist/components/popover/popover.stories.svelte +52 -52
- package/dist/components/qr-code/index.d.ts +1 -0
- package/dist/components/qr-code/index.js +1 -0
- package/dist/components/qr-code/qr-code.stories.svelte +4 -1
- package/dist/components/qr-code/qr-code.svelte +65 -15
- package/dist/components/qr-code/qr-code.svelte.d.ts +2 -4
- package/dist/components/qr-code/types.d.ts +14 -0
- package/dist/components/qr-code/types.js +1 -0
- package/dist/components/sidebar/bond.svelte.d.ts +0 -5
- package/dist/components/sidebar/bond.svelte.js +1 -12
- package/dist/components/sidebar/sidebar-content.svelte +39 -39
- package/dist/components/sidebar/sidebar-content.svelte.d.ts +2 -2
- package/dist/components/sidebar/sidebar-root.svelte +41 -68
- package/dist/components/sidebar/sidebar-root.svelte.d.ts +2 -2
- package/dist/components/sidebar/sidebar.stories.svelte +54 -52
- package/dist/components/sidebar/types.d.ts +6 -6
- package/llm/variants.md +1259 -1261
- package/package.json +2 -1
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
<script lang="ts" generics="T extends keyof HTMLElementTagNameMap, B extends Base = Base">
|
|
2
|
-
import { defineProperty, defineState } from '../../utils';
|
|
3
|
-
import { HtmlAtom, type Base } from '../atom';
|
|
4
|
-
import { DataGridBond, DataGridBondState, type DataGridStateProps } from './bond.svelte';
|
|
5
|
-
import type { DatagridRootProps } from './types';
|
|
6
|
-
|
|
7
|
-
import './datagrid.css';
|
|
8
|
-
|
|
9
|
-
let {
|
|
10
|
-
class: klass = '',
|
|
11
|
-
values = $bindable([]),
|
|
12
|
-
template = undefined,
|
|
13
|
-
|
|
14
|
-
factory = _factory,
|
|
15
|
-
children = undefined,
|
|
16
|
-
onmount = undefined,
|
|
17
|
-
ondestroy = undefined,
|
|
18
|
-
animate = undefined,
|
|
19
|
-
enter = undefined,
|
|
20
|
-
exit = undefined,
|
|
21
|
-
initial = undefined,
|
|
22
|
-
...restProps
|
|
23
|
-
}: DatagridRootProps<T> = $props();
|
|
24
|
-
|
|
25
|
-
const bondProps = defineState<DataGridStateProps<T>>([
|
|
26
|
-
defineProperty('template', () => template),
|
|
27
|
-
defineProperty(
|
|
28
|
-
'values',
|
|
29
|
-
() => values,
|
|
30
|
-
(v) => (values = v)
|
|
31
|
-
)
|
|
32
|
-
]);
|
|
33
|
-
const bond = factory(bondProps).share();
|
|
34
|
-
|
|
35
|
-
function _factory(props: typeof bondProps) {
|
|
36
|
-
const dataGridState = new DataGridBondState(() => props);
|
|
37
|
-
return new DataGridBond(dataGridState);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function getBond() {
|
|
41
|
-
return bond;
|
|
42
|
-
}
|
|
43
|
-
</script>
|
|
44
|
-
|
|
45
|
-
<HtmlAtom
|
|
46
|
-
{bond}
|
|
47
|
-
preset="datagrid"
|
|
48
|
-
class={['border-border', 'datagrid-root w-full gap-x-0 gap-y-0', '$preset', klass]}
|
|
49
|
-
style="--template-columns:{bond.state.template}"
|
|
50
|
-
enter={enter?.bind(bond.state)}
|
|
51
|
-
exit={exit?.bind(bond.state)}
|
|
52
|
-
initial={initial?.bind(bond.state)}
|
|
53
|
-
animate={animate?.bind(bond.state)}
|
|
54
|
-
onmount={onmount?.bind(bond.state)}
|
|
55
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
56
|
-
{...restProps}
|
|
57
|
-
>
|
|
58
|
-
{@render children?.({ datagrid: bond })}
|
|
59
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts" generics="T extends keyof HTMLElementTagNameMap, B extends Base = Base">
|
|
2
|
+
import { defineProperty, defineState } from '../../utils';
|
|
3
|
+
import { HtmlAtom, type Base } from '../atom';
|
|
4
|
+
import { DataGridBond, DataGridBondState, type DataGridStateProps } from './bond.svelte';
|
|
5
|
+
import type { DatagridRootProps } from './types';
|
|
6
|
+
|
|
7
|
+
import './datagrid.css';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
class: klass = '',
|
|
11
|
+
values = $bindable([]),
|
|
12
|
+
template = undefined,
|
|
13
|
+
fallbackTemplate = 'auto',
|
|
14
|
+
factory = _factory,
|
|
15
|
+
children = undefined,
|
|
16
|
+
onmount = undefined,
|
|
17
|
+
ondestroy = undefined,
|
|
18
|
+
animate = undefined,
|
|
19
|
+
enter = undefined,
|
|
20
|
+
exit = undefined,
|
|
21
|
+
initial = undefined,
|
|
22
|
+
...restProps
|
|
23
|
+
}: DatagridRootProps<T> = $props();
|
|
24
|
+
|
|
25
|
+
const bondProps = defineState<DataGridStateProps<T>>([
|
|
26
|
+
defineProperty('template', () => template),
|
|
27
|
+
defineProperty(
|
|
28
|
+
'values',
|
|
29
|
+
() => values,
|
|
30
|
+
(v) => (values = v)
|
|
31
|
+
)
|
|
32
|
+
]);
|
|
33
|
+
const bond = factory(bondProps).share();
|
|
34
|
+
|
|
35
|
+
function _factory(props: typeof bondProps) {
|
|
36
|
+
const dataGridState = new DataGridBondState(() => props);
|
|
37
|
+
return new DataGridBond(dataGridState);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function getBond() {
|
|
41
|
+
return bond;
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<HtmlAtom
|
|
46
|
+
{bond}
|
|
47
|
+
preset="datagrid"
|
|
48
|
+
class={['border-border', 'datagrid-root w-full gap-x-0 gap-y-0', '$preset', klass]}
|
|
49
|
+
style="--template-columns:{bond.state.template ?? fallbackTemplate}"
|
|
50
|
+
enter={enter?.bind(bond.state)}
|
|
51
|
+
exit={exit?.bind(bond.state)}
|
|
52
|
+
initial={initial?.bind(bond.state)}
|
|
53
|
+
animate={animate?.bind(bond.state)}
|
|
54
|
+
onmount={onmount?.bind(bond.state)}
|
|
55
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
56
|
+
{...restProps}
|
|
57
|
+
>
|
|
58
|
+
{@render children?.({ datagrid: bond })}
|
|
59
|
+
</HtmlAtom>
|
|
@@ -1,47 +1,5 @@
|
|
|
1
|
-
.datagrid-root {
|
|
2
|
-
display: grid;
|
|
3
|
-
grid-auto-flow: row;
|
|
4
|
-
grid-template-columns: var(--template-columns, auto);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.cas-[data-screen='sm'] {
|
|
8
|
-
@media (max-width: var(--screens-sm)) {
|
|
9
|
-
display: none;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.cas-[data-screen='md'] {
|
|
14
|
-
@media (max-width: var(--screens-md)) {
|
|
15
|
-
display: none;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.cas-[data-screen='sd'] {
|
|
20
|
-
@media (max-width: var(--screens-sd)) {
|
|
21
|
-
display: none;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.cas-[data-screen='lg'] {
|
|
26
|
-
@media (max-width: var(--screens-lg)) {
|
|
27
|
-
display: none;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.cas-[data-screen='xl'] {
|
|
32
|
-
@media (max-width: var(--screens-xl)) {
|
|
33
|
-
display: none;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.cas-[data-screen='2xl'] {
|
|
38
|
-
@media (max-width: var(--screens-2xl)) {
|
|
39
|
-
display: none;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.cas-[data-screen='3xl'] {
|
|
44
|
-
@media (max-width: var(--screens-3xl)) {
|
|
45
|
-
display: none;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
.datagrid-root {
|
|
2
|
+
display: grid;
|
|
3
|
+
grid-auto-flow: row;
|
|
4
|
+
grid-template-columns: var(--template-columns, auto);
|
|
5
|
+
}
|
|
@@ -77,8 +77,8 @@ export interface Column {
|
|
|
77
77
|
export interface DatagridRootProps<T> extends DatagridRootExtendProps {
|
|
78
78
|
class?: string;
|
|
79
79
|
template?: string;
|
|
80
|
+
fallbackTemplate?: string;
|
|
80
81
|
values?: string[];
|
|
81
|
-
data?: T[];
|
|
82
82
|
readonly element?: HTMLElement;
|
|
83
83
|
children?: Snippet<[{
|
|
84
84
|
context: DatagridContext<T>;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
export { Arrow, Indicator, Trigger } from '../popover/atoms';
|
|
2
|
-
export { Body, Day, Header as WeekDays, WeekDay } from '../calendar/atoms';
|
|
3
2
|
export { default as Root } from './date-picker-root.svelte';
|
|
4
3
|
export { default as Calendar } from './date-picker-calendar.svelte';
|
|
5
|
-
export { default as Header } from './date-picker-header.svelte';
|
|
6
|
-
export { default as Years } from './date-picker-years.svelte';
|
|
7
|
-
export { default as Months } from './date-picker-months.svelte';
|
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
export { Arrow, Indicator, Trigger } from '../popover/atoms';
|
|
2
|
-
export { Body, Day, Header as WeekDays, WeekDay } from '../calendar/atoms';
|
|
3
2
|
export { default as Root } from './date-picker-root.svelte';
|
|
4
3
|
export { default as Calendar } from './date-picker-calendar.svelte';
|
|
5
|
-
export { default as Header } from './date-picker-header.svelte';
|
|
6
|
-
export { default as Years } from './date-picker-years.svelte';
|
|
7
|
-
export { default as Months } from './date-picker-months.svelte';
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Content } from '../popover/atoms';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Root,
|
|
5
|
+
Header as CalendarHeader,
|
|
6
|
+
Body as CalendarBody,
|
|
7
|
+
Day as CalendarDay
|
|
8
|
+
} from '../calendar/atoms';
|
|
4
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';
|
|
5
16
|
|
|
6
17
|
const datePickerBond = DatePickerBond.get();
|
|
7
18
|
const datePickerBondProps = $derived(datePickerBond?.state.props);
|
|
@@ -9,9 +20,15 @@
|
|
|
9
20
|
let {
|
|
10
21
|
class: klass = '',
|
|
11
22
|
preset = 'datepicker.calendar',
|
|
12
|
-
children:
|
|
23
|
+
children: childrenProp,
|
|
24
|
+
Header = DatePickerHeader,
|
|
25
|
+
Weekdays = CalendarHeader,
|
|
26
|
+
Body = CalendarBody,
|
|
27
|
+
Day = CalendarDay,
|
|
28
|
+
Months = DatePickerMonths,
|
|
29
|
+
Years = DatePickerYears,
|
|
13
30
|
...restProps
|
|
14
|
-
} = $props();
|
|
31
|
+
}: DatePickerCalendarProps = $props();
|
|
15
32
|
|
|
16
33
|
const calendarProps = $derived({
|
|
17
34
|
...datePickerBond?.content(),
|
|
@@ -19,7 +36,7 @@
|
|
|
19
36
|
...restProps
|
|
20
37
|
});
|
|
21
38
|
|
|
22
|
-
function handleChange(
|
|
39
|
+
function handleChange(_: CustomEvent, { range, pivote }: { range: CalendarRange; pivote: Date }) {
|
|
23
40
|
if (!datePickerBond) return;
|
|
24
41
|
|
|
25
42
|
datePickerBond.state.props.range = range;
|
|
@@ -34,9 +51,17 @@
|
|
|
34
51
|
{preset}
|
|
35
52
|
{...calendarProps}
|
|
36
53
|
>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
54
|
+
<HtmlAtom base={Header} class="col-span-full" />
|
|
55
|
+
<HtmlAtom base={Weekdays} />
|
|
56
|
+
|
|
57
|
+
<HtmlAtom base={Body}>
|
|
58
|
+
{#snippet children({ day }: { day: CalendarDayType })}
|
|
59
|
+
<HtmlAtom base={Day} {day} class="flex items-center justify-center">
|
|
60
|
+
<span class="value">{day.dayOfMonth}</span>
|
|
61
|
+
</HtmlAtom>
|
|
62
|
+
{/snippet}
|
|
63
|
+
</HtmlAtom>
|
|
64
|
+
|
|
65
|
+
<HtmlAtom base={Months} />
|
|
66
|
+
<HtmlAtom base={Years} />
|
|
42
67
|
</Content>
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
preset?: string;
|
|
4
|
-
children: any;
|
|
5
|
-
} & Record<string, any>, {}, "">;
|
|
1
|
+
import type { DatePickerCalendarProps } from './types';
|
|
2
|
+
declare const DatePickerCalendar: import("svelte").Component<DatePickerCalendarProps, {}, "">;
|
|
6
3
|
type DatePickerCalendar = ReturnType<typeof DatePickerCalendar>;
|
|
7
4
|
export default DatePickerCalendar;
|
|
@@ -3,11 +3,17 @@
|
|
|
3
3
|
import { DatePickerBond } from './bond.svelte';
|
|
4
4
|
import { CalendarBond } from '../calendar/bond.svelte';
|
|
5
5
|
import { Icon } from '../icon';
|
|
6
|
+
import type { DatePickerHeaderProps } from './types';
|
|
6
7
|
|
|
7
8
|
const datePickerBond = DatePickerBond.get();
|
|
8
9
|
const calendarBond = CalendarBond.get();
|
|
9
10
|
|
|
10
|
-
let {
|
|
11
|
+
let {
|
|
12
|
+
class: klass = '',
|
|
13
|
+
preset = 'datepicker.header',
|
|
14
|
+
children,
|
|
15
|
+
...restProps
|
|
16
|
+
}: DatePickerHeaderProps = $props();
|
|
11
17
|
|
|
12
18
|
const calendarBondProps = $derived(datePickerBond?.state?.props);
|
|
13
19
|
|
|
@@ -37,69 +43,58 @@
|
|
|
37
43
|
{preset}
|
|
38
44
|
{...restProps}
|
|
39
45
|
>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
fill="none"
|
|
63
|
-
stroke="currentColor"
|
|
64
|
-
stroke-width="2"
|
|
65
|
-
stroke-linecap="round"
|
|
66
|
-
stroke-linejoin="round"
|
|
67
|
-
>
|
|
68
|
-
<path d="M15 18l-6-6 6-6" />
|
|
69
|
-
</svg>
|
|
70
|
-
</Icon>
|
|
71
|
-
</button>
|
|
46
|
+
<!-- Previous Month Button -->
|
|
47
|
+
<button
|
|
48
|
+
type="button"
|
|
49
|
+
class="hover:bg-foreground/10 active:bg-foreground/20 flex size-8 cursor-pointer items-center justify-center rounded-md transition-colors"
|
|
50
|
+
onclick={handlePreviousMonth}
|
|
51
|
+
aria-label="Previous month"
|
|
52
|
+
>
|
|
53
|
+
<Icon class="size-5">
|
|
54
|
+
<svg
|
|
55
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
56
|
+
class="size-full"
|
|
57
|
+
viewBox="0 0 24 24"
|
|
58
|
+
fill="none"
|
|
59
|
+
stroke="currentColor"
|
|
60
|
+
stroke-width="2"
|
|
61
|
+
stroke-linecap="round"
|
|
62
|
+
stroke-linejoin="round"
|
|
63
|
+
>
|
|
64
|
+
<path d="M15 18l-6-6 6-6" />
|
|
65
|
+
</svg>
|
|
66
|
+
</Icon>
|
|
67
|
+
</button>
|
|
72
68
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
<!-- Month and Year Display -->
|
|
70
|
+
<button
|
|
71
|
+
class="text-foreground h-full flex-1 cursor-pointer text-center text-sm font-semibold"
|
|
72
|
+
onclick={handleMonthPicker}
|
|
73
|
+
>
|
|
74
|
+
{monthName}
|
|
75
|
+
{year}
|
|
76
|
+
</button>
|
|
81
77
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
{/if}
|
|
78
|
+
<!-- Next Month Button -->
|
|
79
|
+
<button
|
|
80
|
+
type="button"
|
|
81
|
+
class="hover:bg-foreground/10 active:bg-foreground/20 flex size-8 cursor-pointer items-center justify-center rounded-md transition-colors"
|
|
82
|
+
onclick={handleNextMonth}
|
|
83
|
+
aria-label="Next month"
|
|
84
|
+
>
|
|
85
|
+
<Icon class="size-5">
|
|
86
|
+
<svg
|
|
87
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
88
|
+
class="size-full"
|
|
89
|
+
viewBox="0 0 24 24"
|
|
90
|
+
fill="none"
|
|
91
|
+
stroke="currentColor"
|
|
92
|
+
stroke-width="2"
|
|
93
|
+
stroke-linecap="round"
|
|
94
|
+
stroke-linejoin="round"
|
|
95
|
+
>
|
|
96
|
+
<path d="M9 18l6-6-6-6" />
|
|
97
|
+
</svg>
|
|
98
|
+
</Icon>
|
|
99
|
+
</button>
|
|
105
100
|
</HtmlAtom>
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
preset?: string;
|
|
4
|
-
children: any;
|
|
5
|
-
} & Record<string, any>, {}, "">;
|
|
1
|
+
import type { DatePickerHeaderProps } from './types';
|
|
2
|
+
declare const DatePickerHeader: import("svelte").Component<DatePickerHeaderProps, {}, "">;
|
|
6
3
|
type DatePickerHeader = ReturnType<typeof DatePickerHeader>;
|
|
7
4
|
export default DatePickerHeader;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import { PopoverBond } from '../popover';
|
|
4
|
-
import { DatePickerBond } from './bond.svelte';
|
|
2
|
+
import { animate } from 'motion';
|
|
5
3
|
import { getYear, getMonth, setMonth } from 'date-fns';
|
|
6
4
|
import { cn } from '../../utils';
|
|
7
|
-
import {
|
|
5
|
+
import { HtmlAtom } from '../atom';
|
|
6
|
+
import { DatePickerBond } from './bond.svelte';
|
|
7
|
+
import type { DatePickerMonthsProps } from './types';
|
|
8
8
|
|
|
9
|
-
const popover = PopoverBond.get();
|
|
10
9
|
const datePicker = DatePickerBond.get();
|
|
11
|
-
const calendar = datePicker.calendar;
|
|
12
10
|
|
|
13
11
|
const pivote = $derived(datePicker?.state.props.pivote ?? new Date());
|
|
14
12
|
|
|
@@ -31,7 +29,12 @@
|
|
|
31
29
|
'Dec'
|
|
32
30
|
];
|
|
33
31
|
|
|
34
|
-
let {
|
|
32
|
+
let {
|
|
33
|
+
class: klass = '',
|
|
34
|
+
preset = 'datepicker.months',
|
|
35
|
+
children,
|
|
36
|
+
...restProps
|
|
37
|
+
}: DatePickerMonthsProps = $props();
|
|
35
38
|
|
|
36
39
|
function enter(node: HTMLElement) {
|
|
37
40
|
animate(
|
|
@@ -104,47 +107,36 @@
|
|
|
104
107
|
{...restProps}
|
|
105
108
|
>
|
|
106
109
|
<HtmlAtom class="flex flex-1 flex-col gap-2" {enter} {exit}>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
onMonthSelect: handleMonthSelect
|
|
115
|
-
})}
|
|
116
|
-
{:else}
|
|
117
|
-
<!-- Year Display -->
|
|
118
|
-
<nav
|
|
119
|
-
class="border-border text-foreground flex h-12 items-center justify-center gap-2 border-b px-2 py-2"
|
|
110
|
+
<!-- Year Display -->
|
|
111
|
+
<nav
|
|
112
|
+
class="border-border text-foreground flex h-12 items-center justify-center gap-2 border-b px-2 py-2"
|
|
113
|
+
>
|
|
114
|
+
<button
|
|
115
|
+
class="text-foreground cursor-pointer text-center text-sm font-semibold"
|
|
116
|
+
onclick={handleYearPicker}
|
|
120
117
|
>
|
|
118
|
+
{currentYear}
|
|
119
|
+
</button>
|
|
120
|
+
</nav>
|
|
121
|
+
|
|
122
|
+
<!-- Months Grid -->
|
|
123
|
+
<div class="grid flex-1 grid-cols-3 gap-1 px-2 pb-2">
|
|
124
|
+
{#each monthsGrid as month, index}
|
|
125
|
+
{@const isSelected = index === currentMonth}
|
|
121
126
|
<button
|
|
122
|
-
|
|
123
|
-
|
|
127
|
+
type="button"
|
|
128
|
+
class={cn(
|
|
129
|
+
'hover:bg-foreground/10 active:bg-foreground/20 rounded-md px-3 py-2 text-sm transition-colors',
|
|
130
|
+
isSelected && 'bg-primary text-primary-foreground hover:bg-primary/90'
|
|
131
|
+
)}
|
|
132
|
+
onclick={() => handleMonthSelect(index)}
|
|
133
|
+
aria-label="Select {month}"
|
|
134
|
+
aria-current={isSelected ? 'date' : undefined}
|
|
124
135
|
>
|
|
125
|
-
{
|
|
136
|
+
{month}
|
|
126
137
|
</button>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
<!-- Months Grid -->
|
|
130
|
-
<div class="grid flex-1 grid-cols-3 gap-1 px-2 pb-2">
|
|
131
|
-
{#each monthsGrid as month, index}
|
|
132
|
-
{@const isSelected = index === currentMonth}
|
|
133
|
-
<button
|
|
134
|
-
type="button"
|
|
135
|
-
class={cn(
|
|
136
|
-
'hover:bg-foreground/10 active:bg-foreground/20 rounded-md px-3 py-2 text-sm transition-colors',
|
|
137
|
-
isSelected && 'bg-primary text-primary-foreground hover:bg-primary/90'
|
|
138
|
-
)}
|
|
139
|
-
onclick={() => handleMonthSelect(index)}
|
|
140
|
-
aria-label="Select {month}"
|
|
141
|
-
aria-current={isSelected ? 'date' : undefined}
|
|
142
|
-
>
|
|
143
|
-
{month}
|
|
144
|
-
</button>
|
|
145
|
-
{/each}
|
|
146
|
-
</div>
|
|
147
|
-
{/if}
|
|
138
|
+
{/each}
|
|
139
|
+
</div>
|
|
148
140
|
</HtmlAtom>
|
|
149
141
|
</HtmlAtom>
|
|
150
142
|
{/if}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
preset?: string;
|
|
4
|
-
children: any;
|
|
5
|
-
} & Record<string, any>, {}, "">;
|
|
1
|
+
import type { DatePickerMonthsProps } from './types';
|
|
2
|
+
declare const DatePickerMonths: import("svelte").Component<DatePickerMonthsProps, {}, "">;
|
|
6
3
|
type DatePickerMonths = ReturnType<typeof DatePickerMonths>;
|
|
7
4
|
export default DatePickerMonths;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { defineProperty, defineState } from '../../utils';
|
|
3
2
|
import { startOfDay } from 'date-fns';
|
|
3
|
+
import { defineProperty, defineState } from '../../utils';
|
|
4
4
|
import { Root } from '../popover/atoms';
|
|
5
5
|
import type { CalendarRange } from '../calendar/types';
|
|
6
6
|
import { DatePickerBond, DatePickerBondState, type DatePickerBondProps } from './bond.svelte';
|
|
7
|
+
import type { DatePickerRootProps } from './types';
|
|
7
8
|
|
|
8
9
|
let {
|
|
9
10
|
open = $bindable(false),
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
factory = _factory,
|
|
20
21
|
children,
|
|
21
22
|
...restProps
|
|
22
|
-
} = $props();
|
|
23
|
+
}: DatePickerRootProps = $props();
|
|
23
24
|
|
|
24
25
|
const seed = {};
|
|
25
26
|
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const DatePickerRoot: import("svelte").Component<{
|
|
3
|
-
open?: boolean;
|
|
4
|
-
value?: any;
|
|
5
|
-
range?: any[];
|
|
6
|
-
pivote?: any;
|
|
7
|
-
start?: any;
|
|
8
|
-
end?: any;
|
|
9
|
-
min?: any;
|
|
10
|
-
max?: any;
|
|
11
|
-
type?: string;
|
|
12
|
-
offset?: number;
|
|
13
|
-
factory?: () => DatePickerBond<DatePickerBondProps, DatePickerBondState<DatePickerBondProps>>;
|
|
14
|
-
children: any;
|
|
15
|
-
} & Record<string, any>, {}, "value" | "end" | "range" | "open" | "start" | "pivote">;
|
|
1
|
+
import type { DatePickerRootProps } from './types';
|
|
2
|
+
declare const DatePickerRoot: import("svelte").Component<DatePickerRootProps, {}, "value" | "end" | "range" | "open" | "start" | "pivote">;
|
|
16
3
|
type DatePickerRoot = ReturnType<typeof DatePickerRoot>;
|
|
17
4
|
export default DatePickerRoot;
|