@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
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
enter = undefined,
|
|
21
21
|
exit = undefined,
|
|
22
22
|
initial = undefined,
|
|
23
|
+
preset = 'accordion',
|
|
23
24
|
...restProps
|
|
24
25
|
}: AccordionRootProps<E, B> = $props();
|
|
25
26
|
|
|
@@ -31,7 +32,10 @@
|
|
|
31
32
|
values = v;
|
|
32
33
|
value = values[0];
|
|
33
34
|
}
|
|
34
|
-
)
|
|
35
|
+
),
|
|
36
|
+
defineProperty('multiple', () => multiple),
|
|
37
|
+
defineProperty('collapsible', () => collapsible),
|
|
38
|
+
defineProperty('disabled', () => disabled)
|
|
35
39
|
]);
|
|
36
40
|
const bond = factory(bondProps).share();
|
|
37
41
|
|
|
@@ -52,9 +56,9 @@
|
|
|
52
56
|
</script>
|
|
53
57
|
|
|
54
58
|
<HtmlAtom
|
|
55
|
-
preset
|
|
56
|
-
class={['bg-card border-border flex list-none flex-col', '$preset', klass]}
|
|
59
|
+
{preset}
|
|
57
60
|
{bond}
|
|
61
|
+
class={['bg-card border-border flex list-none flex-col', '$preset', klass]}
|
|
58
62
|
{...rootProps}
|
|
59
63
|
>
|
|
60
64
|
{@render children?.({ accordion: bond })}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
<script module>
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
3
|
import { Accordion as AAccordion, AccordionItem } from '.';
|
|
4
|
-
import { linear } from 'svelte/easing';
|
|
5
|
-
import { animate } from 'motion';
|
|
6
4
|
|
|
7
5
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
6
|
const { Story } = defineMeta({
|
|
@@ -21,40 +19,15 @@
|
|
|
21
19
|
</script>
|
|
22
20
|
|
|
23
21
|
<Story name="Accordion" args={{ collapsible: false, multiple: false, disabled: false }}>
|
|
24
|
-
{#snippet
|
|
22
|
+
{#snippet template(args)}
|
|
25
23
|
<AAccordion class="backdrop-blur-sm" {...args}>
|
|
26
24
|
<AccordionItem.Root>
|
|
27
25
|
<AccordionItem.Header>
|
|
28
26
|
<div>Hello Atomic UI 1</div>
|
|
29
|
-
<AccordionItem.Indicator />
|
|
27
|
+
<AccordionItem.Indicator class="ml-auto" />
|
|
30
28
|
</AccordionItem.Header>
|
|
31
29
|
|
|
32
|
-
<AccordionItem.Body
|
|
33
|
-
initial={(node) => {
|
|
34
|
-
Object.assign(node.style, { opacity: 0, height: 0 });
|
|
35
|
-
}}
|
|
36
|
-
enter={function (node) {
|
|
37
|
-
const d = 0.2;
|
|
38
|
-
animate(
|
|
39
|
-
node,
|
|
40
|
-
{
|
|
41
|
-
opacity: 1,
|
|
42
|
-
height: 'auto'
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
duration: d
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
return { duration: d * 1000 };
|
|
50
|
-
}}
|
|
51
|
-
exit={(node) => {
|
|
52
|
-
const d = 0.2;
|
|
53
|
-
animate(node, { opacity: 0, height: 0 }, { duration: d });
|
|
54
|
-
|
|
55
|
-
return { duration: d * 1000 };
|
|
56
|
-
}}
|
|
57
|
-
>
|
|
30
|
+
<AccordionItem.Body>
|
|
58
31
|
<div class="p-2">
|
|
59
32
|
Mauris et habitasse cubilia potenti at condimentum iaculis nam. Ante fusce litora
|
|
60
33
|
tristique letius libero. Curabitur vitae cursus consectetur feugiat aenean viverra vel
|
|
@@ -66,34 +39,10 @@
|
|
|
66
39
|
<AccordionItem.Root>
|
|
67
40
|
<AccordionItem.Header>
|
|
68
41
|
<div>Hello Atomic UI 2</div>
|
|
69
|
-
<AccordionItem.Indicator />
|
|
42
|
+
<AccordionItem.Indicator class="ml-auto" />
|
|
70
43
|
</AccordionItem.Header>
|
|
71
44
|
|
|
72
|
-
<AccordionItem.Body
|
|
73
|
-
initial={(node) => {
|
|
74
|
-
Object.assign(node.style, { opacity: 0, height: 0 });
|
|
75
|
-
}}
|
|
76
|
-
enter={(node) => {
|
|
77
|
-
animate(
|
|
78
|
-
node,
|
|
79
|
-
{
|
|
80
|
-
opacity: 1,
|
|
81
|
-
height: 'auto'
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
duration: 0.2,
|
|
85
|
-
ease: linear
|
|
86
|
-
}
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
return { duration: 0.2 };
|
|
90
|
-
}}
|
|
91
|
-
exit={(node) => {
|
|
92
|
-
animate(node, { opacity: 0, height: 0 }, { duration: 0.2, ease: linear });
|
|
93
|
-
|
|
94
|
-
return { duration: 0.2 };
|
|
95
|
-
}}
|
|
96
|
-
>
|
|
45
|
+
<AccordionItem.Body>
|
|
97
46
|
<div class="p-2">
|
|
98
47
|
Mauris et habitasse cubilia potenti at condimentum iaculis nam. Ante fusce litora
|
|
99
48
|
tristique letius libero. Curabitur vitae cursus consectetur feugiat aenean viverra vel
|
|
@@ -105,34 +54,10 @@
|
|
|
105
54
|
<AccordionItem.Root>
|
|
106
55
|
<AccordionItem.Header>
|
|
107
56
|
<div>Hello Atomic UI 3</div>
|
|
108
|
-
<AccordionItem.Indicator />
|
|
57
|
+
<AccordionItem.Indicator class="ml-auto" />
|
|
109
58
|
</AccordionItem.Header>
|
|
110
59
|
|
|
111
|
-
<AccordionItem.Body
|
|
112
|
-
initial={(node) => {
|
|
113
|
-
Object.assign(node.style, { opacity: 0, height: 0 });
|
|
114
|
-
}}
|
|
115
|
-
enter={(node) => {
|
|
116
|
-
animate(
|
|
117
|
-
node,
|
|
118
|
-
{
|
|
119
|
-
opacity: 1,
|
|
120
|
-
height: 'auto'
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
duration: 0.2,
|
|
124
|
-
ease: linear
|
|
125
|
-
}
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
return { duration: 0.2 };
|
|
129
|
-
}}
|
|
130
|
-
exit={(node) => {
|
|
131
|
-
animate(node, { opacity: 0, height: 0 }, { duration: 0.2, ease: linear });
|
|
132
|
-
|
|
133
|
-
return { duration: 0.2 };
|
|
134
|
-
}}
|
|
135
|
-
>
|
|
60
|
+
<AccordionItem.Body>
|
|
136
61
|
<div class="p-2">
|
|
137
62
|
Mauris et habitasse cubilia potenti at condimentum iaculis nam. Ante fusce litora
|
|
138
63
|
tristique letius libero. Curabitur vitae cursus consectetur feugiat aenean viverra vel
|
|
@@ -1,42 +1,44 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import { HtmlAtom, type Base } from '../../atom';
|
|
3
|
-
import { AccordionItemBond } from './bond.svelte';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
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" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import { HtmlAtom, type Base } from '../../atom';
|
|
3
|
+
import { AccordionItemBond } from './bond.svelte';
|
|
4
|
+
import { enterAccordionItemBody, exitAccordionItemBody } from './motion.svelte';
|
|
5
|
+
import type { AccordionItemBodyProps } from './types';
|
|
6
|
+
|
|
7
|
+
const bond = AccordionItemBond.get();
|
|
8
|
+
const isOpen = $derived(bond?.state.isOpen ?? false);
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
class: klass = '',
|
|
12
|
+
children = undefined,
|
|
13
|
+
onmount = undefined,
|
|
14
|
+
ondestroy = undefined,
|
|
15
|
+
animate = undefined,
|
|
16
|
+
enter = enterAccordionItemBody(),
|
|
17
|
+
exit = exitAccordionItemBody(),
|
|
18
|
+
initial = undefined,
|
|
19
|
+
preset = 'accordion.item.body',
|
|
20
|
+
...restProps
|
|
21
|
+
}: AccordionItemBodyProps<E, B> = $props();
|
|
22
|
+
|
|
23
|
+
const bodyProps = $derived({
|
|
24
|
+
...bond?.body(),
|
|
25
|
+
...restProps
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
{#if isOpen}
|
|
30
|
+
<HtmlAtom
|
|
31
|
+
{preset}
|
|
32
|
+
{bond}
|
|
33
|
+
class={['border-border box-content h-0 opacity-0', '$preset', klass]}
|
|
34
|
+
onmount={onmount?.bind(bond.state)}
|
|
35
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
36
|
+
animate={animate?.bind(bond.state)}
|
|
37
|
+
enter={enter?.bind(bond.state)}
|
|
38
|
+
exit={exit?.bind(bond.state)}
|
|
39
|
+
initial={initial?.bind(bond.state)}
|
|
40
|
+
{...bodyProps}
|
|
41
|
+
>
|
|
42
|
+
{@render children?.({ accordionItem: bond })}
|
|
43
|
+
</HtmlAtom>
|
|
44
|
+
{/if}
|
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import { HtmlAtom, type Base } from '../../atom';
|
|
3
|
-
import { AccordionItemBond } from './bond.svelte';
|
|
4
|
-
import type { AccordionItemHeaderProps } from './types';
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
class: klass = '',
|
|
8
|
-
as = 'button',
|
|
9
|
-
children = undefined,
|
|
10
|
-
onpointerdown = undefined,
|
|
11
|
-
onmount = undefined,
|
|
12
|
-
ondestroy = undefined,
|
|
13
|
-
animate = undefined,
|
|
14
|
-
enter = undefined,
|
|
15
|
-
exit = undefined,
|
|
16
|
-
initial = undefined,
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import { HtmlAtom, type Base } from '../../atom';
|
|
3
|
+
import { AccordionItemBond } from './bond.svelte';
|
|
4
|
+
import type { AccordionItemHeaderProps } from './types';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
class: klass = '',
|
|
8
|
+
as = 'button',
|
|
9
|
+
children = undefined,
|
|
10
|
+
onpointerdown = undefined,
|
|
11
|
+
onmount = undefined,
|
|
12
|
+
ondestroy = undefined,
|
|
13
|
+
animate = undefined,
|
|
14
|
+
enter = undefined,
|
|
15
|
+
exit = undefined,
|
|
16
|
+
initial = undefined,
|
|
17
|
+
preset = 'accordion.item.header',
|
|
18
|
+
...restProps
|
|
19
|
+
}: AccordionItemHeaderProps = $props();
|
|
20
|
+
|
|
21
|
+
const bond = AccordionItemBond.get();
|
|
22
|
+
|
|
23
|
+
const headerProps = $derived({
|
|
24
|
+
...bond?.header(),
|
|
25
|
+
...restProps
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
30
|
+
<HtmlAtom
|
|
31
|
+
{as}
|
|
32
|
+
{bond}
|
|
33
|
+
{preset}
|
|
34
|
+
class={[
|
|
35
|
+
'border-border relative box-border flex w-full cursor-pointer items-center',
|
|
36
|
+
'$preset',
|
|
37
|
+
klass
|
|
38
|
+
]}
|
|
39
|
+
onmount={onmount?.bind(bond.state)}
|
|
40
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
41
|
+
animate={animate?.bind(bond.state)}
|
|
42
|
+
enter={enter?.bind(bond.state)}
|
|
43
|
+
exit={exit?.bind(bond.state)}
|
|
44
|
+
initial={initial?.bind(bond.state)}
|
|
45
|
+
tabindex={as !== 'button' ? 0 : undefined}
|
|
46
|
+
{...headerProps}
|
|
47
|
+
>
|
|
48
|
+
{@render children?.({
|
|
49
|
+
accordionItem: bond
|
|
50
|
+
})}
|
|
51
|
+
</HtmlAtom>
|
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import { animate as motion } from 'motion';
|
|
3
|
-
import { Icon } from '../../icon';
|
|
4
|
-
import IconArrowDown from '../../../icons/icon-arrow-down.svelte';
|
|
5
|
-
import { HtmlAtom, type Base } from '../../atom';
|
|
6
|
-
import { AccordionItemBond } from './bond.svelte';
|
|
7
|
-
import type { AccordionItemIndicatorProps } from './types';
|
|
8
|
-
|
|
9
|
-
const bond = AccordionItemBond.get();
|
|
10
|
-
const isOpen = $derived(bond?.state?.isOpen ?? false);
|
|
11
|
-
|
|
12
|
-
let {
|
|
13
|
-
class: klass = '',
|
|
14
|
-
children = undefined,
|
|
15
|
-
onmount = undefined,
|
|
16
|
-
ondestroy = undefined,
|
|
17
|
-
animate = _animate,
|
|
18
|
-
enter = undefined,
|
|
19
|
-
exit = undefined,
|
|
20
|
-
initial = undefined,
|
|
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
|
-
|
|
1
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import { animate as motion } from 'motion';
|
|
3
|
+
import { Icon } from '../../icon';
|
|
4
|
+
import IconArrowDown from '../../../icons/icon-arrow-down.svelte';
|
|
5
|
+
import { HtmlAtom, type Base } from '../../atom';
|
|
6
|
+
import { AccordionItemBond } from './bond.svelte';
|
|
7
|
+
import type { AccordionItemIndicatorProps } from './types';
|
|
8
|
+
|
|
9
|
+
const bond = AccordionItemBond.get();
|
|
10
|
+
const isOpen = $derived(bond?.state?.isOpen ?? false);
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
class: klass = '',
|
|
14
|
+
children = undefined,
|
|
15
|
+
onmount = undefined,
|
|
16
|
+
ondestroy = undefined,
|
|
17
|
+
animate = _animate,
|
|
18
|
+
enter = undefined,
|
|
19
|
+
exit = undefined,
|
|
20
|
+
initial = undefined,
|
|
21
|
+
preset = 'accordion.item.indicator',
|
|
22
|
+
...restProps
|
|
23
|
+
}: AccordionItemIndicatorProps<E, B> = $props();
|
|
24
|
+
|
|
25
|
+
const indicatorProps = $derived({
|
|
26
|
+
...bond?.indicator(),
|
|
27
|
+
...restProps
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
function _animate(node: HTMLElement) {
|
|
31
|
+
return motion(node, { rotate: 180 * +isOpen }, { duration: 0.3, ease: 'anticipate' });
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<HtmlAtom
|
|
36
|
+
{preset}
|
|
37
|
+
class={['border-border pointer-events-none flex items-center justify-center', '$preset', klass]}
|
|
38
|
+
onmount={onmount?.bind(bond.state)}
|
|
39
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
40
|
+
animate={animate?.bind(bond.state)}
|
|
41
|
+
enter={enter?.bind(bond.state)}
|
|
42
|
+
exit={exit?.bind(bond.state)}
|
|
43
|
+
initial={initial?.bind(bond.state)}
|
|
44
|
+
{...indicatorProps}
|
|
45
|
+
>
|
|
46
|
+
{#if children}
|
|
47
|
+
{@render children({ accordionItem: bond })}
|
|
48
|
+
{:else}
|
|
49
|
+
<Icon src={IconArrowDown} />
|
|
50
|
+
{/if}
|
|
51
|
+
</HtmlAtom>
|
|
@@ -1,65 +1,66 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import { nanoid } from 'nanoid';
|
|
3
|
-
import { defineProperty, defineState } from '../../../utils';
|
|
4
|
-
import { HtmlAtom, type Base } from '../../atom';
|
|
5
|
-
import {
|
|
6
|
-
AccordionItemBond,
|
|
7
|
-
AccordionItemBondState,
|
|
8
|
-
type AccordionItemBondProps
|
|
9
|
-
} from './bond.svelte';
|
|
10
|
-
import type { AccordionItemRootProps } from './types';
|
|
11
|
-
|
|
12
|
-
let {
|
|
13
|
-
class: klass = '',
|
|
14
|
-
value = nanoid(),
|
|
15
|
-
data = undefined,
|
|
16
|
-
disabled = false,
|
|
17
|
-
factory = _factory,
|
|
18
|
-
children = undefined,
|
|
19
|
-
onmount = undefined,
|
|
20
|
-
ondestroy = undefined,
|
|
21
|
-
animate = undefined,
|
|
22
|
-
enter = undefined,
|
|
23
|
-
exit = undefined,
|
|
24
|
-
initial = undefined,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
defineProperty('
|
|
31
|
-
defineProperty('
|
|
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
|
-
|
|
1
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import { nanoid } from 'nanoid';
|
|
3
|
+
import { defineProperty, defineState } from '../../../utils';
|
|
4
|
+
import { HtmlAtom, type Base } from '../../atom';
|
|
5
|
+
import {
|
|
6
|
+
AccordionItemBond,
|
|
7
|
+
AccordionItemBondState,
|
|
8
|
+
type AccordionItemBondProps
|
|
9
|
+
} from './bond.svelte';
|
|
10
|
+
import type { AccordionItemRootProps } from './types';
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
class: klass = '',
|
|
14
|
+
value = nanoid(),
|
|
15
|
+
data = undefined,
|
|
16
|
+
disabled = false,
|
|
17
|
+
factory = _factory,
|
|
18
|
+
children = undefined,
|
|
19
|
+
onmount = undefined,
|
|
20
|
+
ondestroy = undefined,
|
|
21
|
+
animate = undefined,
|
|
22
|
+
enter = undefined,
|
|
23
|
+
exit = undefined,
|
|
24
|
+
initial = undefined,
|
|
25
|
+
preset = 'accordion.item',
|
|
26
|
+
...restProps
|
|
27
|
+
}: AccordionItemRootProps<E, B> = $props();
|
|
28
|
+
|
|
29
|
+
const accordionItemProps = defineState<AccordionItemBondProps>([
|
|
30
|
+
defineProperty('data', () => data),
|
|
31
|
+
defineProperty('disabled', () => disabled),
|
|
32
|
+
defineProperty('value', () => value)
|
|
33
|
+
]);
|
|
34
|
+
const bond = factory(accordionItemProps).share();
|
|
35
|
+
|
|
36
|
+
bond.state.mount();
|
|
37
|
+
|
|
38
|
+
const rootProps = $derived({
|
|
39
|
+
...bond.root(),
|
|
40
|
+
...restProps
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
function _factory(props: typeof accordionItemProps) {
|
|
44
|
+
const accordionItemState = new AccordionItemBondState(() => props);
|
|
45
|
+
return new AccordionItemBond(accordionItemState);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function getBond() {
|
|
49
|
+
return bond;
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<HtmlAtom
|
|
54
|
+
{bond}
|
|
55
|
+
{preset}
|
|
56
|
+
class={['border-border', '$preset', klass]}
|
|
57
|
+
onmount={onmount?.bind(bond.state)}
|
|
58
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
59
|
+
animate={animate?.bind(bond.state)}
|
|
60
|
+
enter={enter?.bind(bond.state)}
|
|
61
|
+
exit={exit?.bind(bond.state)}
|
|
62
|
+
initial={initial?.bind(bond.state)}
|
|
63
|
+
{...rootProps}
|
|
64
|
+
>
|
|
65
|
+
{@render children?.({ accordionItem: bond })}
|
|
66
|
+
</HtmlAtom>
|
|
@@ -3,6 +3,8 @@ import { Bond, BondState, type BondStateProps } from '../../../shared/bond.svelt
|
|
|
3
3
|
export type AccordionItemBondProps = BondStateProps & {
|
|
4
4
|
value: string;
|
|
5
5
|
disabled: boolean;
|
|
6
|
+
multiple: boolean;
|
|
7
|
+
collapsible: boolean;
|
|
6
8
|
};
|
|
7
9
|
export type AccordionItemBondElements = {
|
|
8
10
|
root: HTMLElement;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Easing } from 'motion';
|
|
2
|
+
export type EnterAccordionItemBodyParams = {
|
|
3
|
+
duration?: number;
|
|
4
|
+
delay?: number;
|
|
5
|
+
ease?: Easing | Easing[] | (string & {});
|
|
6
|
+
};
|
|
7
|
+
export declare function enterAccordionItemBody(params?: EnterAccordionItemBodyParams): (node: HTMLElement) => {
|
|
8
|
+
duration: number;
|
|
9
|
+
delay: number;
|
|
10
|
+
};
|
|
11
|
+
export type ExitAccordionItemBodyParams = EnterAccordionItemBodyParams;
|
|
12
|
+
export declare function exitAccordionItemBody(params?: ExitAccordionItemBodyParams): (node: HTMLElement) => {
|
|
13
|
+
duration: number;
|
|
14
|
+
delay: number;
|
|
15
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DURATION } from '../../../shared';
|
|
2
|
+
import { animate } from 'motion';
|
|
3
|
+
export function enterAccordionItemBody(params = {}) {
|
|
4
|
+
return (node) => {
|
|
5
|
+
const { duration = DURATION.normal / 1000, delay = 0, ease = 'linear' } = params;
|
|
6
|
+
animate(node, {
|
|
7
|
+
opacity: [0, 1],
|
|
8
|
+
height: 'auto'
|
|
9
|
+
}, {
|
|
10
|
+
duration,
|
|
11
|
+
delay,
|
|
12
|
+
ease
|
|
13
|
+
});
|
|
14
|
+
return { duration: duration * 1000, delay: delay * 1000 };
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function exitAccordionItemBody(params = {}) {
|
|
18
|
+
return (node) => {
|
|
19
|
+
const { duration = DURATION.normal / 1000, delay = 0.1, ease = 'linear' } = params;
|
|
20
|
+
animate(node, {
|
|
21
|
+
opacity: [1, 0],
|
|
22
|
+
height: 0
|
|
23
|
+
}, {
|
|
24
|
+
duration,
|
|
25
|
+
delay,
|
|
26
|
+
ease
|
|
27
|
+
});
|
|
28
|
+
return { duration: duration * 1000, delay: delay * 1000 };
|
|
29
|
+
};
|
|
30
|
+
}
|