@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,38 +1,35 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { Input as AInput } from '.';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
<
|
|
27
|
-
<AInput.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
</div>
|
|
37
|
-
</Root>
|
|
38
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Input as AInput } from '.';
|
|
4
|
+
import { Label } from '../label';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
title: 'Atoms/Input',
|
|
9
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
10
|
+
|
|
11
|
+
parameters: {
|
|
12
|
+
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
13
|
+
layout: 'fullscreen'
|
|
14
|
+
},
|
|
15
|
+
args: {}
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<Story name="Input" args={{}}>
|
|
23
|
+
<div class="flex flex-col">
|
|
24
|
+
<Label for="price-input">Price</Label>
|
|
25
|
+
<AInput.Root>
|
|
26
|
+
<AInput.Icon class="text-foreground box-content px-0">$</AInput.Icon>
|
|
27
|
+
<AInput.Control id="price-input" class="border-border box-content border-x px-2 py-2">
|
|
28
|
+
<!-- -->
|
|
29
|
+
</AInput.Control>
|
|
30
|
+
<AInput.Icon class="text-foreground box-content px-2">.00</AInput.Icon>
|
|
31
|
+
|
|
32
|
+
<AInput.Placeholder class="text-foreground/20 pl-2">Hello World</AInput.Placeholder>
|
|
33
|
+
</AInput.Root>
|
|
34
|
+
</div>
|
|
35
|
+
</Story>
|
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { default as LabelCmp } from './label.svelte';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
</
|
|
15
|
-
|
|
16
|
-
<Story name="Label">
|
|
17
|
-
{#snippet children(args)}
|
|
18
|
-
<Root>
|
|
19
|
-
{#snippet children({})}
|
|
20
|
-
<div class="flex h-full w-full items-center justify-center">
|
|
21
|
-
<LabelCmp>Hello World</LabelCmp>
|
|
22
|
-
</div>
|
|
23
|
-
{/snippet}
|
|
24
|
-
</Root>
|
|
25
|
-
{/snippet}
|
|
26
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { default as LabelCmp } from './label.svelte';
|
|
4
|
+
|
|
5
|
+
const { Story } = defineMeta({
|
|
6
|
+
title: 'ATOMS/Label'
|
|
7
|
+
});
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Story name="Label">
|
|
14
|
+
<LabelCmp>Hello World</LabelCmp>
|
|
15
|
+
</Story>
|
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
export default Label;
|
|
2
|
-
type Label = {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type Label = SvelteComponent<{
|
|
3
|
+
[x: string]: never;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string;
|
|
5
8
|
};
|
|
6
|
-
declare const Label:
|
|
9
|
+
declare const Label: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Lazy } from './lazy.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Lazy } from './lazy.svelte';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
|
|
4
|
+
const { Story } = defineMeta({
|
|
5
|
+
title: 'Atoms/Lazy'
|
|
6
|
+
});
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import Lazy from './lazy.svelte';
|
|
11
|
+
import { delay } from 'es-toolkit';
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Story name="Lazy">
|
|
15
|
+
<Lazy
|
|
16
|
+
promise={import('../button/button.svelte').then(async res=> {
|
|
17
|
+
await delay(1000 * 2);
|
|
18
|
+
|
|
19
|
+
return res.default;
|
|
20
|
+
})}
|
|
21
|
+
>
|
|
22
|
+
Hello World
|
|
23
|
+
|
|
24
|
+
{#snippet loading()}
|
|
25
|
+
<span>Loading...</span>
|
|
26
|
+
{/snippet}
|
|
27
|
+
</Lazy>
|
|
28
|
+
</Story>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Lazy from './lazy.svelte';
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const Lazy: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type Lazy = InstanceType<typeof Lazy>;
|
|
19
|
+
export default Lazy;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import type { LazyProps } from './types';
|
|
4
|
+
|
|
5
|
+
let { promise, children, loading, error, ...restProps }: LazyProps = $props();
|
|
6
|
+
|
|
7
|
+
let Lazy: Component | null = $state(null);
|
|
8
|
+
|
|
9
|
+
let err = $state();
|
|
10
|
+
|
|
11
|
+
promise
|
|
12
|
+
.then((c) => {
|
|
13
|
+
Lazy = c;
|
|
14
|
+
})
|
|
15
|
+
.catch((r) => {
|
|
16
|
+
err = r;
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<Lazy {...restProps}>
|
|
21
|
+
{@render children?.()}
|
|
22
|
+
</Lazy>
|
|
23
|
+
|
|
24
|
+
{#if err && error}
|
|
25
|
+
{@render error?.()}
|
|
26
|
+
{:else if !Lazy}
|
|
27
|
+
{@render loading?.()}
|
|
28
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Component, Snippet } from 'svelte';
|
|
2
|
+
import type { HtmlAtomProps } from '../atom';
|
|
3
|
+
export interface LazyExtendProps {
|
|
4
|
+
}
|
|
5
|
+
export interface LazyProps extends HtmlAtomProps<'button'>, LazyExtendProps {
|
|
6
|
+
promise: Promise<Component>;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
error?: Snippet;
|
|
9
|
+
loading?: Snippet;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
</
|
|
15
|
-
|
|
16
|
-
<Story name="Link">
|
|
17
|
-
{#snippet children(args)}
|
|
18
|
-
<Root>
|
|
19
|
-
{#snippet children({})}
|
|
20
|
-
<div class="flex h-full w-full items-center justify-center">
|
|
21
|
-
<LinkComponent>Hello World</LinkComponent>
|
|
22
|
-
</div>
|
|
23
|
-
{/snippet}
|
|
24
|
-
</Root>
|
|
25
|
-
{/snippet}
|
|
26
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import LinkComponent from './link.svelte';
|
|
4
|
+
|
|
5
|
+
const { Story } = defineMeta({
|
|
6
|
+
title: 'ATOMS/Link'
|
|
7
|
+
});
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Story name="Link">
|
|
14
|
+
<LinkComponent>Hello World</LinkComponent>
|
|
15
|
+
</Story>
|
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
export default Link;
|
|
2
|
-
type Link = {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type Link = SvelteComponent<{
|
|
3
|
+
[x: string]: never;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string;
|
|
5
8
|
};
|
|
6
|
-
declare const Link:
|
|
9
|
+
declare const Link: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
class: klass = '',
|
|
11
11
|
as = 'ul' as T,
|
|
12
12
|
base = List.Root as B,
|
|
13
|
+
preset = 'menu.list',
|
|
13
14
|
children = undefined,
|
|
14
15
|
onmount = undefined,
|
|
15
16
|
ondestroy = undefined,
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
{as}
|
|
26
27
|
{base}
|
|
27
28
|
{bond}
|
|
28
|
-
preset
|
|
29
|
+
{preset}
|
|
29
30
|
class={['bg-background border-border overflow-hidden p-0', '$preset', klass]}
|
|
30
31
|
onmount={onmount?.bind(bond.state)}
|
|
31
32
|
ondestroy={ondestroy?.bind(bond.state)}
|
|
@@ -1,36 +1,33 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { Menu as AMenu } from '.';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
<AMenu.
|
|
27
|
-
<AMenu.
|
|
28
|
-
<AMenu.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
</AMenu.Root>
|
|
35
|
-
</Root>
|
|
36
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Menu as AMenu } from '.';
|
|
4
|
+
import { Button } from '../button';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
title: 'Atoms/Menu',
|
|
9
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
10
|
+
|
|
11
|
+
parameters: {
|
|
12
|
+
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
13
|
+
layout: 'fullscreen'
|
|
14
|
+
},
|
|
15
|
+
args: {}
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
let open = $state(false);
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Story name="Menu" args={{}}>
|
|
24
|
+
<AMenu.Root bind:open offset={4}>
|
|
25
|
+
<AMenu.Trigger base={Button}>Select a language</AMenu.Trigger>
|
|
26
|
+
<AMenu.List>
|
|
27
|
+
<AMenu.Item>Arabic</AMenu.Item>
|
|
28
|
+
<AMenu.Item>English</AMenu.Item>
|
|
29
|
+
<AMenu.Item>Spanish</AMenu.Item>
|
|
30
|
+
<AMenu.Item>Italian</AMenu.Item>
|
|
31
|
+
</AMenu.List>
|
|
32
|
+
</AMenu.Root>
|
|
33
|
+
</Story>
|
|
@@ -52,7 +52,7 @@ export class PopoverBond extends Bond {
|
|
|
52
52
|
const position = untrack(() => this.#position);
|
|
53
53
|
if (!position) {
|
|
54
54
|
const init = async () => {
|
|
55
|
-
popover(this)(
|
|
55
|
+
popover(this)({
|
|
56
56
|
...props,
|
|
57
57
|
onchange: (node, position) => {
|
|
58
58
|
this.#position = position;
|
|
@@ -96,7 +96,7 @@ export class PopoverBond extends Bond {
|
|
|
96
96
|
}
|
|
97
97
|
if (!this.state.isOpen)
|
|
98
98
|
return;
|
|
99
|
-
return popover(this)(
|
|
99
|
+
return popover(this)({
|
|
100
100
|
...props,
|
|
101
101
|
onchange: (node, position) => {
|
|
102
102
|
this.#position = position;
|
|
@@ -160,38 +160,44 @@ export class PopoverState extends BondState {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
function popover(bond) {
|
|
163
|
-
return (
|
|
163
|
+
return (props, updater) => {
|
|
164
164
|
const { offset: ofs, placements, placement } = bond.state.props;
|
|
165
|
-
|
|
165
|
+
// Guard: ensure required elements exist
|
|
166
|
+
if (!bond.elements.content || !bond.elements.trigger) {
|
|
166
167
|
return;
|
|
167
168
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const middleware = [
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
const { content, trigger, arrow: arrowElement } = bond.elements;
|
|
170
|
+
// Set minimum width to match trigger
|
|
171
|
+
content.style.minWidth = `${trigger.clientWidth}px`;
|
|
172
|
+
// Build middleware stack
|
|
173
|
+
const middleware = [
|
|
174
|
+
offset(ofs),
|
|
175
|
+
flip({
|
|
176
|
+
fallbackPlacements: placements,
|
|
177
|
+
padding: 4
|
|
178
|
+
})
|
|
179
|
+
];
|
|
180
|
+
// Add arrow middleware if element exists
|
|
181
|
+
if (arrowElement) {
|
|
182
|
+
middleware.push(arrow({ element: arrowElement }));
|
|
175
183
|
}
|
|
184
|
+
// Debounce position change callback
|
|
185
|
+
const onchangeCallback = props.onchange;
|
|
176
186
|
const onchangeDebounced = debounce((node, position) => {
|
|
177
|
-
|
|
178
|
-
}, 1000 / 60
|
|
187
|
+
onchangeCallback?.(node, position);
|
|
188
|
+
}, 1000 / 60 // ~16ms for 60fps
|
|
189
|
+
);
|
|
190
|
+
// Compute position and notify listeners
|
|
179
191
|
const compute = async () => {
|
|
180
|
-
const position = await computePosition(
|
|
181
|
-
placement,
|
|
182
|
-
middleware
|
|
183
|
-
offset(ofs),
|
|
184
|
-
flip({
|
|
185
|
-
fallbackPlacements: placements,
|
|
186
|
-
padding: 4
|
|
187
|
-
}),
|
|
188
|
-
...middleware
|
|
189
|
-
]
|
|
192
|
+
const position = await computePosition(trigger, content, {
|
|
193
|
+
placement: placement ?? 'bottom',
|
|
194
|
+
middleware
|
|
190
195
|
});
|
|
191
|
-
onchangeDebounced
|
|
196
|
+
onchangeDebounced(content, position);
|
|
192
197
|
};
|
|
198
|
+
// Use auto-update if provided, otherwise compute once
|
|
193
199
|
if (updater) {
|
|
194
|
-
return updater(
|
|
200
|
+
return updater(trigger, content, compute, {});
|
|
195
201
|
}
|
|
196
202
|
compute();
|
|
197
203
|
};
|