@svelte-atoms/core 1.0.0-alpha.30 → 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 +853 -852
- package/dist/components/accordion/accordion-root.svelte +7 -3
- package/dist/components/accordion/accordion.stories.svelte +7 -82
- 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 +400 -400
- 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 -261
- package/dist/components/avatar/avatar.stories.svelte +22 -22
- package/dist/components/badge/badge.stories.svelte +12 -12
- package/dist/components/badge/badge.svelte +19 -19
- package/dist/components/breadcrumb/breadcrumb.stories.svelte +5 -5
- package/dist/components/button/button.stories.svelte +27 -27
- package/dist/components/calendar/calendar-day.svelte +101 -96
- package/dist/components/calendar/calendar.stories.svelte +26 -26
- 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 -133
- package/dist/components/checkbox/checkbox.stories.svelte +22 -22
- package/dist/components/checkbox/checkbox.svelte +6 -2
- package/dist/components/collapsible/collapsible.stories.svelte +172 -172
- package/dist/components/combobox/atoms.d.ts +1 -1
- package/dist/components/combobox/atoms.js +1 -1
- package/dist/components/combobox/combobox-root.svelte +65 -65
- package/dist/components/combobox/compobox.stories.svelte +51 -51
- package/dist/components/combobox/index.d.ts +1 -0
- package/dist/components/container/container.stories.svelte +20 -20
- package/dist/components/container/container.svelte.d.ts +1 -1
- package/dist/components/datagrid/datagrid.stories.svelte +72 -72
- 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 +67 -67
- package/dist/components/date-picker/date-picker-root.svelte +95 -95
- package/dist/components/date-picker/date-picker.stories.svelte +35 -35
- 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 +44 -62
- package/dist/components/dialog/dialog-root.svelte +91 -110
- package/dist/components/dialog/dialog.stories.svelte +64 -64
- 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 +1 -3
- 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 +6 -14
- package/dist/components/drawer/drawer.stories.svelte +27 -95
- 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 +59 -59
- package/dist/components/dropdown/dropdown.stories.svelte +80 -80
- package/dist/components/dropdown/index.d.ts +1 -0
- package/dist/components/form/form.stories.svelte +96 -96
- package/dist/components/image/image.stories.svelte +20 -20
- package/dist/components/input/input.stories.svelte +35 -35
- package/dist/components/label/label.stories.svelte +15 -15
- package/dist/components/lazy/lazy.stories.svelte +28 -28
- package/dist/components/link/link.stories.svelte +15 -15
- 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.stories.svelte +33 -33
- package/dist/components/popover/bond.svelte.d.ts +20 -7
- package/dist/components/popover/bond.svelte.js +80 -27
- package/dist/components/popover/motion.d.ts +6 -0
- package/dist/components/popover/motion.js +56 -0
- package/dist/components/popover/popover-arrow.svelte +111 -111
- package/dist/components/popover/popover-content.svelte +34 -72
- package/dist/components/popover/popover-indicator.svelte +44 -44
- package/dist/components/popover/popover-root.svelte +48 -48
- package/dist/components/popover/popover.stories.svelte +3 -3
- 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 -18
- package/dist/components/radio/radio-group.stories.svelte +41 -41
- package/dist/components/radio/radio.stories.svelte +17 -17
- package/dist/components/radio/radio.svelte +1 -1
- package/dist/components/radio/types.d.ts +98 -0
- package/dist/components/radio/types.js +2 -0
- package/dist/components/root/root.svelte +13 -30
- package/dist/components/root/root.svelte.d.ts +1 -1
- package/dist/components/scrollable/scrollable-root.svelte.d.ts +2 -2
- package/dist/components/scrollable/scrollable.stories.svelte +116 -116
- 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 -13
- package/dist/components/sidebar/sidebar-root.svelte +39 -39
- package/dist/components/sidebar/sidebar.stories.svelte +43 -43
- package/dist/components/sidebar/types.d.ts +2 -12
- package/dist/components/tabs/tabs.stories.svelte +56 -56
- 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 +2 -2
- package/dist/components/tooltip/tooltip-trigger.svelte.d.ts +1 -0
- package/dist/components/tooltip/tooltip.stories.svelte +32 -32
- package/dist/components/tree/tree.stories.svelte +142 -142
- 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/markdown-to-llm.d.ts +28 -0
- package/dist/utils/markdown-to-llm.js +76 -0
- package/package.json +1 -2
- 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,27 +1,27 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import ButtonCmp from './button.svelte';
|
|
4
|
-
|
|
5
|
-
const { Story } = defineMeta({
|
|
6
|
-
title: 'ATOMS/Button',
|
|
7
|
-
argTypes: {
|
|
8
|
-
variant: {
|
|
9
|
-
control: 'select',
|
|
10
|
-
options: ['primary', 'secondary', 'destructive', 'outline', 'ghost'],
|
|
11
|
-
description: 'Button variant style',
|
|
12
|
-
table: {
|
|
13
|
-
defaultValue: { summary: 'primary' }
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<script lang="ts">
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<Story name="Button">
|
|
24
|
-
{#snippet template(args)}
|
|
25
|
-
<ButtonCmp {...args}>Click me</ButtonCmp>
|
|
26
|
-
{/snippet}
|
|
27
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import ButtonCmp from './button.svelte';
|
|
4
|
+
|
|
5
|
+
const { Story } = defineMeta({
|
|
6
|
+
title: 'ATOMS/Button',
|
|
7
|
+
argTypes: {
|
|
8
|
+
variant: {
|
|
9
|
+
control: 'select',
|
|
10
|
+
options: ['primary', 'secondary', 'destructive', 'outline', 'ghost'],
|
|
11
|
+
description: 'Button variant style',
|
|
12
|
+
table: {
|
|
13
|
+
defaultValue: { summary: 'primary' }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Story name="Button">
|
|
24
|
+
{#snippet template(args)}
|
|
25
|
+
<ButtonCmp {...args}>Click me</ButtonCmp>
|
|
26
|
+
{/snippet}
|
|
27
|
+
</Story>
|
|
@@ -1,96 +1,101 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { isBefore, isSameDay, isWithinInterval } from 'date-fns';
|
|
3
|
-
import { CalendarBond } from './bond.svelte';
|
|
4
|
-
import type { CalendarDayProps } from './types';
|
|
5
|
-
import { HtmlAtom } from '../atom';
|
|
6
|
-
|
|
7
|
-
const calendarBond = CalendarBond.get();
|
|
8
|
-
|
|
9
|
-
const selectedDateStart = $derived(calendarBond?.state.props.start);
|
|
10
|
-
const selectedDateEnd = $derived(calendarBond?.state.props.end);
|
|
11
|
-
const isRange = $derived(Array.isArray(calendarBond?.state.props.type === 'range'));
|
|
12
|
-
|
|
13
|
-
let {
|
|
14
|
-
class: klass = '',
|
|
15
|
-
preset = 'calendar.day',
|
|
16
|
-
day,
|
|
17
|
-
as = 'button',
|
|
18
|
-
children = undefined,
|
|
19
|
-
onclick = handleClick,
|
|
20
|
-
...restProps
|
|
21
|
-
}: CalendarDayProps = $props();
|
|
22
|
-
|
|
23
|
-
const dayProps = $derived({
|
|
24
|
-
...calendarBond?.day(day),
|
|
25
|
-
...restProps
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const isSelected = $derived.by(() => {
|
|
29
|
-
if (selectedDateEnd && selectedDateStart) {
|
|
30
|
-
return isWithinInterval(day.date, { end: selectedDateEnd, start: selectedDateStart });
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return selectedDateStart && isSameDay(day.date, selectedDateStart);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
function handleClick() {
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
calendarBond?.state.
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
day
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
isSelected &&
|
|
66
|
-
|
|
67
|
-
day.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
data-
|
|
76
|
-
data-
|
|
77
|
-
{
|
|
78
|
-
{
|
|
79
|
-
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { isBefore, isSameDay, isWithinInterval } from 'date-fns';
|
|
3
|
+
import { CalendarBond } from './bond.svelte';
|
|
4
|
+
import type { CalendarDayProps } from './types';
|
|
5
|
+
import { HtmlAtom } from '../atom';
|
|
6
|
+
|
|
7
|
+
const calendarBond = CalendarBond.get();
|
|
8
|
+
|
|
9
|
+
const selectedDateStart = $derived(calendarBond?.state.props.start);
|
|
10
|
+
const selectedDateEnd = $derived(calendarBond?.state.props.end);
|
|
11
|
+
const isRange = $derived(Array.isArray(calendarBond?.state.props.type === 'range'));
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
class: klass = '',
|
|
15
|
+
preset = 'calendar.day',
|
|
16
|
+
day,
|
|
17
|
+
as = 'button',
|
|
18
|
+
children = undefined,
|
|
19
|
+
onclick = handleClick,
|
|
20
|
+
...restProps
|
|
21
|
+
}: CalendarDayProps = $props();
|
|
22
|
+
|
|
23
|
+
const dayProps = $derived({
|
|
24
|
+
...calendarBond?.day(day),
|
|
25
|
+
...restProps
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const isSelected = $derived.by(() => {
|
|
29
|
+
if (selectedDateEnd && selectedDateStart) {
|
|
30
|
+
return isWithinInterval(day.date, { end: selectedDateEnd, start: selectedDateStart });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return selectedDateStart && isSameDay(day.date, selectedDateStart);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
function handleClick() {
|
|
37
|
+
if (day.disabled) return;
|
|
38
|
+
|
|
39
|
+
if (isRange) {
|
|
40
|
+
const start = calendarBond?.state.props.start;
|
|
41
|
+
if (!start) {
|
|
42
|
+
calendarBond?.state.selectStart(new Date(day.date));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (isBefore(new Date(day.date), new Date(start))) {
|
|
47
|
+
calendarBond?.state.selectStart(new Date(day.date));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
calendarBond?.state.selectEnd(new Date(day.date));
|
|
52
|
+
} else {
|
|
53
|
+
calendarBond?.state.selectStart(new Date(day.date));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<HtmlAtom
|
|
59
|
+
{as}
|
|
60
|
+
{preset}
|
|
61
|
+
class={[
|
|
62
|
+
'calendar-day text-foreground border-border hover:bg-accent hover:text-accent-foreground h-12 cursor-pointer border-b border-l p-1 transition-colors',
|
|
63
|
+
day.offmonth && !day.disabled && 'text-muted-foreground/50 bg-muted/50',
|
|
64
|
+
day.weekend && 'bg-accent',
|
|
65
|
+
isSelected &&
|
|
66
|
+
'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground',
|
|
67
|
+
isSelected && day.offmonth && 'bg-primary/70',
|
|
68
|
+
day.today &&
|
|
69
|
+
!day.disabled &&
|
|
70
|
+
!isSelected &&
|
|
71
|
+
'border-primary bg-primary/5 border-2 font-semibold',
|
|
72
|
+
day.disabled && 'pointer-events-none opacity-25',
|
|
73
|
+
klass
|
|
74
|
+
]}
|
|
75
|
+
data-disabled={day.disabled}
|
|
76
|
+
data-prec={day.fromPreviousMonth}
|
|
77
|
+
data-next={day.fromNextMonth}
|
|
78
|
+
data-offmonth={day.offmonth}
|
|
79
|
+
data-weekend={day.weekend}
|
|
80
|
+
data-today={day.today}
|
|
81
|
+
data-selected={isSelected}
|
|
82
|
+
{onclick}
|
|
83
|
+
{...dayProps}
|
|
84
|
+
>
|
|
85
|
+
{#if children}
|
|
86
|
+
{@render children({
|
|
87
|
+
calendar: calendarBond!
|
|
88
|
+
})}
|
|
89
|
+
{:else}
|
|
90
|
+
<span class="value">{day.dayOfMonth}</span>
|
|
91
|
+
{/if}
|
|
92
|
+
</HtmlAtom>
|
|
93
|
+
|
|
94
|
+
<style>
|
|
95
|
+
:global(.calendar-day):nth-child(7n + 1) {
|
|
96
|
+
border-left: none;
|
|
97
|
+
}
|
|
98
|
+
:global(.calendar-day):nth-last-child(-n + 7) {
|
|
99
|
+
border-bottom: none;
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { Calendar as CalendarModule } from '.';
|
|
4
|
-
|
|
5
|
-
const { Story } = defineMeta({
|
|
6
|
-
title: 'Atoms/Calendar'
|
|
7
|
-
});
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<script>
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<Story name="Calendar">
|
|
14
|
-
{#snippet children({ args })}
|
|
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>
|
|
25
|
-
{/snippet}
|
|
26
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Calendar as CalendarModule } from '.';
|
|
4
|
+
|
|
5
|
+
const { Story } = defineMeta({
|
|
6
|
+
title: 'Atoms/Calendar'
|
|
7
|
+
});
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Story name="Calendar">
|
|
14
|
+
{#snippet children({ args })}
|
|
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>
|
|
25
|
+
{/snippet}
|
|
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 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
|
+
<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 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>
|
|
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>
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import { defineState } from '../../utils';
|
|
3
|
-
import { defineProperty } from '../../utils/state';
|
|
4
|
-
import { HtmlAtom, type Base } from '../atom';
|
|
5
|
-
import { CardBond, CardBondState, type CardBondProps } from './bond.svelte';
|
|
6
|
-
import type { CardRootProps } from './types';
|
|
7
|
-
import './card.css';
|
|
8
|
-
|
|
9
|
-
let {
|
|
10
|
-
class: klass = '',
|
|
11
|
-
disabled = false,
|
|
12
|
-
factory = _factory,
|
|
13
|
-
children = undefined,
|
|
14
|
-
onclick = undefined,
|
|
15
|
-
onkeydown = undefined,
|
|
16
|
-
onmount = undefined,
|
|
17
|
-
ondestroy = undefined,
|
|
18
|
-
animate = undefined,
|
|
19
|
-
enter = undefined,
|
|
20
|
-
exit = undefined,
|
|
21
|
-
initial = undefined,
|
|
22
|
-
...restProps
|
|
23
|
-
}: CardRootProps<E, B> = $props();
|
|
24
|
-
|
|
25
|
-
const bondProps = defineState<CardBondProps>(
|
|
26
|
-
[
|
|
27
|
-
defineProperty(
|
|
28
|
-
'disabled',
|
|
29
|
-
() => disabled,
|
|
30
|
-
(v) => {
|
|
31
|
-
disabled = v;
|
|
32
|
-
}
|
|
33
|
-
)
|
|
34
|
-
],
|
|
35
|
-
() => ({})
|
|
36
|
-
);
|
|
37
|
-
const bond = _factory(bondProps).share();
|
|
38
|
-
|
|
39
|
-
// Disabled styles
|
|
40
|
-
const disabledStyles = disabled ? 'opacity-50 cursor-not-allowed' : '';
|
|
41
|
-
|
|
42
|
-
const rootProps = $derived({
|
|
43
|
-
...bond?.root(),
|
|
44
|
-
...restProps
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
function _factory(props: typeof bondProps) {
|
|
48
|
-
const bondState = new CardBondState(() => props);
|
|
49
|
-
return new CardBond(bondState);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function handleClick(event: MouseEvent) {
|
|
53
|
-
if (disabled) return;
|
|
54
|
-
onclick?.(event);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function handleKeydown(event: KeyboardEvent) {
|
|
58
|
-
if (disabled) return;
|
|
59
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
60
|
-
event.preventDefault();
|
|
61
|
-
onclick?.(event as unknown as MouseEvent);
|
|
62
|
-
}
|
|
63
|
-
onkeydown?.(event);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function getBond() {
|
|
67
|
-
return bond;
|
|
68
|
-
}
|
|
69
|
-
</script>
|
|
70
|
-
|
|
71
|
-
<HtmlAtom
|
|
72
|
-
preset="card"
|
|
73
|
-
class={[
|
|
74
|
-
'card bg-card border-border flex flex-col overflow-clip rounded-lg border shadow-sm',
|
|
75
|
-
disabledStyles,
|
|
76
|
-
'$preset',
|
|
77
|
-
klass
|
|
78
|
-
]}
|
|
79
|
-
{bond}
|
|
80
|
-
enter={enter?.bind(bond.state)}
|
|
81
|
-
exit={exit?.bind(bond.state)}
|
|
82
|
-
initial={initial?.bind(bond.state)}
|
|
83
|
-
animate={animate?.bind(bond.state)}
|
|
84
|
-
onmount={onmount?.bind(bond.state)}
|
|
85
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
86
|
-
onclick={handleClick}
|
|
87
|
-
onkeydown={handleKeydown}
|
|
88
|
-
{...rootProps}
|
|
89
|
-
>
|
|
90
|
-
{@render children?.({ card: bond })}
|
|
91
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import { defineState } from '../../utils';
|
|
3
|
+
import { defineProperty } from '../../utils/state';
|
|
4
|
+
import { HtmlAtom, type Base } from '../atom';
|
|
5
|
+
import { CardBond, CardBondState, type CardBondProps } from './bond.svelte';
|
|
6
|
+
import type { CardRootProps } from './types';
|
|
7
|
+
import './card.css';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
class: klass = '',
|
|
11
|
+
disabled = false,
|
|
12
|
+
factory = _factory,
|
|
13
|
+
children = undefined,
|
|
14
|
+
onclick = undefined,
|
|
15
|
+
onkeydown = undefined,
|
|
16
|
+
onmount = undefined,
|
|
17
|
+
ondestroy = undefined,
|
|
18
|
+
animate = undefined,
|
|
19
|
+
enter = undefined,
|
|
20
|
+
exit = undefined,
|
|
21
|
+
initial = undefined,
|
|
22
|
+
...restProps
|
|
23
|
+
}: CardRootProps<E, B> = $props();
|
|
24
|
+
|
|
25
|
+
const bondProps = defineState<CardBondProps>(
|
|
26
|
+
[
|
|
27
|
+
defineProperty(
|
|
28
|
+
'disabled',
|
|
29
|
+
() => disabled,
|
|
30
|
+
(v) => {
|
|
31
|
+
disabled = v;
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
],
|
|
35
|
+
() => ({})
|
|
36
|
+
);
|
|
37
|
+
const bond = _factory(bondProps).share();
|
|
38
|
+
|
|
39
|
+
// Disabled styles
|
|
40
|
+
const disabledStyles = disabled ? 'opacity-50 cursor-not-allowed' : '';
|
|
41
|
+
|
|
42
|
+
const rootProps = $derived({
|
|
43
|
+
...bond?.root(),
|
|
44
|
+
...restProps
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
function _factory(props: typeof bondProps) {
|
|
48
|
+
const bondState = new CardBondState(() => props);
|
|
49
|
+
return new CardBond(bondState);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function handleClick(event: MouseEvent) {
|
|
53
|
+
if (disabled) return;
|
|
54
|
+
onclick?.(event);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
58
|
+
if (disabled) return;
|
|
59
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
onclick?.(event as unknown as MouseEvent);
|
|
62
|
+
}
|
|
63
|
+
onkeydown?.(event);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function getBond() {
|
|
67
|
+
return bond;
|
|
68
|
+
}
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<HtmlAtom
|
|
72
|
+
preset="card"
|
|
73
|
+
class={[
|
|
74
|
+
'card bg-card border-border flex flex-col overflow-clip rounded-lg border shadow-sm',
|
|
75
|
+
disabledStyles,
|
|
76
|
+
'$preset',
|
|
77
|
+
klass
|
|
78
|
+
]}
|
|
79
|
+
{bond}
|
|
80
|
+
enter={enter?.bind(bond.state)}
|
|
81
|
+
exit={exit?.bind(bond.state)}
|
|
82
|
+
initial={initial?.bind(bond.state)}
|
|
83
|
+
animate={animate?.bind(bond.state)}
|
|
84
|
+
onmount={onmount?.bind(bond.state)}
|
|
85
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
86
|
+
onclick={handleClick}
|
|
87
|
+
onkeydown={handleKeydown}
|
|
88
|
+
{...rootProps}
|
|
89
|
+
>
|
|
90
|
+
{@render children?.({ card: bond })}
|
|
91
|
+
</HtmlAtom>
|