@svelte-atoms/core 1.0.0-alpha.28 → 1.0.0-alpha.29
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 +1 -5
- 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 +401 -401
- package/dist/components/atom/html-atom.svelte +6 -4
- package/dist/components/atom/html-atom.svelte.d.ts +1 -1
- package/dist/components/atom/snippet-renderer.svelte +5 -5
- package/dist/components/button/button.stories.svelte +60 -60
- package/dist/components/calendar/calendar-body.svelte +107 -107
- package/dist/components/calendar/calendar-day.svelte +0 -1
- package/dist/components/calendar/calendar-header.svelte +2 -6
- package/dist/components/calendar/calendar-header.svelte.d.ts +0 -1
- package/dist/components/calendar/calendar-root.svelte +0 -2
- 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 +0 -5
- package/dist/components/calendar/calendar.stories.svelte.d.ts +24 -4
- package/dist/components/datagrid/datagrid-root.svelte +59 -59
- package/dist/components/datagrid/datagrid.css +5 -47
- 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 +34 -9
- package/dist/components/date-picker/date-picker-calendar.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-header.svelte +59 -64
- package/dist/components/date-picker/date-picker-header.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-months.svelte +36 -44
- package/dist/components/date-picker/date-picker-months.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-root.svelte +3 -2
- package/dist/components/date-picker/date-picker-root.svelte.d.ts +2 -15
- package/dist/components/date-picker/date-picker-years.svelte +88 -97
- package/dist/components/date-picker/date-picker-years.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker.stories.svelte +6 -15
- package/dist/components/date-picker/types.d.ts +53 -1
- package/dist/components/dialog/dialog-content.svelte +62 -62
- package/dist/components/element/html-element.svelte +85 -85
- package/dist/components/element/types.d.ts +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/lazy/index.d.ts +1 -0
- package/dist/components/lazy/index.js +1 -0
- package/dist/components/lazy/lazy.stories.svelte +35 -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/menu/menu-list.svelte +40 -39
- package/dist/components/menu/menu-list.svelte.d.ts +1 -0
- package/dist/components/popover/popover-content.svelte +178 -178
- package/dist/components/popover/popover-root.svelte +48 -48
- package/dist/components/popover/popover.stories.svelte +52 -52
- 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 -1
- package/dist/components/qr-code/qr-code.svelte +65 -15
- 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/sidebar/bond.svelte.d.ts +0 -5
- package/dist/components/sidebar/bond.svelte.js +1 -12
- package/dist/components/sidebar/sidebar-content.svelte +39 -39
- package/dist/components/sidebar/sidebar-content.svelte.d.ts +2 -2
- package/dist/components/sidebar/sidebar-root.svelte +41 -68
- package/dist/components/sidebar/sidebar-root.svelte.d.ts +2 -2
- package/dist/components/sidebar/sidebar.stories.svelte +54 -52
- package/dist/components/sidebar/types.d.ts +6 -6
- package/llm/variants.md +1259 -1261
- package/package.json +2 -1
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { Popover as Popover_ } from '.';
|
|
4
|
-
import Root from '../root/root.svelte';
|
|
5
|
-
import { clickoutPopover } from './attachments.svelte';
|
|
6
|
-
import { Button } from '../button';
|
|
7
|
-
|
|
8
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
9
|
-
const { Story } = defineMeta({
|
|
10
|
-
title: 'Atoms/Popover',
|
|
11
|
-
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
12
|
-
|
|
13
|
-
parameters: {
|
|
14
|
-
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
15
|
-
layout: 'fullscreen'
|
|
16
|
-
},
|
|
17
|
-
args: {}
|
|
18
|
-
});
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
<script lang="ts">
|
|
22
|
-
let open = $state(false);
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<Story name="Popover" args={{}}>
|
|
26
|
-
{#snippet children(args)}
|
|
27
|
-
<Root class="overflow-clip p-4">
|
|
28
|
-
<Popover_.Root bind:open offset={0} {...args}>
|
|
29
|
-
{#snippet children({ popover })}
|
|
30
|
-
<!-- {#if dev}
|
|
31
|
-
<RenderScan duration={400} />
|
|
32
|
-
{/if} -->
|
|
33
|
-
|
|
34
|
-
<Popover_.Trigger base={Button} class="items-center gap-4">
|
|
35
|
-
<div>Open Popover</div>
|
|
36
|
-
<Popover_.Indicator />
|
|
37
|
-
</Popover_.Trigger>
|
|
38
|
-
|
|
39
|
-
<Popover_.Content
|
|
40
|
-
{@attach clickoutPopover((ev, atom) => {
|
|
41
|
-
atom.state.close();
|
|
42
|
-
})}
|
|
43
|
-
class="bg-card"
|
|
44
|
-
>
|
|
45
|
-
<div>Hello World !</div>
|
|
46
|
-
<Popover_.Arrow />
|
|
47
|
-
</Popover_.Content>
|
|
48
|
-
{/snippet}
|
|
49
|
-
</Popover_.Root>
|
|
50
|
-
</Root>
|
|
51
|
-
{/snippet}
|
|
52
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Popover as Popover_ } from '.';
|
|
4
|
+
import Root from '../root/root.svelte';
|
|
5
|
+
import { clickoutPopover } from './attachments.svelte';
|
|
6
|
+
import { Button } from '../button';
|
|
7
|
+
|
|
8
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
9
|
+
const { Story } = defineMeta({
|
|
10
|
+
title: 'Atoms/Popover',
|
|
11
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
12
|
+
|
|
13
|
+
parameters: {
|
|
14
|
+
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
15
|
+
layout: 'fullscreen'
|
|
16
|
+
},
|
|
17
|
+
args: {}
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
let open = $state(false);
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<Story name="Popover" args={{}}>
|
|
26
|
+
{#snippet children(args)}
|
|
27
|
+
<Root class="overflow-clip p-4">
|
|
28
|
+
<Popover_.Root bind:open offset={0} {...args}>
|
|
29
|
+
{#snippet children({ popover })}
|
|
30
|
+
<!-- {#if dev}
|
|
31
|
+
<RenderScan duration={400} />
|
|
32
|
+
{/if} -->
|
|
33
|
+
|
|
34
|
+
<Popover_.Trigger base={Button} class="items-center gap-4">
|
|
35
|
+
<div>Open Popover</div>
|
|
36
|
+
<Popover_.Indicator />
|
|
37
|
+
</Popover_.Trigger>
|
|
38
|
+
|
|
39
|
+
<Popover_.Content
|
|
40
|
+
{@attach clickoutPopover((ev, atom) => {
|
|
41
|
+
atom.state.close();
|
|
42
|
+
})}
|
|
43
|
+
class="bg-card"
|
|
44
|
+
>
|
|
45
|
+
<div>Hello World !</div>
|
|
46
|
+
<Popover_.Arrow />
|
|
47
|
+
</Popover_.Content>
|
|
48
|
+
{/snippet}
|
|
49
|
+
</Popover_.Root>
|
|
50
|
+
</Root>
|
|
51
|
+
{/snippet}
|
|
52
|
+
</Story>
|
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
<Root>
|
|
17
17
|
{#snippet children({})}
|
|
18
18
|
<div class="flex h-full w-full items-center justify-center">
|
|
19
|
-
<QrCodeComponent
|
|
19
|
+
<QrCodeComponent
|
|
20
|
+
class="text-primary-foreground bg-primary size-64 rounded-2xl p-1"
|
|
21
|
+
value="Hello World 123"
|
|
22
|
+
/>
|
|
20
23
|
</div>
|
|
21
24
|
{/snippet}
|
|
22
25
|
</Root>
|
|
@@ -1,25 +1,75 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
2
|
+
import type { QRCodeBrowser } from '@qrcode-js/browser';
|
|
3
|
+
import { HtmlAtom } from '../atom';
|
|
4
|
+
import type { QRCodeProps } from './types';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
type Render = typeof QRCodeBrowser;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
let {
|
|
9
|
+
class: klass = '',
|
|
10
|
+
value = '',
|
|
11
|
+
finder = {
|
|
12
|
+
round: 0.5
|
|
13
|
+
},
|
|
14
|
+
dots = {
|
|
15
|
+
scale: 0.75,
|
|
16
|
+
round: 1
|
|
17
|
+
},
|
|
18
|
+
drawFunction = 'telegram',
|
|
19
|
+
gradient = undefined,
|
|
20
|
+
logo = undefined,
|
|
21
|
+
margin = undefined,
|
|
22
|
+
qr = undefined,
|
|
23
|
+
...restProps
|
|
24
|
+
}: QRCodeProps = $props();
|
|
9
25
|
|
|
26
|
+
let canvasElement: HTMLCanvasElement | undefined = $state();
|
|
27
|
+
|
|
28
|
+
let clientWidth = $state(0);
|
|
29
|
+
let isReady = $state(false);
|
|
10
30
|
let render: Render | undefined = $state();
|
|
31
|
+
let computedColor = $state('black');
|
|
32
|
+
|
|
33
|
+
import('@qrcode-js/browser').then((result) => {
|
|
34
|
+
render = result.QRCodeBrowser;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
$effect(() => {
|
|
38
|
+
if (!canvasElement) return;
|
|
39
|
+
if (!render) return;
|
|
40
|
+
if (!isReady) render;
|
|
41
|
+
|
|
42
|
+
// Get the computed color from the canvas element
|
|
43
|
+
computedColor = getComputedStyle(canvasElement).color;
|
|
44
|
+
|
|
45
|
+
const qrcode = render(canvasElement);
|
|
11
46
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
47
|
+
qrcode.setOptions({
|
|
48
|
+
text: value,
|
|
49
|
+
size: clientWidth,
|
|
50
|
+
color: computedColor,
|
|
51
|
+
dots,
|
|
52
|
+
finder,
|
|
53
|
+
drawFunction,
|
|
54
|
+
...(gradient && { gradient }),
|
|
55
|
+
...(margin && { margin }),
|
|
56
|
+
...(logo && { logo }),
|
|
57
|
+
...(qr && { qr })
|
|
58
|
+
});
|
|
15
59
|
|
|
16
|
-
|
|
17
|
-
render = result.renderSVG;
|
|
60
|
+
qrcode.draw();
|
|
18
61
|
});
|
|
19
62
|
</script>
|
|
20
63
|
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
64
|
+
<HtmlAtom class={[klass]} {...restProps}>
|
|
65
|
+
<div bind:clientWidth class="size-full">
|
|
66
|
+
<canvas
|
|
67
|
+
{@attach (node) => {
|
|
68
|
+
canvasElement = node;
|
|
69
|
+
isReady = true;
|
|
70
|
+
}}
|
|
71
|
+
width={clientWidth}
|
|
72
|
+
height={clientWidth}
|
|
73
|
+
></canvas>
|
|
74
|
+
</div>
|
|
75
|
+
</HtmlAtom>
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
value?: string;
|
|
4
|
-
}, {}, "">;
|
|
1
|
+
import type { QRCodeProps } from './types';
|
|
2
|
+
declare const QrCode: import("svelte").Component<QRCodeProps, {}, "">;
|
|
5
3
|
type QrCode = ReturnType<typeof QrCode>;
|
|
6
4
|
export default QrCode;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { QRCodeBrowser } from '@qrcode-js/browser';
|
|
2
|
+
type QRCodeOptions = Parameters<ReturnType<typeof QRCodeBrowser>['setOptions']>[0];
|
|
3
|
+
export type QRCodeProps = {
|
|
4
|
+
class?: string;
|
|
5
|
+
value: string;
|
|
6
|
+
finder?: QRCodeOptions['finder'];
|
|
7
|
+
dots?: QRCodeOptions['dots'];
|
|
8
|
+
drawFunction?: QRCodeOptions['drawFunction'];
|
|
9
|
+
gradient?: QRCodeOptions['gradient'];
|
|
10
|
+
logo?: QRCodeOptions['logo'];
|
|
11
|
+
margin?: QRCodeOptions['margin'];
|
|
12
|
+
qr?: QRCodeOptions['qr'];
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,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 {
|
|
5
|
-
|
|
6
|
-
const bond = SidebarBond.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
|
-
}:
|
|
19
|
-
|
|
20
|
-
const contentProps = $derived({
|
|
21
|
-
...bond?.content(),
|
|
22
|
-
...restProps
|
|
23
|
-
});
|
|
24
|
-
</script>
|
|
25
|
-
|
|
26
|
-
<HtmlAtom
|
|
27
|
-
{bond}
|
|
28
|
-
preset="sidebar.content"
|
|
29
|
-
class={['bg-card border-border', '$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?.({ sidebar: bond })}
|
|
39
|
-
</HtmlAtom>
|
|
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
|
+
|
|
6
|
+
const bond = SidebarBond.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
|
+
}: SidebarRootProps<E, B> = $props();
|
|
19
|
+
|
|
20
|
+
const contentProps = $derived({
|
|
21
|
+
...bond?.content(),
|
|
22
|
+
...restProps
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<HtmlAtom
|
|
27
|
+
{bond}
|
|
28
|
+
preset="sidebar.content"
|
|
29
|
+
class={['bg-card border-border', '$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?.({ sidebar: bond })}
|
|
39
|
+
</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,41 @@
|
|
|
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
|
-
|
|
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
|
+
[
|
|
16
|
+
defineProperty(
|
|
17
|
+
'open',
|
|
18
|
+
() => open,
|
|
19
|
+
(v) => {
|
|
20
|
+
open = v;
|
|
21
|
+
}
|
|
22
|
+
),
|
|
23
|
+
defineProperty('disabled', () => disabled)
|
|
24
|
+
]
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const bond = factory(bondProps).share();
|
|
28
|
+
|
|
29
|
+
function _factory(props: typeof bondProps) {
|
|
30
|
+
const bondState = new SidebarBondState(() => props);
|
|
31
|
+
const bond = new SidebarBond(bondState);
|
|
32
|
+
|
|
33
|
+
return bond;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function getBond() {
|
|
37
|
+
return bond;
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
{@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,54 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { cubicOut } from 'svelte/easing';
|
|
3
|
-
import gsap from 'gsap';
|
|
4
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
5
|
-
import { Sidebar as Sidebar_ } from '.';
|
|
6
|
-
import Root from '../root/root.svelte';
|
|
7
|
-
import { on } from '../../attachments';
|
|
8
|
-
import { SidebarBond } from './bond.svelte';
|
|
9
|
-
|
|
10
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
11
|
-
const { Story } = defineMeta({
|
|
12
|
-
title: 'Atoms/Sidebar',
|
|
13
|
-
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
14
|
-
|
|
15
|
-
parameters: {
|
|
16
|
-
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
17
|
-
layout: 'fullscreen'
|
|
18
|
-
},
|
|
19
|
-
args: {}
|
|
20
|
-
});
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<script lang="ts">
|
|
24
|
-
let isOpen = $state(false);
|
|
25
|
-
$inspect(isOpen);
|
|
26
|
-
</script>
|
|
27
|
-
|
|
28
|
-
<Story name="Sidebar" args={{}}>
|
|
29
|
-
<Root class="">
|
|
30
|
-
<Sidebar_.Root class="" bind:open={isOpen}>
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
</
|
|
1
|
+
<script module>
|
|
2
|
+
import { cubicOut } from 'svelte/easing';
|
|
3
|
+
import gsap from 'gsap';
|
|
4
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
5
|
+
import { Sidebar as Sidebar_ } from '.';
|
|
6
|
+
import Root from '../root/root.svelte';
|
|
7
|
+
import { on } from '../../attachments';
|
|
8
|
+
import { SidebarBond } from './bond.svelte';
|
|
9
|
+
|
|
10
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
11
|
+
const { Story } = defineMeta({
|
|
12
|
+
title: 'Atoms/Sidebar',
|
|
13
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
14
|
+
|
|
15
|
+
parameters: {
|
|
16
|
+
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
17
|
+
layout: 'fullscreen'
|
|
18
|
+
},
|
|
19
|
+
args: {}
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<script lang="ts">
|
|
24
|
+
let isOpen = $state(false);
|
|
25
|
+
$inspect(isOpen);
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<Story name="Sidebar" args={{}}>
|
|
29
|
+
<Root class="">
|
|
30
|
+
<Sidebar_.Root class="" bind:open={isOpen}>
|
|
31
|
+
<div class="flex size-full">
|
|
32
|
+
<Sidebar_.Content
|
|
33
|
+
class="flex flex-col border-r px-6 py-10 whitespace-nowrap"
|
|
34
|
+
initial={(node) => gsap.set(node, { width: isOpen ? 240 : 96 })}
|
|
35
|
+
animate={(node) =>
|
|
36
|
+
gsap.to(node, { width: isOpen ? 240 : 96, duration: 0.2, ease: cubicOut })}
|
|
37
|
+
>
|
|
38
|
+
<div>
|
|
39
|
+
<button
|
|
40
|
+
{@attach (node) => {
|
|
41
|
+
const bond = SidebarBond.get();
|
|
42
|
+
return on('click', (ev) => {
|
|
43
|
+
bond?.state.toggle?.();
|
|
44
|
+
})(node);
|
|
45
|
+
}}>Open</button
|
|
46
|
+
>
|
|
47
|
+
</div>
|
|
48
|
+
</Sidebar_.Content>
|
|
49
|
+
|
|
50
|
+
<main class="bg-foreground/2 flex-1 p-8">Hello World!</main>
|
|
51
|
+
</div>
|
|
52
|
+
</Sidebar_.Root>
|
|
53
|
+
</Root>
|
|
54
|
+
</Story>
|
|
@@ -6,25 +6,25 @@ 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
23
|
factory?: Factory<SidebarBond>;
|
|
24
24
|
}
|
|
25
|
-
export interface
|
|
25
|
+
export interface SidebarContentProps<E extends keyof HTMLElementTagNameMap, B extends Base = Base> extends Override<HtmlAtomProps<E, B>, {
|
|
26
26
|
children?: Snippet<[{
|
|
27
27
|
sidebar?: SidebarBond<any>;
|
|
28
28
|
}]>;
|
|
29
|
-
}>,
|
|
29
|
+
}>, SidebarContentExtendProps {
|
|
30
30
|
}
|