@svelte-atoms/core 1.0.0-alpha.28 → 1.0.0-alpha.30
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 +852 -856
- package/dist/attachments/clickout.svelte.d.ts +1 -1
- package/dist/attachments/clickout.svelte.js +2 -2
- package/dist/components/accordion/accordion-root.svelte +61 -61
- package/dist/components/accordion/accordion-root.svelte.d.ts +1 -1
- package/dist/components/accordion/accordion.stories.svelte +145 -134
- 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 +10 -11
- package/dist/components/atom/html-atom.svelte +75 -19
- package/dist/components/atom/html-atom.svelte.d.ts +1 -1
- package/dist/components/atom/snippet-renderer.svelte +5 -5
- package/dist/components/avatar/avatar.stories.svelte +22 -27
- package/dist/components/badge/badge.stories.svelte +12 -17
- package/dist/components/badge/badge.svelte +19 -19
- package/dist/components/breadcrumb/breadcrumb.stories.svelte +16 -21
- package/dist/components/button/button.stories.svelte +1 -34
- package/dist/components/calendar/calendar-body.svelte +107 -107
- package/dist/components/calendar/calendar-day.svelte +96 -97
- package/dist/components/calendar/calendar-header.svelte +29 -33
- package/dist/components/calendar/calendar-header.svelte.d.ts +0 -1
- package/dist/components/calendar/calendar-root.svelte +206 -208
- 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 +10 -20
- package/dist/components/calendar/calendar.stories.svelte.d.ts +24 -4
- package/dist/components/card/card-body.svelte +39 -39
- package/dist/components/card/card-footer.svelte +41 -41
- package/dist/components/card/card-root.svelte +91 -91
- package/dist/components/card/card.stories.svelte +133 -145
- package/dist/components/checkbox/checkbox.stories.svelte +22 -27
- package/dist/components/checkbox/checkbox.svelte +155 -157
- package/dist/components/collapsible/collapsible.stories.svelte +172 -173
- package/dist/components/combobox/combobox-root.svelte +65 -65
- package/dist/components/combobox/compobox.stories.svelte +51 -54
- package/dist/components/container/container.stories.svelte +20 -23
- package/dist/components/datagrid/datagrid-root.svelte +2 -2
- package/dist/components/datagrid/datagrid.css +0 -42
- package/dist/components/datagrid/datagrid.stories.svelte +72 -75
- 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 +67 -42
- package/dist/components/date-picker/date-picker-calendar.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-header.svelte +100 -105
- package/dist/components/date-picker/date-picker-header.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-months.svelte +142 -150
- package/dist/components/date-picker/date-picker-months.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-root.svelte +4 -3
- package/dist/components/date-picker/date-picker-root.svelte.d.ts +2 -15
- package/dist/components/date-picker/date-picker-years.svelte +205 -214
- package/dist/components/date-picker/date-picker-years.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker.stories.svelte +15 -31
- package/dist/components/date-picker/types.d.ts +53 -1
- package/dist/components/dialog/dialog-content.svelte +1 -1
- package/dist/components/dialog/dialog.stories.svelte +64 -67
- package/dist/components/drawer/attachments.svelte.js +8 -9
- package/dist/components/drawer/drawer-content.svelte +57 -42
- package/dist/components/drawer/drawer.stories.svelte +212 -224
- package/dist/components/dropdown/dropdown-root.svelte +59 -59
- package/dist/components/dropdown/dropdown.stories.svelte +80 -83
- package/dist/components/element/html-element.svelte +85 -85
- package/dist/components/element/types.d.ts +1 -1
- package/dist/components/form/form.stories.svelte +96 -99
- package/dist/components/image/image.stories.svelte +20 -23
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/input/input.stories.svelte +35 -38
- package/dist/components/label/label.stories.svelte +15 -26
- package/dist/components/label/label.stories.svelte.d.ts +24 -4
- package/dist/components/lazy/index.d.ts +1 -0
- package/dist/components/lazy/index.js +1 -0
- package/dist/components/lazy/lazy.stories.svelte +28 -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/link/link.stories.svelte +15 -26
- package/dist/components/link/link.stories.svelte.d.ts +24 -4
- package/dist/components/menu/menu-list.svelte +2 -1
- package/dist/components/menu/menu-list.svelte.d.ts +1 -0
- package/dist/components/menu/menu.stories.svelte +33 -36
- package/dist/components/popover/bond.svelte.js +31 -25
- package/dist/components/popover/popover-arrow.svelte +111 -111
- package/dist/components/popover/popover-content.svelte +2 -5
- package/dist/components/popover/popover-indicator.svelte +44 -43
- package/dist/components/popover/popover-root.svelte +1 -1
- package/dist/components/popover/popover.stories.svelte +18 -21
- 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 -10
- package/dist/components/qr-code/qr-code.svelte +75 -25
- 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/radio/radio-group.stories.svelte +41 -50
- package/dist/components/radio/radio.stories.svelte +17 -26
- package/dist/components/radio/radio.svelte +109 -109
- package/dist/components/root/root.svelte +121 -121
- package/dist/components/root/root.svelte.d.ts +1 -1
- package/dist/components/scrollable/scrollable.stories.svelte +116 -126
- 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 +50 -39
- package/dist/components/sidebar/sidebar-content.svelte.d.ts +2 -2
- package/dist/components/sidebar/sidebar-root.svelte +39 -68
- package/dist/components/sidebar/sidebar-root.svelte.d.ts +2 -2
- package/dist/components/sidebar/sidebar.stories.svelte +43 -52
- package/dist/components/sidebar/types.d.ts +7 -6
- 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 +56 -59
- package/dist/components/tooltip/tooltip-trigger.svelte +39 -37
- package/dist/components/tooltip/tooltip.stories.svelte +32 -35
- package/dist/components/tree/tree.stories.svelte +142 -134
- package/dist/context/preset.svelte.d.ts +3 -3
- package/dist/utils/function.d.ts +2 -0
- package/dist/utils/function.js +6 -0
- package/llm/variants.md +1259 -1261
- package/package.json +7 -9
- 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
|
@@ -3,45 +3,3 @@
|
|
|
3
3
|
grid-auto-flow: row;
|
|
4
4
|
grid-template-columns: var(--template-columns, auto);
|
|
5
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,75 +1,72 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
width
|
|
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
|
-
</Dropdown.
|
|
60
|
-
<Dropdown.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{/snippet}
|
|
74
|
-
</Root>
|
|
75
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { DataGrid as DataGridCmp } from '.';
|
|
4
|
+
import { Dropdown } from '../dropdown';
|
|
5
|
+
import MoreVerticalIcon from '../../icons/icon-more-vert.svelte';
|
|
6
|
+
import { Icon } from '../icon';
|
|
7
|
+
import { container } from '../../runes/container.svelte';
|
|
8
|
+
|
|
9
|
+
const { Story } = defineMeta({
|
|
10
|
+
title: 'Atoms/DataGrid'
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
let values = $state([]);
|
|
16
|
+
|
|
17
|
+
const datagridContainer = container();
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<Story name="DataGrid">
|
|
21
|
+
{#snippet children({ args })}
|
|
22
|
+
<DataGridCmp.Root class="" {@attach datagridContainer.attach}>
|
|
23
|
+
<DataGridCmp.Header>
|
|
24
|
+
<DataGridCmp.Tr header>
|
|
25
|
+
<DataGridCmp.Th width="auto">
|
|
26
|
+
<DataGridCmp.Checkbox />
|
|
27
|
+
</DataGridCmp.Th>
|
|
28
|
+
<DataGridCmp.Th
|
|
29
|
+
class="resize-x overflow-x-auto"
|
|
30
|
+
width="auto"
|
|
31
|
+
hidden={datagridContainer.current?.width
|
|
32
|
+
? datagridContainer.current.width < 1024
|
|
33
|
+
: false}>ID</DataGridCmp.Th
|
|
34
|
+
>
|
|
35
|
+
<DataGridCmp.Th>Name</DataGridCmp.Th>
|
|
36
|
+
<DataGridCmp.Th width="auto">Job</DataGridCmp.Th>
|
|
37
|
+
<DataGridCmp.Th width="auto">Contact</DataGridCmp.Th>
|
|
38
|
+
<DataGridCmp.Th width="auto"></DataGridCmp.Th>
|
|
39
|
+
</DataGridCmp.Tr>
|
|
40
|
+
</DataGridCmp.Header>
|
|
41
|
+
|
|
42
|
+
<DataGridCmp.Body>
|
|
43
|
+
{#each { length: 10 } as _, i (i)}
|
|
44
|
+
<DataGridCmp.Tr>
|
|
45
|
+
<DataGridCmp.Td>
|
|
46
|
+
<DataGridCmp.Checkbox />
|
|
47
|
+
</DataGridCmp.Td>
|
|
48
|
+
|
|
49
|
+
<DataGridCmp.Td>{crypto.randomUUID()}</DataGridCmp.Td>
|
|
50
|
+
<DataGridCmp.Td>John Doe</DataGridCmp.Td>
|
|
51
|
+
<DataGridCmp.Td>Software Engineer</DataGridCmp.Td>
|
|
52
|
+
<DataGridCmp.Td>+213659009944</DataGridCmp.Td>
|
|
53
|
+
|
|
54
|
+
<DataGridCmp.Td base={Dropdown.Root} placement="bottom-end" offset={0}>
|
|
55
|
+
<Dropdown.Trigger class="flex aspect-square items-center justify-center p-0">
|
|
56
|
+
<Icon src={MoreVerticalIcon} />
|
|
57
|
+
</Dropdown.Trigger>
|
|
58
|
+
<Dropdown.List>
|
|
59
|
+
<Dropdown.Item value="ar">Arabic</Dropdown.Item>
|
|
60
|
+
<Dropdown.Item value="en">English</Dropdown.Item>
|
|
61
|
+
<Dropdown.Item value="sp">Spanish</Dropdown.Item>
|
|
62
|
+
<Dropdown.Item value="fr">Frensh</Dropdown.Item>
|
|
63
|
+
</Dropdown.List>
|
|
64
|
+
</DataGridCmp.Td>
|
|
65
|
+
</DataGridCmp.Tr>
|
|
66
|
+
{/each}
|
|
67
|
+
</DataGridCmp.Body>
|
|
68
|
+
|
|
69
|
+
<DataGridCmp.Footer></DataGridCmp.Footer>
|
|
70
|
+
</DataGridCmp.Root>
|
|
71
|
+
{/snippet}
|
|
72
|
+
</Story>
|
|
@@ -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,42 +1,67 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Content } from '../popover/atoms';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
|
+
const datePickerBondProps = $derived(datePickerBond?.state.props);
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
class: klass = '',
|
|
22
|
+
preset = 'datepicker.calendar',
|
|
23
|
+
children: childrenProp,
|
|
24
|
+
Header = DatePickerHeader,
|
|
25
|
+
Weekdays = CalendarHeader,
|
|
26
|
+
Body = CalendarBody,
|
|
27
|
+
Day = CalendarDay,
|
|
28
|
+
Months = DatePickerMonths,
|
|
29
|
+
Years = DatePickerYears,
|
|
30
|
+
...restProps
|
|
31
|
+
}: DatePickerCalendarProps = $props();
|
|
32
|
+
|
|
33
|
+
const calendarProps = $derived({
|
|
34
|
+
...datePickerBond?.content(),
|
|
35
|
+
...datePickerBondProps,
|
|
36
|
+
...restProps
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
function handleChange(_: CustomEvent, { range, pivote }: { range: CalendarRange; pivote: Date }) {
|
|
40
|
+
if (!datePickerBond) return;
|
|
41
|
+
|
|
42
|
+
datePickerBond.state.props.range = range;
|
|
43
|
+
datePickerBond.state.props.pivote = pivote;
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<Content
|
|
48
|
+
class={['relative overflow-hidden p-0', klass]}
|
|
49
|
+
base={Root}
|
|
50
|
+
onchange={handleChange}
|
|
51
|
+
{preset}
|
|
52
|
+
{...calendarProps}
|
|
53
|
+
>
|
|
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} />
|
|
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;
|
|
@@ -1,105 +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
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
</svg>
|
|
102
|
-
</Icon>
|
|
103
|
-
</button>
|
|
104
|
-
{/if}
|
|
105
|
-
</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,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;
|