@svelte-atoms/core 1.0.0-alpha.29 → 1.0.0-alpha.31
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 +3 -2
- package/dist/attachments/clickout.svelte.d.ts +1 -1
- package/dist/attachments/clickout.svelte.js +2 -2
- package/dist/components/accordion/accordion-root.svelte +65 -61
- package/dist/components/accordion/accordion-root.svelte.d.ts +1 -1
- package/dist/components/accordion/accordion.stories.svelte +70 -134
- package/dist/components/accordion/item/accordion-item-body.svelte +44 -42
- package/dist/components/accordion/item/accordion-item-header.svelte +51 -50
- package/dist/components/accordion/item/accordion-item-indicator.svelte +51 -50
- package/dist/components/accordion/item/accordion-item-root.svelte +66 -65
- package/dist/components/accordion/item/bond.svelte.d.ts +2 -0
- package/dist/components/accordion/item/index.d.ts +3 -0
- package/dist/components/accordion/item/index.js +3 -0
- package/dist/components/accordion/item/motion.svelte.d.ts +15 -0
- package/dist/components/accordion/item/motion.svelte.js +30 -0
- package/dist/components/accordion/item/types.d.ts +7 -24
- package/dist/components/alert/alert-close-button.svelte +66 -70
- package/dist/components/alert/alert-description.svelte +42 -42
- package/dist/components/alert/alert-description.svelte.d.ts +3 -6
- package/dist/components/alert/alert-root.svelte +68 -103
- package/dist/components/alert/alert-root.svelte.d.ts +2 -2
- package/dist/components/alert/alert.stories.svelte +10 -11
- package/dist/components/alert/bond.svelte.d.ts +0 -13
- package/dist/components/alert/bond.svelte.js +0 -32
- package/dist/components/alert/types.d.ts +8 -32
- package/dist/components/atom/html-atom.svelte +261 -207
- package/dist/components/avatar/avatar.stories.svelte +8 -13
- package/dist/components/badge/badge.stories.svelte +1 -6
- package/dist/components/badge/badge.svelte +1 -1
- package/dist/components/breadcrumb/breadcrumb.stories.svelte +16 -21
- package/dist/components/button/button.stories.svelte +1 -34
- package/dist/components/calendar/calendar-day.svelte +9 -4
- package/dist/components/calendar/calendar-header.svelte +29 -29
- package/dist/components/calendar/calendar-root.svelte +206 -206
- package/dist/components/calendar/calendar.stories.svelte +26 -31
- package/dist/components/card/card-body.svelte +1 -1
- package/dist/components/card/card-footer.svelte +1 -1
- package/dist/components/card/card-root.svelte +1 -1
- package/dist/components/card/card.stories.svelte +92 -104
- package/dist/components/checkbox/checkbox.stories.svelte +4 -9
- package/dist/components/checkbox/checkbox.svelte +159 -157
- package/dist/components/collapsible/collapsible.stories.svelte +2 -3
- package/dist/components/combobox/atoms.d.ts +1 -1
- package/dist/components/combobox/atoms.js +1 -1
- package/dist/components/combobox/combobox-root.svelte +1 -1
- package/dist/components/combobox/compobox.stories.svelte +19 -22
- package/dist/components/combobox/index.d.ts +1 -0
- package/dist/components/container/container.stories.svelte +8 -11
- package/dist/components/container/container.svelte.d.ts +1 -1
- package/dist/components/datagrid/datagrid-root.svelte +59 -59
- package/dist/components/datagrid/datagrid.css +5 -5
- package/dist/components/datagrid/datagrid.stories.svelte +47 -50
- package/dist/components/datagrid/tr/bond.svelte.d.ts +4 -2
- package/dist/components/datagrid/tr/bond.svelte.js +9 -7
- package/dist/components/datagrid/tr/datagrid-tr.svelte +90 -88
- package/dist/components/date-picker/date-picker-calendar.svelte +2 -2
- package/dist/components/date-picker/date-picker-header.svelte +100 -100
- package/dist/components/date-picker/date-picker-months.svelte +142 -142
- package/dist/components/date-picker/date-picker-root.svelte +95 -95
- package/dist/components/date-picker/date-picker-years.svelte +205 -205
- package/dist/components/date-picker/date-picker.stories.svelte +35 -42
- package/dist/components/dialog/bond.svelte.d.ts +13 -3
- package/dist/components/dialog/bond.svelte.js +66 -5
- package/dist/components/dialog/dialog-content.svelte +2 -20
- package/dist/components/dialog/dialog-root.svelte +91 -110
- package/dist/components/dialog/dialog.stories.svelte +34 -37
- package/dist/components/dialog/motion.svelte.d.ts +13 -0
- package/dist/components/dialog/motion.svelte.js +44 -0
- package/dist/components/drawer/attachments.svelte.d.ts +1 -1
- package/dist/components/drawer/attachments.svelte.js +7 -10
- package/dist/components/drawer/bond.svelte.d.ts +24 -5
- package/dist/components/drawer/bond.svelte.js +77 -11
- package/dist/components/drawer/drawer-content.svelte +49 -42
- package/dist/components/drawer/drawer.stories.svelte +144 -224
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +2 -0
- package/dist/components/drawer/motion.d.ts +15 -0
- package/dist/components/drawer/motion.js +28 -0
- package/dist/components/dropdown/atoms.d.ts +1 -1
- package/dist/components/dropdown/atoms.js +1 -1
- package/dist/components/dropdown/bond.svelte.d.ts +5 -1
- package/dist/components/dropdown/dropdown-root.svelte +1 -1
- package/dist/components/dropdown/dropdown.stories.svelte +38 -41
- package/dist/components/dropdown/index.d.ts +1 -0
- package/dist/components/form/form.stories.svelte +58 -61
- package/dist/components/image/image.stories.svelte +9 -12
- package/dist/components/input/input.stories.svelte +11 -14
- package/dist/components/label/label.stories.svelte +1 -12
- package/dist/components/label/label.stories.svelte.d.ts +24 -4
- package/dist/components/lazy/lazy.stories.svelte +28 -35
- package/dist/components/lazy/lazy.svelte +28 -28
- package/dist/components/link/link.stories.svelte +1 -12
- package/dist/components/link/link.stories.svelte.d.ts +24 -4
- package/dist/components/list/list-item.svelte +20 -20
- package/dist/components/menu/atoms.d.ts +1 -0
- package/dist/components/menu/atoms.js +1 -0
- package/dist/components/menu/index.d.ts +2 -1
- package/dist/components/menu/index.js +1 -1
- package/dist/components/menu/menu-item.svelte +69 -51
- package/dist/components/menu/menu-item.svelte.d.ts +1 -0
- package/dist/components/menu/menu-list.svelte +40 -40
- package/dist/components/menu/menu.stories.svelte +9 -12
- package/dist/components/popover/bond.svelte.d.ts +20 -7
- package/dist/components/popover/bond.svelte.js +104 -45
- package/dist/components/popover/motion.d.ts +6 -0
- package/dist/components/popover/motion.js +56 -0
- package/dist/components/popover/popover-arrow.svelte +4 -4
- package/dist/components/popover/popover-content.svelte +137 -178
- package/dist/components/popover/popover-indicator.svelte +2 -1
- package/dist/components/popover/popover-root.svelte +1 -1
- package/dist/components/popover/popover.stories.svelte +49 -52
- package/dist/components/popover/types.d.ts +9 -7
- package/dist/components/portal/active-portal.svelte +29 -22
- package/dist/components/portal/active-portal.svelte.d.ts +2 -9
- package/dist/components/portal/portal-root.svelte +76 -83
- package/dist/components/portal/portal-root.svelte.d.ts +4 -6
- package/dist/components/portal/teleport.svelte +49 -50
- package/dist/components/portal/teleport.svelte.d.ts +3 -4
- package/dist/components/qr-code/qr-code.stories.svelte +18 -27
- package/dist/components/qr-code/qr-code.svelte +75 -75
- package/dist/components/radio/radio-group.stories.svelte +21 -30
- package/dist/components/radio/radio.stories.svelte +1 -10
- package/dist/components/radio/radio.svelte +109 -109
- package/dist/components/radio/types.d.ts +98 -0
- package/dist/components/radio/types.js +2 -0
- package/dist/components/root/root.svelte +104 -121
- package/dist/components/scrollable/scrollable-root.svelte.d.ts +2 -2
- package/dist/components/scrollable/scrollable.stories.svelte +95 -105
- package/dist/components/sidebar/index.d.ts +2 -0
- package/dist/components/sidebar/index.js +2 -0
- package/dist/components/sidebar/motion.svelte.d.ts +11 -0
- package/dist/components/sidebar/motion.svelte.js +16 -0
- package/dist/components/sidebar/sidebar-content.svelte +3 -2
- package/dist/components/sidebar/sidebar-root.svelte +39 -41
- package/dist/components/sidebar/sidebar.stories.svelte +43 -54
- package/dist/components/sidebar/types.d.ts +3 -12
- package/dist/components/tabs/tab/bond.svelte.d.ts +4 -1
- package/dist/components/tabs/tab/bond.svelte.js +4 -1
- package/dist/components/tabs/tabs.stories.svelte +31 -34
- package/dist/components/textarea/atoms.d.ts +1 -0
- package/dist/components/textarea/atoms.js +1 -0
- package/dist/components/textarea/textarea-input.svelte +9 -6
- package/dist/components/textarea/textarea-root.svelte +9 -9
- package/dist/components/textarea/textarea-root.svelte.d.ts +2 -0
- package/dist/components/tooltip/tooltip-trigger.svelte +39 -37
- package/dist/components/tooltip/tooltip-trigger.svelte.d.ts +1 -0
- package/dist/components/tooltip/tooltip.stories.svelte +7 -10
- package/dist/components/tree/tree.stories.svelte +102 -94
- package/dist/context/preset.svelte.d.ts +3 -3
- package/dist/icons/icon-copy.svelte +6 -0
- package/dist/{components/radio/types.svelte.d.ts → icons/icon-copy.svelte.d.ts} +3 -3
- package/dist/utils/function.d.ts +2 -0
- package/dist/utils/function.js +6 -0
- package/dist/utils/markdown-to-llm.d.ts +28 -0
- package/dist/utils/markdown-to-llm.js +76 -0
- package/package.json +6 -10
- package/dist/actions/animation.svelte.d.ts +0 -6
- package/dist/actions/animation.svelte.js +0 -14
- package/dist/actions/clickout.svelte.d.ts +0 -2
- package/dist/actions/clickout.svelte.js +0 -15
- package/dist/actions/popover.svelte.d.ts +0 -19
- package/dist/actions/popover.svelte.js +0 -81
- package/dist/actions/portal.svelte.d.ts +0 -8
- package/dist/actions/portal.svelte.js +0 -32
- package/dist/attachments/gsap.svelte.d.ts +0 -2
- package/dist/attachments/gsap.svelte.js +0 -26
- package/dist/components/radio/types.svelte +0 -0
- package/llm/composition.md +0 -395
- package/llm/crafting.md +0 -838
- package/llm/motion.md +0 -970
- package/llm/philosophy.md +0 -23
- package/llm/preset-variant-integration.md +0 -516
- package/llm/preset.md +0 -383
- package/llm/styling.md +0 -216
- package/llm/usage.md +0 -46
- package/llm/variants.md +0 -1259
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { HtmlAtom } from '../atom';
|
|
3
|
-
import { DatePickerBond } from './bond.svelte';
|
|
4
|
-
import { CalendarBond } from '../calendar/bond.svelte';
|
|
5
|
-
import { Icon } from '../icon';
|
|
6
|
-
import type { DatePickerHeaderProps } from './types';
|
|
7
|
-
|
|
8
|
-
const datePickerBond = DatePickerBond.get();
|
|
9
|
-
const calendarBond = CalendarBond.get();
|
|
10
|
-
|
|
11
|
-
let {
|
|
12
|
-
class: klass = '',
|
|
13
|
-
preset = 'datepicker.header',
|
|
14
|
-
children,
|
|
15
|
-
...restProps
|
|
16
|
-
}: DatePickerHeaderProps = $props();
|
|
17
|
-
|
|
18
|
-
const calendarBondProps = $derived(datePickerBond?.state?.props);
|
|
19
|
-
|
|
20
|
-
const pivote = $derived(calendarBondProps?.pivote ?? new Date());
|
|
21
|
-
|
|
22
|
-
// Format month and year
|
|
23
|
-
const monthName = $derived(pivote.toLocaleDateString('en-US', { month: 'long' }));
|
|
24
|
-
const year = $derived(pivote.getFullYear());
|
|
25
|
-
|
|
26
|
-
function handlePreviousMonth() {
|
|
27
|
-
calendarBond?.state?.previousMonth();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function handleNextMonth() {
|
|
31
|
-
calendarBond?.state?.nextMonth();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function handleMonthPicker() {
|
|
35
|
-
if (!datePickerBond) return;
|
|
36
|
-
datePickerBond.state.openMonthsPicker();
|
|
37
|
-
}
|
|
38
|
-
</script>
|
|
39
|
-
|
|
40
|
-
<HtmlAtom
|
|
41
|
-
as="nav"
|
|
42
|
-
class={['border-border flex items-center justify-between gap-2 border-b p-2', '$preset', klass]}
|
|
43
|
-
{preset}
|
|
44
|
-
{...restProps}
|
|
45
|
-
>
|
|
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>
|
|
68
|
-
|
|
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>
|
|
77
|
-
|
|
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>
|
|
100
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { HtmlAtom } from '../atom';
|
|
3
|
+
import { DatePickerBond } from './bond.svelte';
|
|
4
|
+
import { CalendarBond } from '../calendar/bond.svelte';
|
|
5
|
+
import { Icon } from '../icon';
|
|
6
|
+
import type { DatePickerHeaderProps } from './types';
|
|
7
|
+
|
|
8
|
+
const datePickerBond = DatePickerBond.get();
|
|
9
|
+
const calendarBond = CalendarBond.get();
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
class: klass = '',
|
|
13
|
+
preset = 'datepicker.header',
|
|
14
|
+
children,
|
|
15
|
+
...restProps
|
|
16
|
+
}: DatePickerHeaderProps = $props();
|
|
17
|
+
|
|
18
|
+
const calendarBondProps = $derived(datePickerBond?.state?.props);
|
|
19
|
+
|
|
20
|
+
const pivote = $derived(calendarBondProps?.pivote ?? new Date());
|
|
21
|
+
|
|
22
|
+
// Format month and year
|
|
23
|
+
const monthName = $derived(pivote.toLocaleDateString('en-US', { month: 'long' }));
|
|
24
|
+
const year = $derived(pivote.getFullYear());
|
|
25
|
+
|
|
26
|
+
function handlePreviousMonth() {
|
|
27
|
+
calendarBond?.state?.previousMonth();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function handleNextMonth() {
|
|
31
|
+
calendarBond?.state?.nextMonth();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function handleMonthPicker() {
|
|
35
|
+
if (!datePickerBond) return;
|
|
36
|
+
datePickerBond.state.openMonthsPicker();
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<HtmlAtom
|
|
41
|
+
as="nav"
|
|
42
|
+
class={['border-border flex items-center justify-between gap-2 border-b p-2', '$preset', klass]}
|
|
43
|
+
{preset}
|
|
44
|
+
{...restProps}
|
|
45
|
+
>
|
|
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>
|
|
68
|
+
|
|
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>
|
|
77
|
+
|
|
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>
|
|
100
|
+
</HtmlAtom>
|
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { animate } from 'motion';
|
|
3
|
-
import { getYear, getMonth, setMonth } from 'date-fns';
|
|
4
|
-
import { cn } from '../../utils';
|
|
5
|
-
import { HtmlAtom } from '../atom';
|
|
6
|
-
import { DatePickerBond } from './bond.svelte';
|
|
7
|
-
import type { DatePickerMonthsProps } from './types';
|
|
8
|
-
|
|
9
|
-
const datePicker = DatePickerBond.get();
|
|
10
|
-
|
|
11
|
-
const pivote = $derived(datePicker?.state.props.pivote ?? new Date());
|
|
12
|
-
|
|
13
|
-
const currentYear = $derived(getYear(pivote));
|
|
14
|
-
const currentMonth = $derived(getMonth(pivote));
|
|
15
|
-
|
|
16
|
-
// Generate array of months
|
|
17
|
-
const monthsGrid = [
|
|
18
|
-
'Jan',
|
|
19
|
-
'Feb',
|
|
20
|
-
'Mar',
|
|
21
|
-
'Apr',
|
|
22
|
-
'May',
|
|
23
|
-
'Jun',
|
|
24
|
-
'Jul',
|
|
25
|
-
'Aug',
|
|
26
|
-
'Sep',
|
|
27
|
-
'Oct',
|
|
28
|
-
'Nov',
|
|
29
|
-
'Dec'
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
let {
|
|
33
|
-
class: klass = '',
|
|
34
|
-
preset = 'datepicker.months',
|
|
35
|
-
children,
|
|
36
|
-
...restProps
|
|
37
|
-
}: DatePickerMonthsProps = $props();
|
|
38
|
-
|
|
39
|
-
function enter(node: HTMLElement) {
|
|
40
|
-
animate(
|
|
41
|
-
node,
|
|
42
|
-
{
|
|
43
|
-
scale: [0.8, 1]
|
|
44
|
-
},
|
|
45
|
-
{ duration: 100 / 1000, ease: 'circOut' }
|
|
46
|
-
);
|
|
47
|
-
return {
|
|
48
|
-
duration: 100
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function exit(node: HTMLElement) {
|
|
53
|
-
animate(
|
|
54
|
-
node,
|
|
55
|
-
{
|
|
56
|
-
scale: 0.8
|
|
57
|
-
},
|
|
58
|
-
{ duration: 100 / 1000, ease: 'circOut' }
|
|
59
|
-
);
|
|
60
|
-
return {
|
|
61
|
-
duration: 100
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function handleMonthSelect(monthIndex: number) {
|
|
66
|
-
if (!datePicker?.state.props.pivote) return;
|
|
67
|
-
const current = datePicker.state.props.pivote;
|
|
68
|
-
datePicker.state.props.pivote = setMonth(current, monthIndex);
|
|
69
|
-
|
|
70
|
-
datePicker.state.closeMonthsPicker();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function handleYearPicker() {
|
|
74
|
-
if (!datePicker) return;
|
|
75
|
-
datePicker.state.openYearsPicker();
|
|
76
|
-
}
|
|
77
|
-
</script>
|
|
78
|
-
|
|
79
|
-
{#if datePicker.state.isMonthsPickerOpen}
|
|
80
|
-
<HtmlAtom
|
|
81
|
-
class={['absolute inset-0 z-1 flex flex-col gap-2 bg-inherit opacity-0', '$preset', klass]}
|
|
82
|
-
enter={(node) => {
|
|
83
|
-
animate(
|
|
84
|
-
node,
|
|
85
|
-
{
|
|
86
|
-
opacity: [0, 1]
|
|
87
|
-
},
|
|
88
|
-
{ duration: 100 / 1000, ease: 'anticipate' }
|
|
89
|
-
);
|
|
90
|
-
return {
|
|
91
|
-
duration: 100
|
|
92
|
-
};
|
|
93
|
-
}}
|
|
94
|
-
exit={(node) => {
|
|
95
|
-
animate(
|
|
96
|
-
node,
|
|
97
|
-
{
|
|
98
|
-
opacity: 0
|
|
99
|
-
},
|
|
100
|
-
{ duration: 100 / 1000, ease: 'anticipate' }
|
|
101
|
-
);
|
|
102
|
-
return {
|
|
103
|
-
duration: 100
|
|
104
|
-
};
|
|
105
|
-
}}
|
|
106
|
-
{preset}
|
|
107
|
-
{...restProps}
|
|
108
|
-
>
|
|
109
|
-
<HtmlAtom class="flex flex-1 flex-col gap-2" {enter} {exit}>
|
|
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}
|
|
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}
|
|
126
|
-
<button
|
|
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}
|
|
135
|
-
>
|
|
136
|
-
{month}
|
|
137
|
-
</button>
|
|
138
|
-
{/each}
|
|
139
|
-
</div>
|
|
140
|
-
</HtmlAtom>
|
|
141
|
-
</HtmlAtom>
|
|
142
|
-
{/if}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { animate } from 'motion';
|
|
3
|
+
import { getYear, getMonth, setMonth } from 'date-fns';
|
|
4
|
+
import { cn } from '../../utils';
|
|
5
|
+
import { HtmlAtom } from '../atom';
|
|
6
|
+
import { DatePickerBond } from './bond.svelte';
|
|
7
|
+
import type { DatePickerMonthsProps } from './types';
|
|
8
|
+
|
|
9
|
+
const datePicker = DatePickerBond.get();
|
|
10
|
+
|
|
11
|
+
const pivote = $derived(datePicker?.state.props.pivote ?? new Date());
|
|
12
|
+
|
|
13
|
+
const currentYear = $derived(getYear(pivote));
|
|
14
|
+
const currentMonth = $derived(getMonth(pivote));
|
|
15
|
+
|
|
16
|
+
// Generate array of months
|
|
17
|
+
const monthsGrid = [
|
|
18
|
+
'Jan',
|
|
19
|
+
'Feb',
|
|
20
|
+
'Mar',
|
|
21
|
+
'Apr',
|
|
22
|
+
'May',
|
|
23
|
+
'Jun',
|
|
24
|
+
'Jul',
|
|
25
|
+
'Aug',
|
|
26
|
+
'Sep',
|
|
27
|
+
'Oct',
|
|
28
|
+
'Nov',
|
|
29
|
+
'Dec'
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
let {
|
|
33
|
+
class: klass = '',
|
|
34
|
+
preset = 'datepicker.months',
|
|
35
|
+
children,
|
|
36
|
+
...restProps
|
|
37
|
+
}: DatePickerMonthsProps = $props();
|
|
38
|
+
|
|
39
|
+
function enter(node: HTMLElement) {
|
|
40
|
+
animate(
|
|
41
|
+
node,
|
|
42
|
+
{
|
|
43
|
+
scale: [0.8, 1]
|
|
44
|
+
},
|
|
45
|
+
{ duration: 100 / 1000, ease: 'circOut' }
|
|
46
|
+
);
|
|
47
|
+
return {
|
|
48
|
+
duration: 100
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function exit(node: HTMLElement) {
|
|
53
|
+
animate(
|
|
54
|
+
node,
|
|
55
|
+
{
|
|
56
|
+
scale: 0.8
|
|
57
|
+
},
|
|
58
|
+
{ duration: 100 / 1000, ease: 'circOut' }
|
|
59
|
+
);
|
|
60
|
+
return {
|
|
61
|
+
duration: 100
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function handleMonthSelect(monthIndex: number) {
|
|
66
|
+
if (!datePicker?.state.props.pivote) return;
|
|
67
|
+
const current = datePicker.state.props.pivote;
|
|
68
|
+
datePicker.state.props.pivote = setMonth(current, monthIndex);
|
|
69
|
+
|
|
70
|
+
datePicker.state.closeMonthsPicker();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function handleYearPicker() {
|
|
74
|
+
if (!datePicker) return;
|
|
75
|
+
datePicker.state.openYearsPicker();
|
|
76
|
+
}
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
{#if datePicker.state.isMonthsPickerOpen}
|
|
80
|
+
<HtmlAtom
|
|
81
|
+
class={['absolute inset-0 z-1 flex flex-col gap-2 bg-inherit opacity-0', '$preset', klass]}
|
|
82
|
+
enter={(node) => {
|
|
83
|
+
animate(
|
|
84
|
+
node,
|
|
85
|
+
{
|
|
86
|
+
opacity: [0, 1]
|
|
87
|
+
},
|
|
88
|
+
{ duration: 100 / 1000, ease: 'anticipate' }
|
|
89
|
+
);
|
|
90
|
+
return {
|
|
91
|
+
duration: 100
|
|
92
|
+
};
|
|
93
|
+
}}
|
|
94
|
+
exit={(node) => {
|
|
95
|
+
animate(
|
|
96
|
+
node,
|
|
97
|
+
{
|
|
98
|
+
opacity: 0
|
|
99
|
+
},
|
|
100
|
+
{ duration: 100 / 1000, ease: 'anticipate' }
|
|
101
|
+
);
|
|
102
|
+
return {
|
|
103
|
+
duration: 100
|
|
104
|
+
};
|
|
105
|
+
}}
|
|
106
|
+
{preset}
|
|
107
|
+
{...restProps}
|
|
108
|
+
>
|
|
109
|
+
<HtmlAtom class="flex flex-1 flex-col gap-2" {enter} {exit}>
|
|
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}
|
|
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}
|
|
126
|
+
<button
|
|
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}
|
|
135
|
+
>
|
|
136
|
+
{month}
|
|
137
|
+
</button>
|
|
138
|
+
{/each}
|
|
139
|
+
</div>
|
|
140
|
+
</HtmlAtom>
|
|
141
|
+
</HtmlAtom>
|
|
142
|
+
{/if}
|
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { startOfDay } from 'date-fns';
|
|
3
|
-
import { defineProperty, defineState } from '../../utils';
|
|
4
|
-
import { Root } from '../popover/atoms';
|
|
5
|
-
import type { CalendarRange } from '../calendar/types';
|
|
6
|
-
import { DatePickerBond, DatePickerBondState, type DatePickerBondProps } from './bond.svelte';
|
|
7
|
-
import type { DatePickerRootProps } from './types';
|
|
8
|
-
|
|
9
|
-
let {
|
|
10
|
-
open = $bindable(false),
|
|
11
|
-
value = $bindable(undefined),
|
|
12
|
-
range = $bindable([undefined, undefined]),
|
|
13
|
-
pivote = $bindable(new Date()),
|
|
14
|
-
start = $bindable(startOfDay(new Date())),
|
|
15
|
-
end = $bindable(undefined),
|
|
16
|
-
min = undefined,
|
|
17
|
-
max = undefined,
|
|
18
|
-
type = 'single',
|
|
19
|
-
offset =
|
|
20
|
-
factory = _factory,
|
|
21
|
-
children,
|
|
22
|
-
...restProps
|
|
23
|
-
}: DatePickerRootProps = $props();
|
|
24
|
-
|
|
25
|
-
const seed = {};
|
|
26
|
-
|
|
27
|
-
const bondProps = defineState<DatePickerBondProps>(
|
|
28
|
-
[
|
|
29
|
-
defineProperty(
|
|
30
|
-
'open',
|
|
31
|
-
() => open,
|
|
32
|
-
(v) => {
|
|
33
|
-
open = v;
|
|
34
|
-
}
|
|
35
|
-
),
|
|
36
|
-
defineProperty(
|
|
37
|
-
'range',
|
|
38
|
-
() => range,
|
|
39
|
-
(v: CalendarRange) => {
|
|
40
|
-
range = v;
|
|
41
|
-
value = v[0];
|
|
42
|
-
}
|
|
43
|
-
),
|
|
44
|
-
defineProperty(
|
|
45
|
-
'value',
|
|
46
|
-
() => range?.[0],
|
|
47
|
-
(v) => {
|
|
48
|
-
range[0] = v;
|
|
49
|
-
}
|
|
50
|
-
),
|
|
51
|
-
defineProperty(
|
|
52
|
-
'pivote',
|
|
53
|
-
() => pivote,
|
|
54
|
-
(v: Date) => (pivote = v)
|
|
55
|
-
),
|
|
56
|
-
defineProperty(
|
|
57
|
-
'start',
|
|
58
|
-
() => range[0],
|
|
59
|
-
(v: Date) => {
|
|
60
|
-
range[0] = v;
|
|
61
|
-
}
|
|
62
|
-
),
|
|
63
|
-
defineProperty(
|
|
64
|
-
'end',
|
|
65
|
-
() => range[1],
|
|
66
|
-
(v: Date | undefined) => {
|
|
67
|
-
range[1] = v;
|
|
68
|
-
}
|
|
69
|
-
),
|
|
70
|
-
defineProperty(
|
|
71
|
-
'min',
|
|
72
|
-
() => min,
|
|
73
|
-
(v: Date | undefined) => (min = v)
|
|
74
|
-
),
|
|
75
|
-
defineProperty(
|
|
76
|
-
'max',
|
|
77
|
-
() => max,
|
|
78
|
-
(v: Date | undefined) => (max = v)
|
|
79
|
-
),
|
|
80
|
-
defineProperty('type', () => type ?? 'single')
|
|
81
|
-
],
|
|
82
|
-
() => seed
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const bond = factory().share();
|
|
86
|
-
|
|
87
|
-
function _factory() {
|
|
88
|
-
const bondState = new DatePickerBondState(() => bondProps);
|
|
89
|
-
return new DatePickerBond(bondState);
|
|
90
|
-
}
|
|
91
|
-
</script>
|
|
92
|
-
|
|
93
|
-
<Root bind:open extend={bondProps} {offset} {...restProps}>
|
|
94
|
-
{@render children?.({ datePicker: bond })}
|
|
95
|
-
</Root>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { startOfDay } from 'date-fns';
|
|
3
|
+
import { defineProperty, defineState } from '../../utils';
|
|
4
|
+
import { Root } from '../popover/atoms';
|
|
5
|
+
import type { CalendarRange } from '../calendar/types';
|
|
6
|
+
import { DatePickerBond, DatePickerBondState, type DatePickerBondProps } from './bond.svelte';
|
|
7
|
+
import type { DatePickerRootProps } from './types';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
open = $bindable(false),
|
|
11
|
+
value = $bindable(undefined),
|
|
12
|
+
range = $bindable([undefined, undefined]),
|
|
13
|
+
pivote = $bindable(new Date()),
|
|
14
|
+
start = $bindable(startOfDay(new Date())),
|
|
15
|
+
end = $bindable(undefined),
|
|
16
|
+
min = undefined,
|
|
17
|
+
max = undefined,
|
|
18
|
+
type = 'single',
|
|
19
|
+
offset = 1,
|
|
20
|
+
factory = _factory,
|
|
21
|
+
children,
|
|
22
|
+
...restProps
|
|
23
|
+
}: DatePickerRootProps = $props();
|
|
24
|
+
|
|
25
|
+
const seed = {};
|
|
26
|
+
|
|
27
|
+
const bondProps = defineState<DatePickerBondProps>(
|
|
28
|
+
[
|
|
29
|
+
defineProperty(
|
|
30
|
+
'open',
|
|
31
|
+
() => open,
|
|
32
|
+
(v) => {
|
|
33
|
+
open = v;
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
defineProperty(
|
|
37
|
+
'range',
|
|
38
|
+
() => range,
|
|
39
|
+
(v: CalendarRange) => {
|
|
40
|
+
range = v;
|
|
41
|
+
value = v[0];
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
defineProperty(
|
|
45
|
+
'value',
|
|
46
|
+
() => range?.[0],
|
|
47
|
+
(v) => {
|
|
48
|
+
range[0] = v;
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
defineProperty(
|
|
52
|
+
'pivote',
|
|
53
|
+
() => pivote,
|
|
54
|
+
(v: Date) => (pivote = v)
|
|
55
|
+
),
|
|
56
|
+
defineProperty(
|
|
57
|
+
'start',
|
|
58
|
+
() => range[0],
|
|
59
|
+
(v: Date) => {
|
|
60
|
+
range[0] = v;
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
defineProperty(
|
|
64
|
+
'end',
|
|
65
|
+
() => range[1],
|
|
66
|
+
(v: Date | undefined) => {
|
|
67
|
+
range[1] = v;
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
defineProperty(
|
|
71
|
+
'min',
|
|
72
|
+
() => min,
|
|
73
|
+
(v: Date | undefined) => (min = v)
|
|
74
|
+
),
|
|
75
|
+
defineProperty(
|
|
76
|
+
'max',
|
|
77
|
+
() => max,
|
|
78
|
+
(v: Date | undefined) => (max = v)
|
|
79
|
+
),
|
|
80
|
+
defineProperty('type', () => type ?? 'single')
|
|
81
|
+
],
|
|
82
|
+
() => seed
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const bond = factory().share();
|
|
86
|
+
|
|
87
|
+
function _factory() {
|
|
88
|
+
const bondState = new DatePickerBondState(() => bondProps);
|
|
89
|
+
return new DatePickerBond(bondState);
|
|
90
|
+
}
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<Root bind:open extend={bondProps} {offset} {...restProps}>
|
|
94
|
+
{@render children?.({ datePicker: bond })}
|
|
95
|
+
</Root>
|