@svelte-atoms/core 1.0.0-alpha.29 → 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.
Files changed (92) hide show
  1. package/README.md +852 -852
  2. package/dist/attachments/clickout.svelte.d.ts +1 -1
  3. package/dist/attachments/clickout.svelte.js +2 -2
  4. package/dist/components/accordion/accordion-root.svelte +61 -61
  5. package/dist/components/accordion/accordion-root.svelte.d.ts +1 -1
  6. package/dist/components/accordion/accordion.stories.svelte +145 -134
  7. package/dist/components/alert/alert.stories.svelte +400 -401
  8. package/dist/components/atom/html-atom.svelte +71 -17
  9. package/dist/components/avatar/avatar.stories.svelte +22 -27
  10. package/dist/components/badge/badge.stories.svelte +12 -17
  11. package/dist/components/badge/badge.svelte +19 -19
  12. package/dist/components/breadcrumb/breadcrumb.stories.svelte +16 -21
  13. package/dist/components/button/button.stories.svelte +27 -60
  14. package/dist/components/calendar/calendar-day.svelte +96 -96
  15. package/dist/components/calendar/calendar-header.svelte +29 -29
  16. package/dist/components/calendar/calendar-root.svelte +206 -206
  17. package/dist/components/calendar/calendar.stories.svelte +10 -15
  18. package/dist/components/card/card-body.svelte +39 -39
  19. package/dist/components/card/card-footer.svelte +41 -41
  20. package/dist/components/card/card-root.svelte +91 -91
  21. package/dist/components/card/card.stories.svelte +133 -145
  22. package/dist/components/checkbox/checkbox.stories.svelte +22 -27
  23. package/dist/components/checkbox/checkbox.svelte +155 -157
  24. package/dist/components/collapsible/collapsible.stories.svelte +172 -173
  25. package/dist/components/combobox/combobox-root.svelte +65 -65
  26. package/dist/components/combobox/compobox.stories.svelte +51 -54
  27. package/dist/components/container/container.stories.svelte +20 -23
  28. package/dist/components/datagrid/datagrid-root.svelte +59 -59
  29. package/dist/components/datagrid/datagrid.css +5 -5
  30. package/dist/components/datagrid/datagrid.stories.svelte +72 -75
  31. package/dist/components/date-picker/date-picker-calendar.svelte +67 -67
  32. package/dist/components/date-picker/date-picker-header.svelte +100 -100
  33. package/dist/components/date-picker/date-picker-months.svelte +142 -142
  34. package/dist/components/date-picker/date-picker-root.svelte +1 -1
  35. package/dist/components/date-picker/date-picker-years.svelte +205 -205
  36. package/dist/components/date-picker/date-picker.stories.svelte +11 -18
  37. package/dist/components/dialog/dialog-content.svelte +62 -62
  38. package/dist/components/dialog/dialog.stories.svelte +64 -67
  39. package/dist/components/drawer/attachments.svelte.js +8 -9
  40. package/dist/components/drawer/drawer-content.svelte +57 -42
  41. package/dist/components/drawer/drawer.stories.svelte +212 -224
  42. package/dist/components/dropdown/dropdown-root.svelte +59 -59
  43. package/dist/components/dropdown/dropdown.stories.svelte +80 -83
  44. package/dist/components/form/form.stories.svelte +96 -99
  45. package/dist/components/image/image.stories.svelte +20 -23
  46. package/dist/components/input/input.stories.svelte +35 -38
  47. package/dist/components/label/label.stories.svelte +15 -26
  48. package/dist/components/label/label.stories.svelte.d.ts +24 -4
  49. package/dist/components/lazy/lazy.stories.svelte +9 -16
  50. package/dist/components/lazy/lazy.svelte +28 -28
  51. package/dist/components/link/link.stories.svelte +15 -26
  52. package/dist/components/link/link.stories.svelte.d.ts +24 -4
  53. package/dist/components/menu/menu-list.svelte +40 -40
  54. package/dist/components/menu/menu.stories.svelte +33 -36
  55. package/dist/components/popover/bond.svelte.js +31 -25
  56. package/dist/components/popover/popover-arrow.svelte +111 -111
  57. package/dist/components/popover/popover-content.svelte +175 -178
  58. package/dist/components/popover/popover-indicator.svelte +44 -43
  59. package/dist/components/popover/popover-root.svelte +48 -48
  60. package/dist/components/popover/popover.stories.svelte +49 -52
  61. package/dist/components/qr-code/qr-code.stories.svelte +4 -13
  62. package/dist/components/qr-code/qr-code.svelte +75 -75
  63. package/dist/components/radio/radio-group.stories.svelte +41 -50
  64. package/dist/components/radio/radio.stories.svelte +17 -26
  65. package/dist/components/radio/radio.svelte +109 -109
  66. package/dist/components/root/root.svelte +121 -121
  67. package/dist/components/root/root.svelte.d.ts +1 -1
  68. package/dist/components/scrollable/scrollable.stories.svelte +116 -126
  69. package/dist/components/sidebar/sidebar-content.svelte +13 -2
  70. package/dist/components/sidebar/sidebar-root.svelte +10 -12
  71. package/dist/components/sidebar/sidebar.stories.svelte +8 -19
  72. package/dist/components/sidebar/types.d.ts +1 -0
  73. package/dist/components/tabs/tab/bond.svelte.d.ts +4 -1
  74. package/dist/components/tabs/tab/bond.svelte.js +4 -1
  75. package/dist/components/tabs/tabs.stories.svelte +56 -59
  76. package/dist/components/tooltip/tooltip-trigger.svelte +39 -37
  77. package/dist/components/tooltip/tooltip.stories.svelte +32 -35
  78. package/dist/components/tree/tree.stories.svelte +142 -134
  79. package/dist/context/preset.svelte.d.ts +3 -3
  80. package/dist/utils/function.d.ts +2 -0
  81. package/dist/utils/function.js +6 -0
  82. package/package.json +6 -9
  83. package/dist/actions/animation.svelte.d.ts +0 -6
  84. package/dist/actions/animation.svelte.js +0 -14
  85. package/dist/actions/clickout.svelte.d.ts +0 -2
  86. package/dist/actions/clickout.svelte.js +0 -15
  87. package/dist/actions/popover.svelte.d.ts +0 -19
  88. package/dist/actions/popover.svelte.js +0 -81
  89. package/dist/actions/portal.svelte.d.ts +0 -8
  90. package/dist/actions/portal.svelte.js +0 -32
  91. package/dist/attachments/gsap.svelte.d.ts +0 -2
  92. package/dist/attachments/gsap.svelte.js +0 -26
@@ -1,121 +1,121 @@
1
- <script module lang="ts">
2
- export type RootPortals = 'root.l0' | 'root.l1' | 'root.l2' | 'root.l3';
3
- </script>
4
-
5
- <script lang="ts">
6
- import { cn, defineState, defineProperty } from '../../utils';
7
- import { RootBond, RootBondState, type RootStateProps } from './bond.svelte';
8
- import { Portal, ActivePortal, Portals } from '../portal';
9
- import { Stack } from '../stack';
10
- import { HtmlAtom } from '../atom';
11
- import { HtmlElement, MathmlElement, SvgElement } from '../element';
12
-
13
- let {
14
- class: klass = '',
15
- base = undefined,
16
- children = undefined,
17
- portals = undefined,
18
- ...restProps
19
- } = $props();
20
-
21
- let html: typeof HtmlElement | undefined = HtmlElement;
22
- let svg: typeof SvgElement | undefined = undefined;
23
- let mathml: typeof MathmlElement | undefined = undefined;
24
-
25
- type Renderers = {
26
- html?: typeof HtmlElement;
27
- svg?: typeof SvgElement;
28
- mathml?: typeof MathmlElement;
29
- };
30
-
31
- const renderers = defineState<Renderers>([
32
- defineProperty('html', () => {
33
- if (!html) {
34
- import('../element/html-element.svelte').then((mod) => {
35
- html = mod.default;
36
- });
37
- }
38
-
39
- return html;
40
- }),
41
- defineProperty('svg', () => {
42
- if (!svg) {
43
- import('../element/svg-element.svelte').then((mod) => {
44
- svg = mod.default;
45
- });
46
- }
47
-
48
- return svg;
49
- }),
50
- defineProperty('mathml', () => {
51
- if (!mathml) {
52
- import('../element/mathml-element.svelte').then((mod) => {
53
- mathml = mod.default;
54
- });
55
- }
56
-
57
- return mathml;
58
- })
59
- ]);
60
-
61
- const bondProps = defineState<RootStateProps>([defineProperty('renderers', () => renderers)]);
62
-
63
- const bondState = new RootBondState(() => bondProps);
64
- const bond = new RootBond(bondState).share();
65
- </script>
66
-
67
- <Portals id="root">
68
- <HtmlAtom
69
- {@attach (node) => {
70
- bond.rootElement = node;
71
- }}
72
- {base}
73
- preset="root"
74
- class={cn(
75
- 'atom-root bg-background text-foreground relative flex w-full flex-1 flex-col items-start font-sans',
76
- '$preset',
77
- klass
78
- )}
79
- {...restProps}
80
- >
81
- {#if portals}
82
- {@render portals?.()}
83
- {:else}
84
- <Portal.Outer
85
- base={Stack.Item}
86
- id="root.l0"
87
- class="pointer-events-none absolute inset-0 z-10 overflow-hidden"
88
- >
89
- <Portal.Inner />
90
- </Portal.Outer>
91
-
92
- <Portal.Outer
93
- base={Stack.Item}
94
- id="root.l1"
95
- class="pointer-events-none absolute inset-0 z-10 overflow-hidden"
96
- >
97
- <Portal.Inner />
98
- </Portal.Outer>
99
-
100
- <Portal.Outer
101
- base={Stack.Item}
102
- id="root.l2"
103
- class="pointer-events-none absolute inset-0 z-10 overflow-hidden"
104
- >
105
- <Portal.Inner />
106
- </Portal.Outer>
107
-
108
- <Portal.Outer
109
- base={Stack.Item}
110
- id="root.l3"
111
- class="pointer-events-none absolute inset-0 z-10 overflow-hidden"
112
- >
113
- <Portal.Inner />
114
- </Portal.Outer>
115
- {/if}
116
-
117
- <ActivePortal portal="root.l0">
118
- {@render children?.()}
119
- </ActivePortal>
120
- </HtmlAtom>
121
- </Portals>
1
+ <script module lang="ts">
2
+ export type RootPortals = 'root.l0' | 'root.l1' | 'root.l2' | 'root.l3';
3
+ </script>
4
+
5
+ <script lang="ts">
6
+ import { cn, defineState, defineProperty } from '../../utils';
7
+ import { RootBond, RootBondState, type RootStateProps } from './bond.svelte';
8
+ import { Portal, ActivePortal, Portals } from '../portal';
9
+ import { Stack } from '../stack';
10
+ import { HtmlAtom } from '../atom';
11
+ import { HtmlElement, MathmlElement, SvgElement } from '../element';
12
+
13
+ let {
14
+ class: klass = '',
15
+ base,
16
+ children = undefined,
17
+ portals = undefined,
18
+ ...restProps
19
+ } = $props();
20
+
21
+ let html: typeof HtmlElement | undefined = HtmlElement;
22
+ let svg: typeof SvgElement | undefined = undefined;
23
+ let mathml: typeof MathmlElement | undefined = undefined;
24
+
25
+ type Renderers = {
26
+ html?: typeof HtmlElement;
27
+ svg?: typeof SvgElement;
28
+ mathml?: typeof MathmlElement;
29
+ };
30
+
31
+ const renderers = defineState<Renderers>([
32
+ defineProperty('html', () => {
33
+ if (!html) {
34
+ import('../element/html-element.svelte').then((mod) => {
35
+ html = mod.default;
36
+ });
37
+ }
38
+
39
+ return html;
40
+ }),
41
+ defineProperty('svg', () => {
42
+ if (!svg) {
43
+ import('../element/svg-element.svelte').then((mod) => {
44
+ svg = mod.default;
45
+ });
46
+ }
47
+
48
+ return svg;
49
+ }),
50
+ defineProperty('mathml', () => {
51
+ if (!mathml) {
52
+ import('../element/mathml-element.svelte').then((mod) => {
53
+ mathml = mod.default;
54
+ });
55
+ }
56
+
57
+ return mathml;
58
+ })
59
+ ]);
60
+
61
+ const bondProps = defineState<RootStateProps>([defineProperty('renderers', () => renderers)]);
62
+
63
+ const bondState = new RootBondState(() => bondProps);
64
+ const bond = new RootBond(bondState).share();
65
+ </script>
66
+
67
+ <Portals id="root">
68
+ <Stack.Root
69
+ {@attach (node) => {
70
+ bond.rootElement = node;
71
+ }}
72
+ {base}
73
+ preset="root"
74
+ class={cn(
75
+ 'atom-root bg-background text-foreground relative flex w-full flex-1 flex-col items-start justify-stretch font-sans',
76
+ '$preset',
77
+ klass
78
+ )}
79
+ {...restProps}
80
+ >
81
+ {#if portals}
82
+ {@render portals?.()}
83
+ {:else}
84
+ <Portal.Outer
85
+ base={Stack.Item}
86
+ id="root.l0"
87
+ class="pointer-events-none absolute inset-0 z-10 overflow-hidden"
88
+ >
89
+ <Portal.Inner />
90
+ </Portal.Outer>
91
+
92
+ <Portal.Outer
93
+ base={Stack.Item}
94
+ id="root.l1"
95
+ class="pointer-events-none absolute inset-0 z-10 overflow-hidden"
96
+ >
97
+ <Portal.Inner />
98
+ </Portal.Outer>
99
+
100
+ <Portal.Outer
101
+ base={Stack.Item}
102
+ id="root.l2"
103
+ class="pointer-events-none absolute inset-0 z-10 overflow-hidden"
104
+ >
105
+ <Portal.Inner />
106
+ </Portal.Outer>
107
+
108
+ <Portal.Outer
109
+ base={Stack.Item}
110
+ id="root.l3"
111
+ class="pointer-events-none absolute inset-0 z-10 overflow-hidden"
112
+ >
113
+ <Portal.Inner />
114
+ </Portal.Outer>
115
+ {/if}
116
+
117
+ <ActivePortal portal="root.l0">
118
+ {@render children?.()}
119
+ </ActivePortal>
120
+ </Stack.Root>
121
+ </Portals>
@@ -1,7 +1,7 @@
1
1
  export type RootPortals = 'root.l0' | 'root.l1' | 'root.l2' | 'root.l3';
2
2
  declare const Root: import("svelte").Component<{
3
3
  class?: string;
4
- base?: any;
4
+ base: any;
5
5
  children?: any;
6
6
  portals?: any;
7
7
  } & Record<string, any>, {}, "">;
@@ -1,126 +1,116 @@
1
- <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
3
- import { Scrollable as Scrollable_ } from '.';
4
- import { Root as ScrollableRoot } from './atoms';
5
- import gsap from 'gsap';
6
- import { ScrollableBond } from './bond.svelte';
7
- import Root from '../root/root.svelte';
8
- import { on } from '../../attachments/event.svelte';
9
-
10
- const { Story } = defineMeta({
11
- title: 'ATOMS/Scrollable'
12
- });
13
- </script>
14
-
15
- <Story name="Scrollable">
16
- <Root class="p-0">
17
- {#snippet children({ args })}
18
- <div class="h-full w-full flex-1">
19
- <Scrollable_.Root
20
- class="border-border box-border flex min-h-full w-full rounded-lg border shadow-inner"
21
- open={false}
22
- {@attach (node) => {
23
- const scrollable = ScrollableBond.get();
24
- if (!scrollable) return;
25
-
26
- const c1 = on('pointerenter', () => {
27
- scrollable.state.props.open = true;
28
- })(node);
29
-
30
- const c2 = on('pointerleave', () => {
31
- scrollable.state.props.open = false;
32
- })(node);
33
-
34
- return () => {
35
- c1();
36
- c2();
37
- };
38
- }}
39
- >
40
- {#snippet children({ scrollable })}
41
- <Scrollable_.Container class="max-h-[100svh]">
42
- <Scrollable_.Content>
43
- <div class="mx-auto w-[600px] p-4">
44
- <h3 class="mb-4 text-lg font-semibold">Scrollable Content (New API)</h3>
45
- <div class="grid grid-cols-3 gap-4">
46
- {#each Array(99) as _, i}
47
- <div class="rounded border p-4 shadow">
48
- <h4 class="font-medium">Card {i + 1}</h4>
49
- <p class="mt-2 text-sm">
50
- This is some sample content in card {i + 1}. You can scroll horizontally
51
- and vertically to see more content.
52
- </p>
53
- </div>
54
- {/each}
55
- </div>
56
-
57
- <div class="bg-foreground/10 mt-6 rounded p-4">
58
- <p class="text-sm">
59
- This content area is larger than the container, so you can scroll both
60
- horizontally and vertically using the custom scrollbars or mouse wheel.
61
- </p>
62
- </div>
63
-
64
- <div class="mt-4 flex gap-2">
65
- <button
66
- class="rounded bg-blue-500 px-3 py-2 hover:bg-blue-600"
67
- onclick={() => scrollable.scrollTo(0, 0)}
68
- >
69
- Scroll to Top
70
- </button>
71
- <button
72
- class="rounded bg-green-500 px-3 py-2 hover:bg-green-600"
73
- onclick={() => scrollable.scrollBy(50, 50)}
74
- >
75
- Scroll +50px
76
- </button>
77
- </div>
78
- </div>
79
- </Scrollable_.Content>
80
- </Scrollable_.Container>
81
-
82
- <!-- New unified vertical scrollbar -->
83
- <Scrollable_.Track
84
- orientation="vertical"
85
- class="inset-y-0 right-0 w-[2px] rounded-md"
86
- initial={(node) => gsap.set(node, { opacity: 0, right: 0, top: 0, bottom: 0 })}
87
- enter={(node) => {
88
- const tween = gsap.to(node, {
89
- opacity: 1,
90
- duration: 0.3,
91
- right: 8,
92
- top: 8,
93
- bottom: 8,
94
- ease: 'power2.out'
95
- });
96
-
97
- return {
98
- duration: tween.duration() * 1000
99
- };
100
- }}
101
- exit={(node) => {
102
- const tween = gsap.to(node, {
103
- opacity: 0,
104
- right: 0,
105
- top: 0,
106
- bottom: 0,
107
- duration: 0.3,
108
- ease: 'power2.out'
109
- });
110
-
111
- return {
112
- duration: tween.duration() * 1000
113
- };
114
- }}
115
- >
116
- <Scrollable_.Thumb
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>
@@ -2,18 +2,20 @@
2
2
  import { HtmlAtom, type Base } from '../atom';
3
3
  import { SidebarBond } from './bond.svelte';
4
4
  import type { SidebarRootProps } from './types';
5
+ import { animate as motion } from 'motion';
5
6
 
6
7
  const bond = SidebarBond.get();
7
8
 
8
9
  let {
9
10
  class: klass = '',
11
+ width = 'auto',
10
12
  children = undefined,
11
13
  onmount = undefined,
12
14
  ondestroy = undefined,
13
- animate = undefined,
15
+ animate = _animate,
14
16
  enter = undefined,
15
17
  exit = undefined,
16
- initial = undefined,
18
+ initial = _initial,
17
19
  ...restProps
18
20
  }: SidebarRootProps<E, B> = $props();
19
21
 
@@ -21,6 +23,15 @@
21
23
  ...bond?.content(),
22
24
  ...restProps
23
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
+ }
24
35
  </script>
25
36
 
26
37
  <HtmlAtom
@@ -11,18 +11,16 @@
11
11
  children = undefined
12
12
  }: SidebarRootProps<E, B> = $props();
13
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
- );
14
+ const bondProps = defineState<SidebarBondProps>([
15
+ defineProperty(
16
+ 'open',
17
+ () => open,
18
+ (v) => {
19
+ open = v;
20
+ }
21
+ ),
22
+ defineProperty('disabled', () => disabled)
23
+ ]);
26
24
 
27
25
  const bond = factory(bondProps).share();
28
26
 
@@ -1,11 +1,6 @@
1
1
  <script module>
2
- import { cubicOut } from 'svelte/easing';
3
- import gsap from 'gsap';
4
2
  import { defineMeta } from '@storybook/addon-svelte-csf';
5
3
  import { Sidebar as Sidebar_ } from '.';
6
- import Root from '../root/root.svelte';
7
- import { on } from '../../attachments';
8
- import { SidebarBond } from './bond.svelte';
9
4
 
10
5
  // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
11
6
  const { Story } = defineMeta({
@@ -22,26 +17,20 @@
22
17
 
23
18
  <script lang="ts">
24
19
  let isOpen = $state(false);
25
- $inspect(isOpen);
26
20
  </script>
27
21
 
28
22
  <Story name="Sidebar" args={{}}>
29
- <Root class="">
30
- <Sidebar_.Root class="" bind:open={isOpen}>
23
+ <Sidebar_.Root class="" bind:open={isOpen}>
24
+ {#snippet children({ sidebar })}
31
25
  <div class="flex size-full">
32
26
  <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 })}
27
+ class="flex min-w-32 flex-col border-r px-6 py-10 whitespace-nowrap"
28
+ width="300px"
37
29
  >
38
30
  <div>
39
31
  <button
40
- {@attach (node) => {
41
- const bond = SidebarBond.get();
42
- return on('click', (ev) => {
43
- bond?.state.toggle?.();
44
- })(node);
32
+ onclick={() => {
33
+ sidebar?.state.toggle?.();
45
34
  }}>Open</button
46
35
  >
47
36
  </div>
@@ -49,6 +38,6 @@
49
38
 
50
39
  <main class="bg-foreground/2 flex-1 p-8">Hello World!</main>
51
40
  </div>
52
- </Sidebar_.Root>
53
- </Root>
41
+ {/snippet}
42
+ </Sidebar_.Root>
54
43
  </Story>
@@ -20,6 +20,7 @@ export interface SidebarRootProps<E extends keyof HTMLElementTagNameMap = 'div',
20
20
  }>, SidebarRootExtendProps {
21
21
  open?: boolean;
22
22
  disabled?: boolean;
23
+ width?: string | number;
23
24
  factory?: Factory<SidebarBond>;
24
25
  }
25
26
  export interface SidebarContentProps<E extends keyof HTMLElementTagNameMap, B extends Base = Base> extends Override<HtmlAtomProps<E, B>, {
@@ -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;
@@ -30,7 +30,10 @@ export class TabBond extends Bond {
30
30
  return TabBond.set(this);
31
31
  }
32
32
  root(props) {
33
- return {};
33
+ return {
34
+ 'data-active': this.state.isActive,
35
+ 'data-kind': 'tab-root'
36
+ };
34
37
  }
35
38
  header(props) {
36
39
  const id = getElementId(this.id, TAB_ELEMENTS_KIND.header);