@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
|
@@ -1,126 +1,116 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { Scrollable as Scrollable_ } from '.';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
orientation="vertical"
|
|
118
|
-
class="left-[50%] w-2 origin-center translate-x-[-50%] rounded-none transition-colors"
|
|
119
|
-
/>
|
|
120
|
-
</Scrollable_.Track>
|
|
121
|
-
{/snippet}
|
|
122
|
-
</Scrollable_.Root>
|
|
123
|
-
</div>
|
|
124
|
-
{/snippet}
|
|
125
|
-
</Root>
|
|
126
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Scrollable as Scrollable_ } from '.';
|
|
4
|
+
import { animate } from 'motion';
|
|
5
|
+
import { ScrollableBond } from './bond.svelte';
|
|
6
|
+
import { on } from '../../attachments/event.svelte';
|
|
7
|
+
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
title: 'ATOMS/Scrollable'
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Story name="Scrollable">
|
|
14
|
+
{#snippet children({ args })}
|
|
15
|
+
<div class="h-full w-full flex-1">
|
|
16
|
+
<Scrollable_.Root
|
|
17
|
+
class="border-border box-border flex min-h-full w-full rounded-lg border shadow-inner"
|
|
18
|
+
open={false}
|
|
19
|
+
{@attach (node) => {
|
|
20
|
+
const scrollable = ScrollableBond.get();
|
|
21
|
+
if (!scrollable) return;
|
|
22
|
+
|
|
23
|
+
const c1 = on('pointerenter', () => {
|
|
24
|
+
scrollable.state.props.open = true;
|
|
25
|
+
})(node);
|
|
26
|
+
|
|
27
|
+
const c2 = on('pointerleave', () => {
|
|
28
|
+
scrollable.state.props.open = false;
|
|
29
|
+
})(node);
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
c1();
|
|
33
|
+
c2();
|
|
34
|
+
};
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
{#snippet children({ scrollable })}
|
|
38
|
+
<Scrollable_.Container class="max-h-[100svh]">
|
|
39
|
+
<Scrollable_.Content>
|
|
40
|
+
<div class="mx-auto w-[600px] p-4">
|
|
41
|
+
<h3 class="mb-4 text-lg font-semibold">Scrollable Content (New API)</h3>
|
|
42
|
+
<div class="grid grid-cols-3 gap-4">
|
|
43
|
+
{#each Array(99) as _, i}
|
|
44
|
+
<div class="rounded border p-4 shadow">
|
|
45
|
+
<h4 class="font-medium">Card {i + 1}</h4>
|
|
46
|
+
<p class="mt-2 text-sm">
|
|
47
|
+
This is some sample content in card {i + 1}. You can scroll horizontally and
|
|
48
|
+
vertically to see more content.
|
|
49
|
+
</p>
|
|
50
|
+
</div>
|
|
51
|
+
{/each}
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<div class="bg-foreground/10 mt-6 rounded p-4">
|
|
55
|
+
<p class="text-sm">
|
|
56
|
+
This content area is larger than the container, so you can scroll both
|
|
57
|
+
horizontally and vertically using the custom scrollbars or mouse wheel.
|
|
58
|
+
</p>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<div class="mt-4 flex gap-2">
|
|
62
|
+
<button
|
|
63
|
+
class="rounded bg-blue-500 px-3 py-2 hover:bg-blue-600"
|
|
64
|
+
onclick={() => scrollable.scrollTo(0, 0)}
|
|
65
|
+
>
|
|
66
|
+
Scroll to Top
|
|
67
|
+
</button>
|
|
68
|
+
<button
|
|
69
|
+
class="rounded bg-green-500 px-3 py-2 hover:bg-green-600"
|
|
70
|
+
onclick={() => scrollable.scrollBy(50, 50)}
|
|
71
|
+
>
|
|
72
|
+
Scroll +50px
|
|
73
|
+
</button>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</Scrollable_.Content>
|
|
77
|
+
</Scrollable_.Container>
|
|
78
|
+
|
|
79
|
+
<!-- New unified vertical scrollbar -->
|
|
80
|
+
<Scrollable_.Track
|
|
81
|
+
orientation="vertical"
|
|
82
|
+
class="inset-y-0 right-0 w-[2px] rounded-md"
|
|
83
|
+
initial={(node) => {
|
|
84
|
+
animate(node, { opacity: 0, right: 0, top: 0, bottom: 0 }, { duration: 0 });
|
|
85
|
+
}}
|
|
86
|
+
enter={(node) => {
|
|
87
|
+
animate(
|
|
88
|
+
node,
|
|
89
|
+
{ opacity: 1, right: 8, top: 8, bottom: 8 },
|
|
90
|
+
{ duration: 0.3, ease: 'easeOut' }
|
|
91
|
+
);
|
|
92
|
+
return {
|
|
93
|
+
duration: 300
|
|
94
|
+
};
|
|
95
|
+
}}
|
|
96
|
+
exit={(node) => {
|
|
97
|
+
animate(
|
|
98
|
+
node,
|
|
99
|
+
{ opacity: 0, right: 0, top: 0, bottom: 0 },
|
|
100
|
+
{ duration: 0.3, ease: 'easeOut' }
|
|
101
|
+
);
|
|
102
|
+
return {
|
|
103
|
+
duration: 300
|
|
104
|
+
};
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
<Scrollable_.Thumb
|
|
108
|
+
orientation="vertical"
|
|
109
|
+
class="left-[50%] w-2 origin-center translate-x-[-50%] rounded-none transition-colors"
|
|
110
|
+
/>
|
|
111
|
+
</Scrollable_.Track>
|
|
112
|
+
{/snippet}
|
|
113
|
+
</Scrollable_.Root>
|
|
114
|
+
</div>
|
|
115
|
+
{/snippet}
|
|
116
|
+
</Story>
|
|
@@ -14,12 +14,7 @@ export declare class SidebarBond<Props extends SidebarBondProps = SidebarBondPro
|
|
|
14
14
|
constructor(state: State);
|
|
15
15
|
content(props?: Record<string, unknown>): {
|
|
16
16
|
'aria-expanded': boolean;
|
|
17
|
-
'data-atom': string;
|
|
18
|
-
'data-kind': string;
|
|
19
|
-
};
|
|
20
|
-
root(props?: Record<string, unknown>): {
|
|
21
17
|
'aria-disabled': boolean;
|
|
22
|
-
'data-open': boolean;
|
|
23
18
|
'data-atom': string;
|
|
24
19
|
'data-kind': string;
|
|
25
20
|
};
|
|
@@ -9,6 +9,7 @@ export class SidebarBond extends Bond {
|
|
|
9
9
|
content(props = {}) {
|
|
10
10
|
return {
|
|
11
11
|
'aria-expanded': this.state?.props?.open ?? false,
|
|
12
|
+
'aria-disabled': this.state?.props?.disabled ?? false,
|
|
12
13
|
'data-atom': this.id,
|
|
13
14
|
'data-kind': 'sidebar-content',
|
|
14
15
|
...props,
|
|
@@ -17,18 +18,6 @@ export class SidebarBond extends Bond {
|
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
root(props = {}) {
|
|
21
|
-
return {
|
|
22
|
-
'aria-disabled': this.state?.props?.disabled ?? false,
|
|
23
|
-
'data-open': this.state?.props?.open ?? false,
|
|
24
|
-
'data-atom': this.id,
|
|
25
|
-
'data-kind': 'sidebar-root',
|
|
26
|
-
...props,
|
|
27
|
-
[createAttachmentKey()]: (node) => {
|
|
28
|
-
this.elements.root = node;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
21
|
share() {
|
|
33
22
|
return SidebarBond.set(this);
|
|
34
23
|
}
|
|
@@ -1,39 +1,50 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import { HtmlAtom, type Base } from '../atom';
|
|
3
|
-
import { SidebarBond } from './bond.svelte';
|
|
4
|
-
import type {
|
|
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
|
-
|
|
1
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import { HtmlAtom, type Base } from '../atom';
|
|
3
|
+
import { SidebarBond } from './bond.svelte';
|
|
4
|
+
import type { SidebarRootProps } from './types';
|
|
5
|
+
import { animate as motion } from 'motion';
|
|
6
|
+
|
|
7
|
+
const bond = SidebarBond.get();
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
class: klass = '',
|
|
11
|
+
width = 'auto',
|
|
12
|
+
children = undefined,
|
|
13
|
+
onmount = undefined,
|
|
14
|
+
ondestroy = undefined,
|
|
15
|
+
animate = _animate,
|
|
16
|
+
enter = undefined,
|
|
17
|
+
exit = undefined,
|
|
18
|
+
initial = _initial,
|
|
19
|
+
...restProps
|
|
20
|
+
}: SidebarRootProps<E, B> = $props();
|
|
21
|
+
|
|
22
|
+
const contentProps = $derived({
|
|
23
|
+
...bond?.content(),
|
|
24
|
+
...restProps
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const isOpen = $derived(bond?.state.props.open);
|
|
28
|
+
|
|
29
|
+
function _initial(node: HTMLElement) {
|
|
30
|
+
motion(node, { width: isOpen ? width : 0 }, { duration: 0 });
|
|
31
|
+
}
|
|
32
|
+
function _animate(node: HTMLElement) {
|
|
33
|
+
motion(node, { width: isOpen ? width : 0 }, { duration: 0.3, ease: 'anticipate' });
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<HtmlAtom
|
|
38
|
+
{bond}
|
|
39
|
+
preset="sidebar.content"
|
|
40
|
+
class={['bg-card border-border', '$preset', klass]}
|
|
41
|
+
enter={enter?.bind(bond.state)}
|
|
42
|
+
exit={exit?.bind(bond.state)}
|
|
43
|
+
initial={initial?.bind(bond.state)}
|
|
44
|
+
animate={animate?.bind(bond.state)}
|
|
45
|
+
onmount={onmount?.bind(bond.state)}
|
|
46
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
47
|
+
{...contentProps}
|
|
48
|
+
>
|
|
49
|
+
{@render children?.({ sidebar: bond })}
|
|
50
|
+
</HtmlAtom>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Base } from '../atom';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SidebarRootProps } from './types';
|
|
3
3
|
declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base>(): {
|
|
4
|
-
props:
|
|
4
|
+
props: SidebarRootProps<E, B>;
|
|
5
5
|
exports: {};
|
|
6
6
|
bindings: "";
|
|
7
7
|
slots: {};
|
|
@@ -1,68 +1,39 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import { defineProperty, defineState } from '../../utils';
|
|
3
|
-
import {
|
|
4
|
-
import { SidebarBond, SidebarBondState, type SidebarBondProps } from './bond.svelte';
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
let {
|
|
8
|
-
open = $bindable(false),
|
|
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
|
-
...restProps
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
function _factory(props: typeof bondProps) {
|
|
44
|
-
const bondState = new SidebarBondState(() => props);
|
|
45
|
-
const bond = new SidebarBond(bondState);
|
|
46
|
-
|
|
47
|
-
return bond;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function getBond() {
|
|
51
|
-
return bond;
|
|
52
|
-
}
|
|
53
|
-
</script>
|
|
54
|
-
|
|
55
|
-
<HtmlAtom
|
|
56
|
-
{bond}
|
|
57
|
-
preset="sidebar"
|
|
58
|
-
class={['border-border flex min-h-full w-full flex-1 flex-nowrap', '$preset', klass]}
|
|
59
|
-
enter={enter?.bind(bond.state)}
|
|
60
|
-
exit={exit?.bind(bond.state)}
|
|
61
|
-
initial={initial?.bind(bond.state)}
|
|
62
|
-
animate={animate?.bind(bond.state)}
|
|
63
|
-
onmount={onmount?.bind(bond.state)}
|
|
64
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
65
|
-
{...rootProps}
|
|
66
|
-
>
|
|
67
|
-
{@render children?.({ sidebar: bond })}
|
|
68
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import { defineProperty, defineState } from '../../utils';
|
|
3
|
+
import { type Base } from '../atom';
|
|
4
|
+
import { SidebarBond, SidebarBondState, type SidebarBondProps } from './bond.svelte';
|
|
5
|
+
import type { SidebarRootProps } from './types';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
open = $bindable(false),
|
|
9
|
+
disabled = false,
|
|
10
|
+
factory = _factory,
|
|
11
|
+
children = undefined
|
|
12
|
+
}: SidebarRootProps<E, B> = $props();
|
|
13
|
+
|
|
14
|
+
const bondProps = defineState<SidebarBondProps>([
|
|
15
|
+
defineProperty(
|
|
16
|
+
'open',
|
|
17
|
+
() => open,
|
|
18
|
+
(v) => {
|
|
19
|
+
open = v;
|
|
20
|
+
}
|
|
21
|
+
),
|
|
22
|
+
defineProperty('disabled', () => disabled)
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
const bond = factory(bondProps).share();
|
|
26
|
+
|
|
27
|
+
function _factory(props: typeof bondProps) {
|
|
28
|
+
const bondState = new SidebarBondState(() => props);
|
|
29
|
+
const bond = new SidebarBond(bondState);
|
|
30
|
+
|
|
31
|
+
return bond;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getBond() {
|
|
35
|
+
return bond;
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
{@render children?.({ sidebar: bond })}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Base } from '../atom';
|
|
2
2
|
import { SidebarBond, SidebarBondState, type SidebarBondProps } from './bond.svelte';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SidebarRootProps } from './types';
|
|
4
4
|
declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base>(): {
|
|
5
|
-
props:
|
|
5
|
+
props: SidebarRootProps<E, B>;
|
|
6
6
|
exports: {
|
|
7
7
|
getBond: () => SidebarBond<SidebarBondProps<Record<string, unknown>>, SidebarBondState<SidebarBondProps<Record<string, unknown>>>>;
|
|
8
8
|
};
|
|
@@ -1,52 +1,43 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import {
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
}}>Open</button
|
|
45
|
-
>
|
|
46
|
-
</div>
|
|
47
|
-
</Sidebar_.Content>
|
|
48
|
-
|
|
49
|
-
<div class="bg-foreground/2 flex-1 p-8">Hello World!</div>
|
|
50
|
-
</Sidebar_.Root>
|
|
51
|
-
</Root>
|
|
52
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Sidebar as Sidebar_ } from '.';
|
|
4
|
+
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
title: 'Atoms/Sidebar',
|
|
8
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
9
|
+
|
|
10
|
+
parameters: {
|
|
11
|
+
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
12
|
+
layout: 'fullscreen'
|
|
13
|
+
},
|
|
14
|
+
args: {}
|
|
15
|
+
});
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script lang="ts">
|
|
19
|
+
let isOpen = $state(false);
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<Story name="Sidebar" args={{}}>
|
|
23
|
+
<Sidebar_.Root class="" bind:open={isOpen}>
|
|
24
|
+
{#snippet children({ sidebar })}
|
|
25
|
+
<div class="flex size-full">
|
|
26
|
+
<Sidebar_.Content
|
|
27
|
+
class="flex min-w-32 flex-col border-r px-6 py-10 whitespace-nowrap"
|
|
28
|
+
width="300px"
|
|
29
|
+
>
|
|
30
|
+
<div>
|
|
31
|
+
<button
|
|
32
|
+
onclick={() => {
|
|
33
|
+
sidebar?.state.toggle?.();
|
|
34
|
+
}}>Open</button
|
|
35
|
+
>
|
|
36
|
+
</div>
|
|
37
|
+
</Sidebar_.Content>
|
|
38
|
+
|
|
39
|
+
<main class="bg-foreground/2 flex-1 p-8">Hello World!</main>
|
|
40
|
+
</div>
|
|
41
|
+
{/snippet}
|
|
42
|
+
</Sidebar_.Root>
|
|
43
|
+
</Story>
|
|
@@ -6,25 +6,26 @@ import type { Base, HtmlAtomProps } from '../atom';
|
|
|
6
6
|
/**
|
|
7
7
|
* Extend this interface to add custom slideover root properties in your application.
|
|
8
8
|
*/
|
|
9
|
-
export interface
|
|
9
|
+
export interface SidebarRootExtendProps {
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Extend this interface to add custom slideover content properties in your application.
|
|
13
13
|
*/
|
|
14
|
-
export interface
|
|
14
|
+
export interface SidebarContentExtendProps {
|
|
15
15
|
}
|
|
16
|
-
export interface
|
|
16
|
+
export interface SidebarRootProps<E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base> extends Override<HtmlAtomProps<E, B>, {
|
|
17
17
|
children?: Snippet<[{
|
|
18
18
|
sidebar?: SidebarBond;
|
|
19
19
|
}]>;
|
|
20
|
-
}>,
|
|
20
|
+
}>, SidebarRootExtendProps {
|
|
21
21
|
open?: boolean;
|
|
22
22
|
disabled?: boolean;
|
|
23
|
+
width?: string | number;
|
|
23
24
|
factory?: Factory<SidebarBond>;
|
|
24
25
|
}
|
|
25
|
-
export interface
|
|
26
|
+
export interface SidebarContentProps<E extends keyof HTMLElementTagNameMap, B extends Base = Base> extends Override<HtmlAtomProps<E, B>, {
|
|
26
27
|
children?: Snippet<[{
|
|
27
28
|
sidebar?: SidebarBond<any>;
|
|
28
29
|
}]>;
|
|
29
|
-
}>,
|
|
30
|
+
}>, SidebarContentExtendProps {
|
|
30
31
|
}
|
|
@@ -18,7 +18,10 @@ export declare class TabBond<T = unknown> extends Bond<TabBondProps<T>, TabBondS
|
|
|
18
18
|
mount(): (() => void) | undefined;
|
|
19
19
|
unmount(): void;
|
|
20
20
|
share(): this;
|
|
21
|
-
root(props?: Record<string, unknown>): {
|
|
21
|
+
root(props?: Record<string, unknown>): {
|
|
22
|
+
'data-active': boolean;
|
|
23
|
+
'data-kind': string;
|
|
24
|
+
};
|
|
22
25
|
header(props?: Record<string, unknown>): {
|
|
23
26
|
id: string;
|
|
24
27
|
role: string;
|