@svelte-atoms/core 1.0.0-alpha.29 → 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 -852
- 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.stories.svelte +400 -401
- package/dist/components/atom/html-atom.svelte +71 -17
- 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 +27 -60
- package/dist/components/calendar/calendar-day.svelte +96 -96
- 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 +10 -15
- 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 +59 -59
- package/dist/components/datagrid/datagrid.css +5 -5
- package/dist/components/datagrid/datagrid.stories.svelte +72 -75
- package/dist/components/date-picker/date-picker-calendar.svelte +67 -67
- 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 +1 -1
- package/dist/components/date-picker/date-picker-years.svelte +205 -205
- package/dist/components/date-picker/date-picker.stories.svelte +11 -18
- package/dist/components/dialog/dialog-content.svelte +62 -62
- 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/form/form.stories.svelte +96 -99
- package/dist/components/image/image.stories.svelte +20 -23
- 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/lazy.stories.svelte +9 -16
- package/dist/components/lazy/lazy.svelte +28 -28
- 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 +40 -40
- 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 +175 -178
- package/dist/components/popover/popover-indicator.svelte +44 -43
- package/dist/components/popover/popover-root.svelte +48 -48
- package/dist/components/popover/popover.stories.svelte +49 -52
- package/dist/components/qr-code/qr-code.stories.svelte +4 -13
- package/dist/components/qr-code/qr-code.svelte +75 -75
- 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/sidebar-content.svelte +13 -2
- package/dist/components/sidebar/sidebar-root.svelte +10 -12
- package/dist/components/sidebar/sidebar.stories.svelte +8 -19
- package/dist/components/sidebar/types.d.ts +1 -0
- 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/package.json +6 -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
|
@@ -1,206 +1,206 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { cn, defineProperty, defineState } from '../../utils';
|
|
3
|
-
import { addMonths, format, isToday, startOfDay, subMonths } from 'date-fns';
|
|
4
|
-
import type { CalendarRange, CalendarRootProps, Day, Month } from './types';
|
|
5
|
-
import { CalendarBond, CalendarBondState, type CalendarBondProps } from './bond.svelte';
|
|
6
|
-
import { HtmlAtom } from '../atom';
|
|
7
|
-
|
|
8
|
-
import './calendar.css';
|
|
9
|
-
|
|
10
|
-
let {
|
|
11
|
-
class: klass = '',
|
|
12
|
-
preset = 'calendar',
|
|
13
|
-
value = $bindable(),
|
|
14
|
-
range = $bindable([undefined, undefined]),
|
|
15
|
-
pivote = $bindable(new Date()),
|
|
16
|
-
start = $bindable(startOfDay(new Date())),
|
|
17
|
-
end = $bindable(),
|
|
18
|
-
min = undefined,
|
|
19
|
-
max = undefined,
|
|
20
|
-
type = 'single',
|
|
21
|
-
extend = {},
|
|
22
|
-
onchange = undefined,
|
|
23
|
-
factory = _factory,
|
|
24
|
-
children = undefined,
|
|
25
|
-
...restProps
|
|
26
|
-
}: CalendarRootProps = $props();
|
|
27
|
-
|
|
28
|
-
const monthCurrentDays = $derived(generator(pivote));
|
|
29
|
-
|
|
30
|
-
const monthCurrent: Month = $derived.by(() => {
|
|
31
|
-
const start = monthCurrentDays.at(0) as Day;
|
|
32
|
-
const end = monthCurrentDays.at(-1) as Day;
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
start: start?.date,
|
|
36
|
-
end: end?.date,
|
|
37
|
-
days: monthCurrentDays,
|
|
38
|
-
name: start ? format(start.date, 'MM') : '',
|
|
39
|
-
fullname: start ? format(start.date, 'MMM') : ''
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const monthPreviousDays = $derived(generator(subMonths(pivote, 1)));
|
|
44
|
-
const monthPrevious: Month = $derived.by(() => {
|
|
45
|
-
const start = monthPreviousDays.at(0) as Day;
|
|
46
|
-
const end = monthPreviousDays.at(-1) as Day;
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
start: start?.date,
|
|
50
|
-
end: end?.date,
|
|
51
|
-
days: monthPreviousDays,
|
|
52
|
-
name: start ? format(start.date, 'MM') : '',
|
|
53
|
-
fullname: start ? format(start.date, 'MMM') : ''
|
|
54
|
-
};
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const monthNextDays = $derived(generator(addMonths(pivote, 1)));
|
|
58
|
-
|
|
59
|
-
const monthNext: Month = $derived.by(() => {
|
|
60
|
-
const start = monthNextDays.at(0) as Day;
|
|
61
|
-
const end = monthNextDays.at(-1) as Day;
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
start: start?.date,
|
|
65
|
-
end: end?.date,
|
|
66
|
-
days: monthNextDays,
|
|
67
|
-
name: start ? format(start.date, 'MM') : '',
|
|
68
|
-
fullname: start ? format(start.date, 'MMM') : ''
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
function generator(pivot: Date): Day[] {
|
|
73
|
-
const firstDay = new Date(pivot.getFullYear(), pivot.getMonth(), 1).getDay();
|
|
74
|
-
const lastMonthDaysCount = monthDays(pivot.getMonth() - 1, pivot.getFullYear());
|
|
75
|
-
const sample = startOfDay(
|
|
76
|
-
new Date(pivot.getFullYear(), pivot.getMonth() - 1, lastMonthDaysCount - firstDay)
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
const array: Day[] = [];
|
|
80
|
-
|
|
81
|
-
for (let index = 0; index < 42; index++) {
|
|
82
|
-
sample.setDate(sample.getDate() + 1);
|
|
83
|
-
|
|
84
|
-
const prec =
|
|
85
|
-
pivot.getMonth() > sample.getMonth() || pivot.getFullYear() > sample.getFullYear();
|
|
86
|
-
const next =
|
|
87
|
-
(pivot.getMonth() < sample.getMonth() && pivot.getFullYear() === sample.getFullYear()) ||
|
|
88
|
-
(pivot.getMonth() > sample.getMonth() && pivot.getFullYear() < sample.getFullYear());
|
|
89
|
-
|
|
90
|
-
const disabled =
|
|
91
|
-
(min ? sample < startOfDay(min) : false) || (max ? sample > startOfDay(max) : false);
|
|
92
|
-
|
|
93
|
-
array.push({
|
|
94
|
-
id: sample.getTime(),
|
|
95
|
-
date: new Date(sample),
|
|
96
|
-
get offmonth() {
|
|
97
|
-
return next || prec;
|
|
98
|
-
},
|
|
99
|
-
dayOfMonth: sample.getDate(),
|
|
100
|
-
today: isToday(sample),
|
|
101
|
-
week: Math.floor(index / 7),
|
|
102
|
-
month: sample.getMonth(),
|
|
103
|
-
disabled: disabled,
|
|
104
|
-
weekend: sample.getDay() == 0,
|
|
105
|
-
name: format(sample, 'iii'),
|
|
106
|
-
fullname: format(sample, 'iiiii'),
|
|
107
|
-
get fromNextMonth() {
|
|
108
|
-
return next;
|
|
109
|
-
},
|
|
110
|
-
get fromPreviousMonth() {
|
|
111
|
-
return prec;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return array;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function monthDays(month: number, year = 2020) {
|
|
120
|
-
return new Date(year, month + 1, 0).getDate();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const bondProps = defineState<CalendarBondProps>(
|
|
124
|
-
[
|
|
125
|
-
defineProperty(
|
|
126
|
-
'range',
|
|
127
|
-
() => range,
|
|
128
|
-
(v: CalendarRange) => {
|
|
129
|
-
range = v;
|
|
130
|
-
onchange?.(new CustomEvent('change'), { range, pivote });
|
|
131
|
-
}
|
|
132
|
-
),
|
|
133
|
-
defineProperty(
|
|
134
|
-
'value',
|
|
135
|
-
() => range?.[0],
|
|
136
|
-
(v) => {
|
|
137
|
-
if (range?.[0]) {
|
|
138
|
-
range[0] = v;
|
|
139
|
-
}
|
|
140
|
-
onchange?.(new CustomEvent('change'), { range, pivote });
|
|
141
|
-
}
|
|
142
|
-
),
|
|
143
|
-
defineProperty(
|
|
144
|
-
'pivote',
|
|
145
|
-
() => pivote,
|
|
146
|
-
(v: Date) => {
|
|
147
|
-
pivote = v;
|
|
148
|
-
onchange?.(new CustomEvent('change'), { range, pivote });
|
|
149
|
-
}
|
|
150
|
-
),
|
|
151
|
-
defineProperty(
|
|
152
|
-
'start',
|
|
153
|
-
() => range?.[0],
|
|
154
|
-
(v: Date) => {
|
|
155
|
-
range[0] = v;
|
|
156
|
-
onchange?.(new CustomEvent('change'), { range, pivote });
|
|
157
|
-
}
|
|
158
|
-
),
|
|
159
|
-
defineProperty(
|
|
160
|
-
'end',
|
|
161
|
-
() => range?.[1],
|
|
162
|
-
(v: Date | undefined) => {
|
|
163
|
-
range[1] = v;
|
|
164
|
-
onchange?.(new CustomEvent('change'), { range, pivote });
|
|
165
|
-
}
|
|
166
|
-
),
|
|
167
|
-
defineProperty(
|
|
168
|
-
'min',
|
|
169
|
-
() => min,
|
|
170
|
-
(v: Date | undefined) => (min = v)
|
|
171
|
-
),
|
|
172
|
-
defineProperty(
|
|
173
|
-
'max',
|
|
174
|
-
() => max,
|
|
175
|
-
(v: Date | undefined) => (max = v)
|
|
176
|
-
),
|
|
177
|
-
defineProperty('type', () => type ?? 'single'),
|
|
178
|
-
defineProperty('nextMonth', () => monthNext),
|
|
179
|
-
defineProperty('currentMonth', () => monthCurrent),
|
|
180
|
-
defineProperty('previousMonth', () => monthPrevious)
|
|
181
|
-
],
|
|
182
|
-
() => ({ extend })
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
const bond = factory(bondProps).share();
|
|
186
|
-
|
|
187
|
-
const rootProps = $derived({
|
|
188
|
-
...bond.root(),
|
|
189
|
-
...restProps
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
function _factory(props: typeof bondProps) {
|
|
193
|
-
const popoverState = new CalendarBondState(() => props);
|
|
194
|
-
const popoverBond = new CalendarBond(popoverState);
|
|
195
|
-
|
|
196
|
-
return popoverBond;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export function getBond() {
|
|
200
|
-
return bond;
|
|
201
|
-
}
|
|
202
|
-
</script>
|
|
203
|
-
|
|
204
|
-
<HtmlAtom {preset} class={cn('h-full w-full', klass)} data-atom="calendar-root" {...rootProps}>
|
|
205
|
-
{@render children?.({ calendar: bond })}
|
|
206
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn, defineProperty, defineState } from '../../utils';
|
|
3
|
+
import { addMonths, format, isToday, startOfDay, subMonths } from 'date-fns';
|
|
4
|
+
import type { CalendarRange, CalendarRootProps, Day, Month } from './types';
|
|
5
|
+
import { CalendarBond, CalendarBondState, type CalendarBondProps } from './bond.svelte';
|
|
6
|
+
import { HtmlAtom } from '../atom';
|
|
7
|
+
|
|
8
|
+
import './calendar.css';
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
class: klass = '',
|
|
12
|
+
preset = 'calendar',
|
|
13
|
+
value = $bindable(),
|
|
14
|
+
range = $bindable([undefined, undefined]),
|
|
15
|
+
pivote = $bindable(new Date()),
|
|
16
|
+
start = $bindable(startOfDay(new Date())),
|
|
17
|
+
end = $bindable(),
|
|
18
|
+
min = undefined,
|
|
19
|
+
max = undefined,
|
|
20
|
+
type = 'single',
|
|
21
|
+
extend = {},
|
|
22
|
+
onchange = undefined,
|
|
23
|
+
factory = _factory,
|
|
24
|
+
children = undefined,
|
|
25
|
+
...restProps
|
|
26
|
+
}: CalendarRootProps = $props();
|
|
27
|
+
|
|
28
|
+
const monthCurrentDays = $derived(generator(pivote));
|
|
29
|
+
|
|
30
|
+
const monthCurrent: Month = $derived.by(() => {
|
|
31
|
+
const start = monthCurrentDays.at(0) as Day;
|
|
32
|
+
const end = monthCurrentDays.at(-1) as Day;
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
start: start?.date,
|
|
36
|
+
end: end?.date,
|
|
37
|
+
days: monthCurrentDays,
|
|
38
|
+
name: start ? format(start.date, 'MM') : '',
|
|
39
|
+
fullname: start ? format(start.date, 'MMM') : ''
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const monthPreviousDays = $derived(generator(subMonths(pivote, 1)));
|
|
44
|
+
const monthPrevious: Month = $derived.by(() => {
|
|
45
|
+
const start = monthPreviousDays.at(0) as Day;
|
|
46
|
+
const end = monthPreviousDays.at(-1) as Day;
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
start: start?.date,
|
|
50
|
+
end: end?.date,
|
|
51
|
+
days: monthPreviousDays,
|
|
52
|
+
name: start ? format(start.date, 'MM') : '',
|
|
53
|
+
fullname: start ? format(start.date, 'MMM') : ''
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const monthNextDays = $derived(generator(addMonths(pivote, 1)));
|
|
58
|
+
|
|
59
|
+
const monthNext: Month = $derived.by(() => {
|
|
60
|
+
const start = monthNextDays.at(0) as Day;
|
|
61
|
+
const end = monthNextDays.at(-1) as Day;
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
start: start?.date,
|
|
65
|
+
end: end?.date,
|
|
66
|
+
days: monthNextDays,
|
|
67
|
+
name: start ? format(start.date, 'MM') : '',
|
|
68
|
+
fullname: start ? format(start.date, 'MMM') : ''
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
function generator(pivot: Date): Day[] {
|
|
73
|
+
const firstDay = new Date(pivot.getFullYear(), pivot.getMonth(), 1).getDay();
|
|
74
|
+
const lastMonthDaysCount = monthDays(pivot.getMonth() - 1, pivot.getFullYear());
|
|
75
|
+
const sample = startOfDay(
|
|
76
|
+
new Date(pivot.getFullYear(), pivot.getMonth() - 1, lastMonthDaysCount - firstDay)
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const array: Day[] = [];
|
|
80
|
+
|
|
81
|
+
for (let index = 0; index < 42; index++) {
|
|
82
|
+
sample.setDate(sample.getDate() + 1);
|
|
83
|
+
|
|
84
|
+
const prec =
|
|
85
|
+
pivot.getMonth() > sample.getMonth() || pivot.getFullYear() > sample.getFullYear();
|
|
86
|
+
const next =
|
|
87
|
+
(pivot.getMonth() < sample.getMonth() && pivot.getFullYear() === sample.getFullYear()) ||
|
|
88
|
+
(pivot.getMonth() > sample.getMonth() && pivot.getFullYear() < sample.getFullYear());
|
|
89
|
+
|
|
90
|
+
const disabled =
|
|
91
|
+
(min ? sample < startOfDay(min) : false) || (max ? sample > startOfDay(max) : false);
|
|
92
|
+
|
|
93
|
+
array.push({
|
|
94
|
+
id: sample.getTime(),
|
|
95
|
+
date: new Date(sample),
|
|
96
|
+
get offmonth() {
|
|
97
|
+
return next || prec;
|
|
98
|
+
},
|
|
99
|
+
dayOfMonth: sample.getDate(),
|
|
100
|
+
today: isToday(sample),
|
|
101
|
+
week: Math.floor(index / 7),
|
|
102
|
+
month: sample.getMonth(),
|
|
103
|
+
disabled: disabled,
|
|
104
|
+
weekend: sample.getDay() == 0,
|
|
105
|
+
name: format(sample, 'iii'),
|
|
106
|
+
fullname: format(sample, 'iiiii'),
|
|
107
|
+
get fromNextMonth() {
|
|
108
|
+
return next;
|
|
109
|
+
},
|
|
110
|
+
get fromPreviousMonth() {
|
|
111
|
+
return prec;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return array;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function monthDays(month: number, year = 2020) {
|
|
120
|
+
return new Date(year, month + 1, 0).getDate();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const bondProps = defineState<CalendarBondProps>(
|
|
124
|
+
[
|
|
125
|
+
defineProperty(
|
|
126
|
+
'range',
|
|
127
|
+
() => range,
|
|
128
|
+
(v: CalendarRange) => {
|
|
129
|
+
range = v;
|
|
130
|
+
onchange?.(new CustomEvent('change'), { range, pivote });
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
defineProperty(
|
|
134
|
+
'value',
|
|
135
|
+
() => range?.[0],
|
|
136
|
+
(v) => {
|
|
137
|
+
if (range?.[0]) {
|
|
138
|
+
range[0] = v;
|
|
139
|
+
}
|
|
140
|
+
onchange?.(new CustomEvent('change'), { range, pivote });
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
defineProperty(
|
|
144
|
+
'pivote',
|
|
145
|
+
() => pivote,
|
|
146
|
+
(v: Date) => {
|
|
147
|
+
pivote = v;
|
|
148
|
+
onchange?.(new CustomEvent('change'), { range, pivote });
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
defineProperty(
|
|
152
|
+
'start',
|
|
153
|
+
() => range?.[0],
|
|
154
|
+
(v: Date) => {
|
|
155
|
+
range[0] = v;
|
|
156
|
+
onchange?.(new CustomEvent('change'), { range, pivote });
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
defineProperty(
|
|
160
|
+
'end',
|
|
161
|
+
() => range?.[1],
|
|
162
|
+
(v: Date | undefined) => {
|
|
163
|
+
range[1] = v;
|
|
164
|
+
onchange?.(new CustomEvent('change'), { range, pivote });
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
defineProperty(
|
|
168
|
+
'min',
|
|
169
|
+
() => min,
|
|
170
|
+
(v: Date | undefined) => (min = v)
|
|
171
|
+
),
|
|
172
|
+
defineProperty(
|
|
173
|
+
'max',
|
|
174
|
+
() => max,
|
|
175
|
+
(v: Date | undefined) => (max = v)
|
|
176
|
+
),
|
|
177
|
+
defineProperty('type', () => type ?? 'single'),
|
|
178
|
+
defineProperty('nextMonth', () => monthNext),
|
|
179
|
+
defineProperty('currentMonth', () => monthCurrent),
|
|
180
|
+
defineProperty('previousMonth', () => monthPrevious)
|
|
181
|
+
],
|
|
182
|
+
() => ({ extend })
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
const bond = factory(bondProps).share();
|
|
186
|
+
|
|
187
|
+
const rootProps = $derived({
|
|
188
|
+
...bond.root(),
|
|
189
|
+
...restProps
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
function _factory(props: typeof bondProps) {
|
|
193
|
+
const popoverState = new CalendarBondState(() => props);
|
|
194
|
+
const popoverBond = new CalendarBond(popoverState);
|
|
195
|
+
|
|
196
|
+
return popoverBond;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function getBond() {
|
|
200
|
+
return bond;
|
|
201
|
+
}
|
|
202
|
+
</script>
|
|
203
|
+
|
|
204
|
+
<HtmlAtom {preset} class={cn('h-full w-full', klass)} data-atom="calendar-root" {...rootProps}>
|
|
205
|
+
{@render children?.({ calendar: bond })}
|
|
206
|
+
</HtmlAtom>
|
|
@@ -8,24 +8,19 @@
|
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
10
|
<script>
|
|
11
|
-
import { Root } from '../root';
|
|
12
11
|
</script>
|
|
13
12
|
|
|
14
13
|
<Story name="Calendar">
|
|
15
14
|
{#snippet children({ args })}
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<CalendarModule.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
</CalendarModule.Root>
|
|
27
|
-
</div>
|
|
28
|
-
{/snippet}
|
|
29
|
-
</Root>
|
|
15
|
+
<div class="flex h-fit items-center justify-center">
|
|
16
|
+
<CalendarModule.Root>
|
|
17
|
+
<CalendarModule.Header></CalendarModule.Header>
|
|
18
|
+
<CalendarModule.Body>
|
|
19
|
+
{#snippet children({ day })}
|
|
20
|
+
<CalendarModule.Day {day}></CalendarModule.Day>
|
|
21
|
+
{/snippet}
|
|
22
|
+
</CalendarModule.Body>
|
|
23
|
+
</CalendarModule.Root>
|
|
24
|
+
</div>
|
|
30
25
|
{/snippet}
|
|
31
26
|
</Story>
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import { HtmlAtom, type Base } from '../atom';
|
|
3
|
-
export type { CardContentProps } from './types';
|
|
4
|
-
import { CardBond } from './bond.svelte';
|
|
5
|
-
|
|
6
|
-
const bond = CardBond.get();
|
|
7
|
-
|
|
8
|
-
let {
|
|
9
|
-
class: klass = '',
|
|
10
|
-
children = undefined,
|
|
11
|
-
onmount = undefined,
|
|
12
|
-
ondestroy = undefined,
|
|
13
|
-
animate = undefined,
|
|
14
|
-
enter = undefined,
|
|
15
|
-
exit = undefined,
|
|
16
|
-
initial = undefined,
|
|
17
|
-
...restProps
|
|
18
|
-
}: CardContentProps<E, B> = $props();
|
|
19
|
-
|
|
20
|
-
const contentProps = $derived({
|
|
21
|
-
...bond?.content(),
|
|
22
|
-
...restProps
|
|
23
|
-
});
|
|
24
|
-
</script>
|
|
25
|
-
|
|
26
|
-
<HtmlAtom
|
|
27
|
-
{bond}
|
|
28
|
-
preset="card.content"
|
|
29
|
-
class={['card-content border-border px-4', '$preset', klass]}
|
|
30
|
-
enter={enter?.bind(bond.state)}
|
|
31
|
-
exit={exit?.bind(bond.state)}
|
|
32
|
-
initial={initial?.bind(bond.state)}
|
|
33
|
-
animate={animate?.bind(bond.state)}
|
|
34
|
-
onmount={onmount?.bind(bond.state)}
|
|
35
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
36
|
-
{...contentProps}
|
|
37
|
-
>
|
|
38
|
-
{@render children?.()}
|
|
39
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import { HtmlAtom, type Base } from '../atom';
|
|
3
|
+
export type { CardContentProps } from './types';
|
|
4
|
+
import { CardBond } from './bond.svelte';
|
|
5
|
+
|
|
6
|
+
const bond = CardBond.get();
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
class: klass = '',
|
|
10
|
+
children = undefined,
|
|
11
|
+
onmount = undefined,
|
|
12
|
+
ondestroy = undefined,
|
|
13
|
+
animate = undefined,
|
|
14
|
+
enter = undefined,
|
|
15
|
+
exit = undefined,
|
|
16
|
+
initial = undefined,
|
|
17
|
+
...restProps
|
|
18
|
+
}: CardContentProps<E, B> = $props();
|
|
19
|
+
|
|
20
|
+
const contentProps = $derived({
|
|
21
|
+
...bond?.content(),
|
|
22
|
+
...restProps
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<HtmlAtom
|
|
27
|
+
{bond}
|
|
28
|
+
preset="card.content"
|
|
29
|
+
class={['card-content border-border px-4 pb-4', '$preset', klass]}
|
|
30
|
+
enter={enter?.bind(bond.state)}
|
|
31
|
+
exit={exit?.bind(bond.state)}
|
|
32
|
+
initial={initial?.bind(bond.state)}
|
|
33
|
+
animate={animate?.bind(bond.state)}
|
|
34
|
+
onmount={onmount?.bind(bond.state)}
|
|
35
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
36
|
+
{...contentProps}
|
|
37
|
+
>
|
|
38
|
+
{@render children?.()}
|
|
39
|
+
</HtmlAtom>
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import { HtmlAtom, type Base } from '../atom';
|
|
3
|
-
import { CardBond } from './bond.svelte';
|
|
4
|
-
export type { CardFooterProps } from './types';
|
|
5
|
-
|
|
6
|
-
const bond = CardBond.get();
|
|
7
|
-
|
|
8
|
-
let {
|
|
9
|
-
class: klass = '',
|
|
10
|
-
as = 'div' as E,
|
|
11
|
-
children = undefined,
|
|
12
|
-
onmount = undefined,
|
|
13
|
-
ondestroy = undefined,
|
|
14
|
-
animate = undefined,
|
|
15
|
-
enter = undefined,
|
|
16
|
-
exit = undefined,
|
|
17
|
-
initial = undefined,
|
|
18
|
-
...restProps
|
|
19
|
-
}: CardFooterProps<E, B> = $props();
|
|
20
|
-
|
|
21
|
-
const footerProps = $derived({
|
|
22
|
-
...bond?.footer(),
|
|
23
|
-
...restProps
|
|
24
|
-
});
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<HtmlAtom
|
|
28
|
-
{as}
|
|
29
|
-
{bond}
|
|
30
|
-
preset="card.footer"
|
|
31
|
-
class={['card-footer border-border flex items-center gap-2 px-4
|
|
32
|
-
enter={enter?.bind(bond.state)}
|
|
33
|
-
exit={exit?.bind(bond.state)}
|
|
34
|
-
initial={initial?.bind(bond.state)}
|
|
35
|
-
animate={animate?.bind(bond.state)}
|
|
36
|
-
onmount={onmount?.bind(bond.state)}
|
|
37
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
38
|
-
{...footerProps}
|
|
39
|
-
>
|
|
40
|
-
{@render children?.()}
|
|
41
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import { HtmlAtom, type Base } from '../atom';
|
|
3
|
+
import { CardBond } from './bond.svelte';
|
|
4
|
+
export type { CardFooterProps } from './types';
|
|
5
|
+
|
|
6
|
+
const bond = CardBond.get();
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
class: klass = '',
|
|
10
|
+
as = 'div' as E,
|
|
11
|
+
children = undefined,
|
|
12
|
+
onmount = undefined,
|
|
13
|
+
ondestroy = undefined,
|
|
14
|
+
animate = undefined,
|
|
15
|
+
enter = undefined,
|
|
16
|
+
exit = undefined,
|
|
17
|
+
initial = undefined,
|
|
18
|
+
...restProps
|
|
19
|
+
}: CardFooterProps<E, B> = $props();
|
|
20
|
+
|
|
21
|
+
const footerProps = $derived({
|
|
22
|
+
...bond?.footer(),
|
|
23
|
+
...restProps
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<HtmlAtom
|
|
28
|
+
{as}
|
|
29
|
+
{bond}
|
|
30
|
+
preset="card.footer"
|
|
31
|
+
class={['card-footer border-border flex items-center gap-2 px-4 pb-4', '$preset', klass]}
|
|
32
|
+
enter={enter?.bind(bond.state)}
|
|
33
|
+
exit={exit?.bind(bond.state)}
|
|
34
|
+
initial={initial?.bind(bond.state)}
|
|
35
|
+
animate={animate?.bind(bond.state)}
|
|
36
|
+
onmount={onmount?.bind(bond.state)}
|
|
37
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
38
|
+
{...footerProps}
|
|
39
|
+
>
|
|
40
|
+
{@render children?.()}
|
|
41
|
+
</HtmlAtom>
|