@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,173 +1,172 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { Collapsible as ACollapsible } from '.';
|
|
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
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Collapsible as ACollapsible } from '.';
|
|
4
|
+
|
|
5
|
+
import { animate as motion } from 'motion';
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
title: 'Atoms/Collapsible',
|
|
10
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
11
|
+
|
|
12
|
+
parameters: {
|
|
13
|
+
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
14
|
+
layout: 'fullscreen'
|
|
15
|
+
},
|
|
16
|
+
args: {}
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Story name="Collapsible" args={{}}>
|
|
24
|
+
<div class="flex w-full flex-col gap-2">
|
|
25
|
+
<ACollapsible.Root>
|
|
26
|
+
{#snippet children({ collapsible })}
|
|
27
|
+
{@const isOpen = collapsible.state.props.open}
|
|
28
|
+
|
|
29
|
+
<ACollapsible.Header class="">
|
|
30
|
+
<div>Hello Atoms UI 1</div>
|
|
31
|
+
<ACollapsible.Indicator />
|
|
32
|
+
</ACollapsible.Header>
|
|
33
|
+
|
|
34
|
+
<ACollapsible.Body
|
|
35
|
+
class={['pointer-events-none h-0 opacity-0', isOpen && 'pointer-events-auto']}
|
|
36
|
+
enter={(node) => {
|
|
37
|
+
motion(
|
|
38
|
+
node,
|
|
39
|
+
{
|
|
40
|
+
opacity: +isOpen,
|
|
41
|
+
height: isOpen ? 'auto' : 0
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
duration: 0.2,
|
|
45
|
+
ease: 'linear'
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
return { duration: 0.2 };
|
|
49
|
+
}}
|
|
50
|
+
exit={(node) => {
|
|
51
|
+
motion(node, { opacity: 0, height: 0 }, { duration: 0.2, ease: 'linear' });
|
|
52
|
+
return { duration: 0.2 };
|
|
53
|
+
}}
|
|
54
|
+
animate={(node) => {
|
|
55
|
+
motion(
|
|
56
|
+
node,
|
|
57
|
+
{
|
|
58
|
+
opacity: +isOpen,
|
|
59
|
+
height: isOpen ? 'auto' : 0
|
|
60
|
+
},
|
|
61
|
+
{ duration: 0.2, ease: 'linear' }
|
|
62
|
+
);
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
<div class="py-2">
|
|
66
|
+
Mauris et habitasse cubilia potenti at condimentum iaculis nam. Ante fusce litora
|
|
67
|
+
tristique letius libero. Curabitur vitae cursus consectetur feugiat aenean viverra vel
|
|
68
|
+
dolor diam nascetur.
|
|
69
|
+
</div>
|
|
70
|
+
</ACollapsible.Body>
|
|
71
|
+
{/snippet}
|
|
72
|
+
</ACollapsible.Root>
|
|
73
|
+
|
|
74
|
+
<ACollapsible.Root>
|
|
75
|
+
{#snippet children({ collapsible })}
|
|
76
|
+
{@const isOpen = collapsible.state.isOpen}
|
|
77
|
+
|
|
78
|
+
<ACollapsible.Header class="">
|
|
79
|
+
<div>Hello Atoms UI 2</div>
|
|
80
|
+
<ACollapsible.Indicator />
|
|
81
|
+
</ACollapsible.Header>
|
|
82
|
+
|
|
83
|
+
<ACollapsible.Body
|
|
84
|
+
class={['pointer-events-none h-0 opacity-0', isOpen && 'pointer-events-auto']}
|
|
85
|
+
enter={(node) => {
|
|
86
|
+
motion(
|
|
87
|
+
node,
|
|
88
|
+
{
|
|
89
|
+
opacity: +isOpen,
|
|
90
|
+
height: isOpen ? 'auto' : 0
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
duration: 0.2,
|
|
94
|
+
ease: 'linear'
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
return { duration: 0.2 };
|
|
98
|
+
}}
|
|
99
|
+
exit={(node) => {
|
|
100
|
+
motion(node, { opacity: 0, height: 0 }, { duration: 0.2, ease: 'linear' });
|
|
101
|
+
return { duration: 0.2 };
|
|
102
|
+
}}
|
|
103
|
+
animate={(node) => {
|
|
104
|
+
motion(
|
|
105
|
+
node,
|
|
106
|
+
{
|
|
107
|
+
opacity: +isOpen,
|
|
108
|
+
height: isOpen ? 'auto' : 0
|
|
109
|
+
},
|
|
110
|
+
{ duration: 0.1, ease: 'linear' }
|
|
111
|
+
);
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
<div class="py-2">
|
|
115
|
+
Mauris et habitasse cubilia potenti at condimentum iaculis nam. Ante fusce litora
|
|
116
|
+
tristique letius libero. Curabitur vitae cursus consectetur feugiat aenean viverra vel
|
|
117
|
+
dolor diam nascetur.
|
|
118
|
+
</div>
|
|
119
|
+
</ACollapsible.Body>
|
|
120
|
+
{/snippet}
|
|
121
|
+
</ACollapsible.Root>
|
|
122
|
+
|
|
123
|
+
<ACollapsible.Root>
|
|
124
|
+
{#snippet children({ collapsible })}
|
|
125
|
+
{@const isOpen = collapsible.state.isOpen}
|
|
126
|
+
|
|
127
|
+
<ACollapsible.Header class="">
|
|
128
|
+
<div>Hello Atoms UI 3</div>
|
|
129
|
+
<ACollapsible.Indicator />
|
|
130
|
+
</ACollapsible.Header>
|
|
131
|
+
|
|
132
|
+
<ACollapsible.Body
|
|
133
|
+
class={['pointer-events-none h-0 opacity-0', isOpen && 'pointer-events-auto']}
|
|
134
|
+
enter={(node) => {
|
|
135
|
+
motion(
|
|
136
|
+
node,
|
|
137
|
+
{
|
|
138
|
+
opacity: +isOpen,
|
|
139
|
+
height: isOpen ? 'auto' : 0
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
duration: 0.2,
|
|
143
|
+
ease: 'linear'
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
return { duration: 0.2 };
|
|
147
|
+
}}
|
|
148
|
+
exit={(node) => {
|
|
149
|
+
motion(node, { opacity: 0, height: 0 }, { duration: 0.2, ease: 'linear' });
|
|
150
|
+
return { duration: 0.2 };
|
|
151
|
+
}}
|
|
152
|
+
animate={(node) => {
|
|
153
|
+
motion(
|
|
154
|
+
node,
|
|
155
|
+
{
|
|
156
|
+
opacity: +isOpen,
|
|
157
|
+
height: isOpen ? 'auto' : 0
|
|
158
|
+
},
|
|
159
|
+
{ duration: 0.1, ease: 'linear' }
|
|
160
|
+
);
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
<div class="py-2">
|
|
164
|
+
Mauris et habitasse cubilia potenti at condimentum iaculis nam. Ante fusce litora
|
|
165
|
+
tristique letius libero. Curabitur vitae cursus consectetur feugiat aenean viverra vel
|
|
166
|
+
dolor diam nascetur.
|
|
167
|
+
</div>
|
|
168
|
+
</ACollapsible.Body>
|
|
169
|
+
{/snippet}
|
|
170
|
+
</ACollapsible.Root>
|
|
171
|
+
</div>
|
|
172
|
+
</Story>
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
<script lang="ts" generics="D">
|
|
2
|
-
import type { ComboboxRootProps } from './types';
|
|
3
|
-
import { defineProperty, defineState } from '../../utils';
|
|
4
|
-
import { ComboboxBond, ComboboxBondState, type ComboboxBondProps } from './bond.svelte';
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
open = $bindable(false),
|
|
8
|
-
value = $bindable(),
|
|
9
|
-
values = $bindable(),
|
|
10
|
-
query = $bindable(),
|
|
11
|
-
text = $bindable(),
|
|
12
|
-
multiple = false,
|
|
13
|
-
disabled = false,
|
|
14
|
-
placements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
|
|
15
|
-
placement = 'bottom-start',
|
|
16
|
-
offset =
|
|
17
|
-
factory = _factory,
|
|
18
|
-
children = undefined,
|
|
19
|
-
...restProps
|
|
20
|
-
}: ComboboxRootProps = $props();
|
|
21
|
-
|
|
22
|
-
const bondProps = defineState<ComboboxBondProps>(
|
|
23
|
-
[
|
|
24
|
-
defineProperty(
|
|
25
|
-
'open',
|
|
26
|
-
() => open,
|
|
27
|
-
(v) => {
|
|
28
|
-
open = v;
|
|
29
|
-
}
|
|
30
|
-
),
|
|
31
|
-
defineProperty(
|
|
32
|
-
'values',
|
|
33
|
-
() => (multiple ? values : [value]),
|
|
34
|
-
(v) => {
|
|
35
|
-
values = v;
|
|
36
|
-
value = v[0];
|
|
37
|
-
}
|
|
38
|
-
),
|
|
39
|
-
defineProperty(
|
|
40
|
-
'query',
|
|
41
|
-
() => query,
|
|
42
|
-
(v) => (query = v)
|
|
43
|
-
),
|
|
44
|
-
defineProperty(
|
|
45
|
-
'text',
|
|
46
|
-
() => text,
|
|
47
|
-
(v) => (text = v)
|
|
48
|
-
)
|
|
49
|
-
],
|
|
50
|
-
() => ({ disabled, multiple, placements, offset, placement: 'bottom-start', ...restProps })
|
|
51
|
-
);
|
|
52
|
-
const bond = factory(bondProps).share();
|
|
53
|
-
|
|
54
|
-
function _factory(props: typeof bondProps) {
|
|
55
|
-
const bondState = new ComboboxBondState<D>(() => props);
|
|
56
|
-
|
|
57
|
-
return new ComboboxBond(bondState).share();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function getBond() {
|
|
61
|
-
return bond;
|
|
62
|
-
}
|
|
63
|
-
</script>
|
|
64
|
-
|
|
65
|
-
{@render children?.({ combobox: bond })}
|
|
1
|
+
<script lang="ts" generics="D">
|
|
2
|
+
import type { ComboboxRootProps } from './types';
|
|
3
|
+
import { defineProperty, defineState } from '../../utils';
|
|
4
|
+
import { ComboboxBond, ComboboxBondState, type ComboboxBondProps } from './bond.svelte';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
open = $bindable(false),
|
|
8
|
+
value = $bindable(),
|
|
9
|
+
values = $bindable(),
|
|
10
|
+
query = $bindable(),
|
|
11
|
+
text = $bindable(),
|
|
12
|
+
multiple = false,
|
|
13
|
+
disabled = false,
|
|
14
|
+
placements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
|
|
15
|
+
placement = 'bottom-start',
|
|
16
|
+
offset = 1,
|
|
17
|
+
factory = _factory,
|
|
18
|
+
children = undefined,
|
|
19
|
+
...restProps
|
|
20
|
+
}: ComboboxRootProps = $props();
|
|
21
|
+
|
|
22
|
+
const bondProps = defineState<ComboboxBondProps>(
|
|
23
|
+
[
|
|
24
|
+
defineProperty(
|
|
25
|
+
'open',
|
|
26
|
+
() => open,
|
|
27
|
+
(v) => {
|
|
28
|
+
open = v;
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
defineProperty(
|
|
32
|
+
'values',
|
|
33
|
+
() => (multiple ? values : [value]),
|
|
34
|
+
(v) => {
|
|
35
|
+
values = v;
|
|
36
|
+
value = v[0];
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
defineProperty(
|
|
40
|
+
'query',
|
|
41
|
+
() => query,
|
|
42
|
+
(v) => (query = v)
|
|
43
|
+
),
|
|
44
|
+
defineProperty(
|
|
45
|
+
'text',
|
|
46
|
+
() => text,
|
|
47
|
+
(v) => (text = v)
|
|
48
|
+
)
|
|
49
|
+
],
|
|
50
|
+
() => ({ disabled, multiple, placements, offset, placement: 'bottom-start', ...restProps })
|
|
51
|
+
);
|
|
52
|
+
const bond = factory(bondProps).share();
|
|
53
|
+
|
|
54
|
+
function _factory(props: typeof bondProps) {
|
|
55
|
+
const bondState = new ComboboxBondState<D>(() => props);
|
|
56
|
+
|
|
57
|
+
return new ComboboxBond(bondState).share();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getBond() {
|
|
61
|
+
return bond;
|
|
62
|
+
}
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
{@render children?.({ combobox: bond })}
|
|
@@ -1,54 +1,51 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { Combobox as ACombobox } from '.';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
let
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
{ value: '
|
|
26
|
-
{ value: '
|
|
27
|
-
{ value: '
|
|
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
|
-
</ACombobox.Root>
|
|
53
|
-
</Root>
|
|
54
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Combobox as ACombobox } from '.';
|
|
4
|
+
import { Input } from '../input';
|
|
5
|
+
import { Divider } from '../divider';
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
title: 'Atoms/Combobox',
|
|
10
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
11
|
+
|
|
12
|
+
parameters: {
|
|
13
|
+
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
14
|
+
layout: 'fullscreen'
|
|
15
|
+
},
|
|
16
|
+
args: {}
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
let open = $state(false);
|
|
22
|
+
let value = $state<string | undefined>('ar');
|
|
23
|
+
let array = $state([
|
|
24
|
+
{ value: 'ar', label: 'Arabic' },
|
|
25
|
+
{ value: 'en', label: 'English' },
|
|
26
|
+
{ value: 'sp', label: 'Spanish' },
|
|
27
|
+
{ value: 'it', label: 'Italian' }
|
|
28
|
+
]);
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<Story name="Combobox" args={{}}>
|
|
32
|
+
<ACombobox.Root bind:open bind:value>
|
|
33
|
+
{#snippet children({ combobox })}
|
|
34
|
+
<ACombobox.Trigger
|
|
35
|
+
base={Input.Root}
|
|
36
|
+
class="h-10 min-w-sm items-center gap-0 rounded-sm p-1 transition-colors duration-200"
|
|
37
|
+
>
|
|
38
|
+
<Input.Icon class="text-foreground/50">$</Input.Icon>
|
|
39
|
+
<Divider class="mx-1" vertical />
|
|
40
|
+
<ACombobox.Input class="px-1" placeholder="Select a language" />
|
|
41
|
+
</ACombobox.Trigger>
|
|
42
|
+
<ACombobox.List>
|
|
43
|
+
{#each array.filter((item) => !combobox.state.query || item.label
|
|
44
|
+
.toLowerCase()
|
|
45
|
+
.includes(combobox.state.query)) as item (item.value)}
|
|
46
|
+
<ACombobox.Item value={item.value}>{item.label}</ACombobox.Item>
|
|
47
|
+
{/each}
|
|
48
|
+
</ACombobox.List>
|
|
49
|
+
{/snippet}
|
|
50
|
+
</ACombobox.Root>
|
|
51
|
+
</Story>
|
|
@@ -1,23 +1,20 @@
|
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</ContainerCmp>
|
|
22
|
-
</Root>
|
|
23
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import ContainerCmp from './container.svelte';
|
|
4
|
+
|
|
5
|
+
const { Story } = defineMeta({
|
|
6
|
+
title: 'ATOMS/Container'
|
|
7
|
+
});
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Story name="Container">
|
|
11
|
+
<ContainerCmp class="flex w-full flex-col items-center gap-4">
|
|
12
|
+
<div class="flex w-full gap-4">
|
|
13
|
+
{#each { length: 5 } as _, i (i)}
|
|
14
|
+
<div class="bg-foreground h-80 flex-1 rounded-lg"></div>
|
|
15
|
+
{/each}
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div class="bg-foreground h-80 w-[50cqw] rounded-lg"></div>
|
|
19
|
+
</ContainerCmp>
|
|
20
|
+
</Story>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
class: klass = '',
|
|
11
11
|
values = $bindable([]),
|
|
12
12
|
template = undefined,
|
|
13
|
-
|
|
13
|
+
fallbackTemplate = 'auto',
|
|
14
14
|
factory = _factory,
|
|
15
15
|
children = undefined,
|
|
16
16
|
onmount = undefined,
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
{bond}
|
|
47
47
|
preset="datagrid"
|
|
48
48
|
class={['border-border', 'datagrid-root w-full gap-x-0 gap-y-0', '$preset', klass]}
|
|
49
|
-
style="--template-columns:{bond.state.template}"
|
|
49
|
+
style="--template-columns:{bond.state.template ?? fallbackTemplate}"
|
|
50
50
|
enter={enter?.bind(bond.state)}
|
|
51
51
|
exit={exit?.bind(bond.state)}
|
|
52
52
|
initial={initial?.bind(bond.state)}
|