@svelte-atoms/core 1.0.0-alpha.29 → 1.0.0-alpha.31
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 +3 -2
- package/dist/attachments/clickout.svelte.d.ts +1 -1
- package/dist/attachments/clickout.svelte.js +2 -2
- package/dist/components/accordion/accordion-root.svelte +65 -61
- package/dist/components/accordion/accordion-root.svelte.d.ts +1 -1
- package/dist/components/accordion/accordion.stories.svelte +70 -134
- package/dist/components/accordion/item/accordion-item-body.svelte +44 -42
- package/dist/components/accordion/item/accordion-item-header.svelte +51 -50
- package/dist/components/accordion/item/accordion-item-indicator.svelte +51 -50
- package/dist/components/accordion/item/accordion-item-root.svelte +66 -65
- package/dist/components/accordion/item/bond.svelte.d.ts +2 -0
- package/dist/components/accordion/item/index.d.ts +3 -0
- package/dist/components/accordion/item/index.js +3 -0
- package/dist/components/accordion/item/motion.svelte.d.ts +15 -0
- package/dist/components/accordion/item/motion.svelte.js +30 -0
- package/dist/components/accordion/item/types.d.ts +7 -24
- package/dist/components/alert/alert-close-button.svelte +66 -70
- package/dist/components/alert/alert-description.svelte +42 -42
- package/dist/components/alert/alert-description.svelte.d.ts +3 -6
- package/dist/components/alert/alert-root.svelte +68 -103
- package/dist/components/alert/alert-root.svelte.d.ts +2 -2
- package/dist/components/alert/alert.stories.svelte +10 -11
- package/dist/components/alert/bond.svelte.d.ts +0 -13
- package/dist/components/alert/bond.svelte.js +0 -32
- package/dist/components/alert/types.d.ts +8 -32
- package/dist/components/atom/html-atom.svelte +261 -207
- package/dist/components/avatar/avatar.stories.svelte +8 -13
- package/dist/components/badge/badge.stories.svelte +1 -6
- package/dist/components/badge/badge.svelte +1 -1
- package/dist/components/breadcrumb/breadcrumb.stories.svelte +16 -21
- package/dist/components/button/button.stories.svelte +1 -34
- package/dist/components/calendar/calendar-day.svelte +9 -4
- package/dist/components/calendar/calendar-header.svelte +29 -29
- package/dist/components/calendar/calendar-root.svelte +206 -206
- package/dist/components/calendar/calendar.stories.svelte +26 -31
- package/dist/components/card/card-body.svelte +1 -1
- package/dist/components/card/card-footer.svelte +1 -1
- package/dist/components/card/card-root.svelte +1 -1
- package/dist/components/card/card.stories.svelte +92 -104
- package/dist/components/checkbox/checkbox.stories.svelte +4 -9
- package/dist/components/checkbox/checkbox.svelte +159 -157
- package/dist/components/collapsible/collapsible.stories.svelte +2 -3
- package/dist/components/combobox/atoms.d.ts +1 -1
- package/dist/components/combobox/atoms.js +1 -1
- package/dist/components/combobox/combobox-root.svelte +1 -1
- package/dist/components/combobox/compobox.stories.svelte +19 -22
- package/dist/components/combobox/index.d.ts +1 -0
- package/dist/components/container/container.stories.svelte +8 -11
- package/dist/components/container/container.svelte.d.ts +1 -1
- package/dist/components/datagrid/datagrid-root.svelte +59 -59
- package/dist/components/datagrid/datagrid.css +5 -5
- package/dist/components/datagrid/datagrid.stories.svelte +47 -50
- package/dist/components/datagrid/tr/bond.svelte.d.ts +4 -2
- package/dist/components/datagrid/tr/bond.svelte.js +9 -7
- package/dist/components/datagrid/tr/datagrid-tr.svelte +90 -88
- package/dist/components/date-picker/date-picker-calendar.svelte +2 -2
- package/dist/components/date-picker/date-picker-header.svelte +100 -100
- package/dist/components/date-picker/date-picker-months.svelte +142 -142
- package/dist/components/date-picker/date-picker-root.svelte +95 -95
- package/dist/components/date-picker/date-picker-years.svelte +205 -205
- package/dist/components/date-picker/date-picker.stories.svelte +35 -42
- package/dist/components/dialog/bond.svelte.d.ts +13 -3
- package/dist/components/dialog/bond.svelte.js +66 -5
- package/dist/components/dialog/dialog-content.svelte +2 -20
- package/dist/components/dialog/dialog-root.svelte +91 -110
- package/dist/components/dialog/dialog.stories.svelte +34 -37
- package/dist/components/dialog/motion.svelte.d.ts +13 -0
- package/dist/components/dialog/motion.svelte.js +44 -0
- package/dist/components/drawer/attachments.svelte.d.ts +1 -1
- package/dist/components/drawer/attachments.svelte.js +7 -10
- package/dist/components/drawer/bond.svelte.d.ts +24 -5
- package/dist/components/drawer/bond.svelte.js +77 -11
- package/dist/components/drawer/drawer-content.svelte +49 -42
- package/dist/components/drawer/drawer.stories.svelte +144 -224
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +2 -0
- package/dist/components/drawer/motion.d.ts +15 -0
- package/dist/components/drawer/motion.js +28 -0
- package/dist/components/dropdown/atoms.d.ts +1 -1
- package/dist/components/dropdown/atoms.js +1 -1
- package/dist/components/dropdown/bond.svelte.d.ts +5 -1
- package/dist/components/dropdown/dropdown-root.svelte +1 -1
- package/dist/components/dropdown/dropdown.stories.svelte +38 -41
- package/dist/components/dropdown/index.d.ts +1 -0
- package/dist/components/form/form.stories.svelte +58 -61
- package/dist/components/image/image.stories.svelte +9 -12
- package/dist/components/input/input.stories.svelte +11 -14
- package/dist/components/label/label.stories.svelte +1 -12
- package/dist/components/label/label.stories.svelte.d.ts +24 -4
- package/dist/components/lazy/lazy.stories.svelte +28 -35
- package/dist/components/lazy/lazy.svelte +28 -28
- package/dist/components/link/link.stories.svelte +1 -12
- package/dist/components/link/link.stories.svelte.d.ts +24 -4
- package/dist/components/list/list-item.svelte +20 -20
- package/dist/components/menu/atoms.d.ts +1 -0
- package/dist/components/menu/atoms.js +1 -0
- package/dist/components/menu/index.d.ts +2 -1
- package/dist/components/menu/index.js +1 -1
- package/dist/components/menu/menu-item.svelte +69 -51
- package/dist/components/menu/menu-item.svelte.d.ts +1 -0
- package/dist/components/menu/menu-list.svelte +40 -40
- package/dist/components/menu/menu.stories.svelte +9 -12
- package/dist/components/popover/bond.svelte.d.ts +20 -7
- package/dist/components/popover/bond.svelte.js +104 -45
- package/dist/components/popover/motion.d.ts +6 -0
- package/dist/components/popover/motion.js +56 -0
- package/dist/components/popover/popover-arrow.svelte +4 -4
- package/dist/components/popover/popover-content.svelte +137 -178
- package/dist/components/popover/popover-indicator.svelte +2 -1
- package/dist/components/popover/popover-root.svelte +1 -1
- package/dist/components/popover/popover.stories.svelte +49 -52
- package/dist/components/popover/types.d.ts +9 -7
- package/dist/components/portal/active-portal.svelte +29 -22
- package/dist/components/portal/active-portal.svelte.d.ts +2 -9
- package/dist/components/portal/portal-root.svelte +76 -83
- package/dist/components/portal/portal-root.svelte.d.ts +4 -6
- package/dist/components/portal/teleport.svelte +49 -50
- package/dist/components/portal/teleport.svelte.d.ts +3 -4
- package/dist/components/qr-code/qr-code.stories.svelte +18 -27
- package/dist/components/qr-code/qr-code.svelte +75 -75
- package/dist/components/radio/radio-group.stories.svelte +21 -30
- package/dist/components/radio/radio.stories.svelte +1 -10
- package/dist/components/radio/radio.svelte +109 -109
- package/dist/components/radio/types.d.ts +98 -0
- package/dist/components/radio/types.js +2 -0
- package/dist/components/root/root.svelte +104 -121
- package/dist/components/scrollable/scrollable-root.svelte.d.ts +2 -2
- package/dist/components/scrollable/scrollable.stories.svelte +95 -105
- package/dist/components/sidebar/index.d.ts +2 -0
- package/dist/components/sidebar/index.js +2 -0
- package/dist/components/sidebar/motion.svelte.d.ts +11 -0
- package/dist/components/sidebar/motion.svelte.js +16 -0
- package/dist/components/sidebar/sidebar-content.svelte +3 -2
- package/dist/components/sidebar/sidebar-root.svelte +39 -41
- package/dist/components/sidebar/sidebar.stories.svelte +43 -54
- package/dist/components/sidebar/types.d.ts +3 -12
- 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 +31 -34
- package/dist/components/textarea/atoms.d.ts +1 -0
- package/dist/components/textarea/atoms.js +1 -0
- package/dist/components/textarea/textarea-input.svelte +9 -6
- package/dist/components/textarea/textarea-root.svelte +9 -9
- package/dist/components/textarea/textarea-root.svelte.d.ts +2 -0
- package/dist/components/tooltip/tooltip-trigger.svelte +39 -37
- package/dist/components/tooltip/tooltip-trigger.svelte.d.ts +1 -0
- package/dist/components/tooltip/tooltip.stories.svelte +7 -10
- package/dist/components/tree/tree.stories.svelte +102 -94
- package/dist/context/preset.svelte.d.ts +3 -3
- package/dist/icons/icon-copy.svelte +6 -0
- package/dist/{components/radio/types.svelte.d.ts → icons/icon-copy.svelte.d.ts} +3 -3
- package/dist/utils/function.d.ts +2 -0
- package/dist/utils/function.js +6 -0
- package/dist/utils/markdown-to-llm.d.ts +28 -0
- package/dist/utils/markdown-to-llm.js +76 -0
- package/package.json +6 -10
- 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
- package/dist/components/radio/types.svelte +0 -0
- package/llm/composition.md +0 -395
- package/llm/crafting.md +0 -838
- package/llm/motion.md +0 -970
- package/llm/philosophy.md +0 -23
- package/llm/preset-variant-integration.md +0 -516
- package/llm/preset.md +0 -383
- package/llm/styling.md +0 -216
- package/llm/usage.md +0 -46
- package/llm/variants.md +0 -1259
|
@@ -9,118 +9,108 @@
|
|
|
9
9
|
|
|
10
10
|
<script lang="ts">
|
|
11
11
|
import { Card } from '.';
|
|
12
|
-
import { Root } from '../root';
|
|
13
|
-
import gsap from 'gsap';
|
|
14
12
|
</script>
|
|
15
13
|
|
|
16
14
|
<!-- Default Card -->
|
|
17
15
|
<Story name="Default">
|
|
18
|
-
<Root>
|
|
19
|
-
<Card.
|
|
20
|
-
<Card.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
</Card.Root>
|
|
43
|
-
</Root>
|
|
16
|
+
<Card.Root class="max-w-sm">
|
|
17
|
+
<Card.Header>
|
|
18
|
+
<Card.Title>Card Title</Card.Title>
|
|
19
|
+
<Card.Description
|
|
20
|
+
>This is a card description that provides additional context.</Card.Description
|
|
21
|
+
>
|
|
22
|
+
</Card.Header>
|
|
23
|
+
<Card.Body>
|
|
24
|
+
<p>
|
|
25
|
+
This is the main content area of the card. You can put any content here including text,
|
|
26
|
+
images, or other components.
|
|
27
|
+
</p>
|
|
28
|
+
</Card.Body>
|
|
29
|
+
<Card.Footer>
|
|
30
|
+
<button
|
|
31
|
+
class="rounded bg-blue-500 px-3 py-1 text-sm text-white hover:bg-blue-600 active:bg-blue-700"
|
|
32
|
+
>Action</button
|
|
33
|
+
>
|
|
34
|
+
<button
|
|
35
|
+
class="border-border hover:bg-foreground/5 active:bg-foreground/10 rounded border px-3 py-1 text-sm"
|
|
36
|
+
>Cancel</button
|
|
37
|
+
>
|
|
38
|
+
</Card.Footer>
|
|
39
|
+
</Card.Root>
|
|
44
40
|
</Story>
|
|
45
41
|
|
|
46
42
|
<!-- Card with Media -->
|
|
47
43
|
<Story name="With Media">
|
|
48
|
-
<Root>
|
|
49
|
-
<Card.
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<Card.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
</Card.Root>
|
|
68
|
-
</Root>
|
|
44
|
+
<Card.Root class="max-w-sm">
|
|
45
|
+
<Card.Media>
|
|
46
|
+
<img
|
|
47
|
+
src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=400&h=200&fit=crop"
|
|
48
|
+
alt="Beautiful landscape"
|
|
49
|
+
class="h-48 w-full object-cover"
|
|
50
|
+
/>
|
|
51
|
+
</Card.Media>
|
|
52
|
+
<Card.Header>
|
|
53
|
+
<Card.Title>Beautiful Landscape</Card.Title>
|
|
54
|
+
<Card.Subtitle>Photography</Card.Subtitle>
|
|
55
|
+
</Card.Header>
|
|
56
|
+
<Card.Body>
|
|
57
|
+
<p>A stunning landscape photograph capturing the beauty of nature.</p>
|
|
58
|
+
</Card.Body>
|
|
59
|
+
<Card.Footer>
|
|
60
|
+
<span class="text-sm text-gray-500">Posted 2 hours ago</span>
|
|
61
|
+
</Card.Footer>
|
|
62
|
+
</Card.Root>
|
|
69
63
|
</Story>
|
|
70
64
|
|
|
71
65
|
<!-- Clickable Card -->
|
|
72
66
|
<Story name="Clickable">
|
|
73
|
-
<Root
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
>
|
|
78
|
-
<Card.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
</Card.Root>
|
|
88
|
-
</Root>
|
|
67
|
+
<Card.Root
|
|
68
|
+
class="hover:bg-card/90 active:bg-card/80 max-w-sm cursor-pointer pb-4"
|
|
69
|
+
onclick={() => alert('Card clicked!')}
|
|
70
|
+
>
|
|
71
|
+
<Card.Header>
|
|
72
|
+
<Card.Title>Clickable Card</Card.Title>
|
|
73
|
+
<Card.Description
|
|
74
|
+
>This card is clickable and will show an alert when clicked.</Card.Description
|
|
75
|
+
>
|
|
76
|
+
</Card.Header>
|
|
77
|
+
<Card.Body>
|
|
78
|
+
<p>Click anywhere on this card to trigger the action.</p>
|
|
79
|
+
</Card.Body>
|
|
80
|
+
</Card.Root>
|
|
89
81
|
</Story>
|
|
90
82
|
|
|
91
83
|
<!-- Card Variants -->
|
|
92
84
|
<Story name="Variants">
|
|
93
|
-
<
|
|
94
|
-
<
|
|
95
|
-
<Card.
|
|
96
|
-
<Card.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
</Card.Root>
|
|
85
|
+
<div class="grid grid-cols-2 gap-4">
|
|
86
|
+
<Card.Root>
|
|
87
|
+
<Card.Header>
|
|
88
|
+
<Card.Title>Default Card</Card.Title>
|
|
89
|
+
<Card.Description>Default variant with border and shadow.</Card.Description>
|
|
90
|
+
</Card.Header>
|
|
91
|
+
</Card.Root>
|
|
101
92
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
93
|
+
<Card.Root class="bg-transparent shadow-none">
|
|
94
|
+
<Card.Header>
|
|
95
|
+
<Card.Title>Outlined Card</Card.Title>
|
|
96
|
+
<Card.Description>Outlined variant with border only.</Card.Description>
|
|
97
|
+
</Card.Header>
|
|
98
|
+
</Card.Root>
|
|
108
99
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
100
|
+
<Card.Root class="shadow-lg">
|
|
101
|
+
<Card.Header>
|
|
102
|
+
<Card.Title>Elevated Card</Card.Title>
|
|
103
|
+
<Card.Description>Elevated variant with enhanced shadow.</Card.Description>
|
|
104
|
+
</Card.Header>
|
|
105
|
+
</Card.Root>
|
|
115
106
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
</Root>
|
|
107
|
+
<Card.Root class="bg-background border-none">
|
|
108
|
+
<Card.Header>
|
|
109
|
+
<Card.Title>Filled Card</Card.Title>
|
|
110
|
+
<Card.Description>Filled variant with background color.</Card.Description>
|
|
111
|
+
</Card.Header>
|
|
112
|
+
</Card.Root>
|
|
113
|
+
</div>
|
|
124
114
|
</Story>
|
|
125
115
|
|
|
126
116
|
<!-- Disabled Card -->
|
|
@@ -131,15 +121,13 @@
|
|
|
131
121
|
disabled: true
|
|
132
122
|
}}
|
|
133
123
|
>
|
|
134
|
-
<Root>
|
|
135
|
-
<Card.
|
|
136
|
-
<Card.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
<
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
</Card.Root>
|
|
144
|
-
</Root>
|
|
124
|
+
<Card.Root class="max-w-sm pb-4 opacity-50">
|
|
125
|
+
<Card.Header>
|
|
126
|
+
<Card.Title>Disabled Card</Card.Title>
|
|
127
|
+
<Card.Description>This card is disabled and cannot be interacted with.</Card.Description>
|
|
128
|
+
</Card.Header>
|
|
129
|
+
<Card.Body>
|
|
130
|
+
<p>The card appears dimmed and is not clickable.</p>
|
|
131
|
+
</Card.Body>
|
|
132
|
+
</Card.Root>
|
|
145
133
|
</Story>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script module>
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
3
|
import { default as CheckboxCmp } from './checkbox.svelte';
|
|
4
|
-
import Root from '../root/root.svelte';
|
|
5
4
|
|
|
6
5
|
const { Story } = defineMeta({
|
|
7
6
|
title: 'ATOMS/Checkbox'
|
|
@@ -14,14 +13,10 @@
|
|
|
14
13
|
|
|
15
14
|
<Story name="Checkbox">
|
|
16
15
|
{#snippet children({ args })}
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
<div class="flex gap-2">
|
|
20
|
-
<CheckboxCmp bind:checked />
|
|
16
|
+
<div class="flex gap-2">
|
|
17
|
+
<CheckboxCmp bind:checked />
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{/snippet}
|
|
25
|
-
</Root>
|
|
19
|
+
<CheckboxCmp indeterminate />
|
|
20
|
+
</div>
|
|
26
21
|
{/snippet}
|
|
27
22
|
</Story>
|
|
@@ -1,157 +1,159 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { circOut } from 'svelte/easing';
|
|
3
|
-
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
4
|
-
import { scale } from 'svelte/transition';
|
|
5
|
-
import { Icon } from '../icon';
|
|
6
|
-
import { HtmlAtom } from '../atom';
|
|
7
|
-
import CheckmarkRegularIcon from '../../icons/icon-checkmark.svelte';
|
|
8
|
-
import { DURATION } from '../../shared';
|
|
9
|
-
import type { CheckboxProps } from './types';
|
|
10
|
-
import './checkbox.css';
|
|
11
|
-
|
|
12
|
-
let {
|
|
13
|
-
class: klass = '',
|
|
14
|
-
checked = $bindable(false),
|
|
15
|
-
indeterminate = $bindable(false),
|
|
16
|
-
value = $bindable(undefined),
|
|
17
|
-
group = $bindable([]),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const
|
|
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
|
-
checked =
|
|
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
|
-
bind:
|
|
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
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { circOut } from 'svelte/easing';
|
|
3
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
4
|
+
import { scale } from 'svelte/transition';
|
|
5
|
+
import { Icon } from '../icon';
|
|
6
|
+
import { HtmlAtom } from '../atom';
|
|
7
|
+
import CheckmarkRegularIcon from '../../icons/icon-checkmark.svelte';
|
|
8
|
+
import { DURATION } from '../../shared';
|
|
9
|
+
import type { CheckboxProps } from './types';
|
|
10
|
+
import './checkbox.css';
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
class: klass = '',
|
|
14
|
+
checked = $bindable(false),
|
|
15
|
+
indeterminate = $bindable(false),
|
|
16
|
+
value = $bindable(undefined),
|
|
17
|
+
group = $bindable([]),
|
|
18
|
+
disabled = false,
|
|
19
|
+
id,
|
|
20
|
+
name,
|
|
21
|
+
checkedContent,
|
|
22
|
+
indeterminateContent,
|
|
23
|
+
enter,
|
|
24
|
+
exit,
|
|
25
|
+
initial,
|
|
26
|
+
onchange,
|
|
27
|
+
oninput,
|
|
28
|
+
onblur,
|
|
29
|
+
onfocus,
|
|
30
|
+
onclick = undefined,
|
|
31
|
+
...restProps
|
|
32
|
+
}: CheckboxProps & Exclude<HTMLInputAttributes, 'type'> = $props();
|
|
33
|
+
|
|
34
|
+
let checkboxElement: HTMLInputElement | undefined = $state();
|
|
35
|
+
|
|
36
|
+
// Computed state for visual representation
|
|
37
|
+
const isChecked = $derived(checked === true);
|
|
38
|
+
const isIndeterminate = $derived(indeterminate === true);
|
|
39
|
+
const showCheckmark = $derived(isChecked && !isIndeterminate);
|
|
40
|
+
|
|
41
|
+
function handleChange(ev: Event) {
|
|
42
|
+
onchange?.(ev, {
|
|
43
|
+
checked: checked,
|
|
44
|
+
value: checked,
|
|
45
|
+
type: 'boolean'
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function handleInput(ev: Event) {
|
|
50
|
+
oninput?.(ev, {
|
|
51
|
+
checked: checked,
|
|
52
|
+
value: checked,
|
|
53
|
+
type: 'boolean'
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function handleClick(ev: MouseEvent) {
|
|
58
|
+
if (disabled) return;
|
|
59
|
+
|
|
60
|
+
onclick?.(ev);
|
|
61
|
+
|
|
62
|
+
if (ev.defaultPrevented) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Handle indeterminate → checked → unchecked cycle
|
|
67
|
+
if (indeterminate) {
|
|
68
|
+
// Indeterminate → checked
|
|
69
|
+
indeterminate = false;
|
|
70
|
+
checked = true;
|
|
71
|
+
} else {
|
|
72
|
+
// Toggle checked state
|
|
73
|
+
checked = !checked;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Trigger input event manually if needed
|
|
77
|
+
handleInput(ev);
|
|
78
|
+
}
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
82
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
83
|
+
<HtmlAtom
|
|
84
|
+
preset="checkbox"
|
|
85
|
+
as="div"
|
|
86
|
+
class={[
|
|
87
|
+
'checkbox-root border-border outline-primary bg-input text-foreground aspect-square h-5 w-fit cursor-pointer rounded-sm border outline-0 outline-offset-2 transition-colors duration-100',
|
|
88
|
+
isChecked && 'bg-foreground',
|
|
89
|
+
'$preset',
|
|
90
|
+
klass,
|
|
91
|
+
'relative'
|
|
92
|
+
]}
|
|
93
|
+
role="checkbox"
|
|
94
|
+
aria-checked={isIndeterminate ? 'mixed' : isChecked}
|
|
95
|
+
{enter}
|
|
96
|
+
{exit}
|
|
97
|
+
{initial}
|
|
98
|
+
onclick={handleClick}
|
|
99
|
+
{...restProps}
|
|
100
|
+
>
|
|
101
|
+
<input
|
|
102
|
+
bind:this={checkboxElement}
|
|
103
|
+
bind:checked
|
|
104
|
+
bind:group
|
|
105
|
+
bind:indeterminate
|
|
106
|
+
{value}
|
|
107
|
+
{id}
|
|
108
|
+
{name}
|
|
109
|
+
{disabled}
|
|
110
|
+
type="checkbox"
|
|
111
|
+
class="checkbox-input pointer-events-none"
|
|
112
|
+
onchange={handleChange}
|
|
113
|
+
oninput={handleInput}
|
|
114
|
+
{onblur}
|
|
115
|
+
{onfocus}
|
|
116
|
+
hidden
|
|
117
|
+
tabindex="-1"
|
|
118
|
+
/>
|
|
119
|
+
|
|
120
|
+
{#if isIndeterminate}
|
|
121
|
+
{#if indeterminateContent}
|
|
122
|
+
<HtmlAtom
|
|
123
|
+
preset="checkbox.indeterminate"
|
|
124
|
+
class={[
|
|
125
|
+
'checkbox-indeterminate pointer-events-none flex size-full scale-50 items-center justify-center rounded-[inherit] bg-current'
|
|
126
|
+
]}
|
|
127
|
+
base={indeterminateContent}
|
|
128
|
+
/>
|
|
129
|
+
{:else}
|
|
130
|
+
<HtmlAtom
|
|
131
|
+
preset="checkbox.indeterminate"
|
|
132
|
+
class={[
|
|
133
|
+
'checkbox-indeterminate pointer-events-none flex size-full scale-50 items-center justify-center rounded-[inherit] bg-current'
|
|
134
|
+
]}
|
|
135
|
+
/>
|
|
136
|
+
{/if}
|
|
137
|
+
{:else if showCheckmark}
|
|
138
|
+
{#if checkedContent}
|
|
139
|
+
<HtmlAtom
|
|
140
|
+
preset="checkbox.checkmark"
|
|
141
|
+
class={[
|
|
142
|
+
'checkbox-indicator text-accent pointer-events-none flex h-full content-center items-center justify-center overflow-hidden p-0.5'
|
|
143
|
+
]}
|
|
144
|
+
base={checkedContent}
|
|
145
|
+
/>
|
|
146
|
+
{:else}
|
|
147
|
+
<HtmlAtom
|
|
148
|
+
preset="checkbox.checkmark"
|
|
149
|
+
class={[
|
|
150
|
+
'checkbox-indicator text-accent pointer-events-none flex h-full content-center items-center justify-center overflow-hidden p-0.5'
|
|
151
|
+
]}
|
|
152
|
+
enter={(node) => scale(node, { duration: DURATION.fast, easing: circOut, start: 0.6 })}
|
|
153
|
+
exit={(node) => scale(node, { duration: DURATION.fast, easing: circOut, start: 0.6 })}
|
|
154
|
+
>
|
|
155
|
+
<Icon class="h-full p-0" src={CheckmarkRegularIcon} />
|
|
156
|
+
</HtmlAtom>
|
|
157
|
+
{/if}
|
|
158
|
+
{/if}
|
|
159
|
+
</HtmlAtom>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script module>
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
3
|
import { Collapsible as ACollapsible } from '.';
|
|
4
|
-
import Root from '../root/root.svelte';
|
|
5
4
|
|
|
6
5
|
import { animate as motion } from 'motion';
|
|
7
6
|
|
|
@@ -22,7 +21,7 @@
|
|
|
22
21
|
</script>
|
|
23
22
|
|
|
24
23
|
<Story name="Collapsible" args={{}}>
|
|
25
|
-
<
|
|
24
|
+
<div class="flex w-full flex-col gap-2">
|
|
26
25
|
<ACollapsible.Root>
|
|
27
26
|
{#snippet children({ collapsible })}
|
|
28
27
|
{@const isOpen = collapsible.state.props.open}
|
|
@@ -169,5 +168,5 @@
|
|
|
169
168
|
</ACollapsible.Body>
|
|
170
169
|
{/snippet}
|
|
171
170
|
</ACollapsible.Root>
|
|
172
|
-
</
|
|
171
|
+
</div>
|
|
173
172
|
</Story>
|
|
@@ -6,4 +6,4 @@ export { default as Item } from './compobox-item.svelte';
|
|
|
6
6
|
*/
|
|
7
7
|
export { default as Input } from './combobox-control.svelte';
|
|
8
8
|
export { default as Control } from './combobox-control.svelte';
|
|
9
|
-
export { Arrow, Indicator, List } from '../dropdown/atoms';
|
|
9
|
+
export { Arrow, Indicator, List, Group, Divider, Title } from '../dropdown/atoms';
|
|
@@ -6,4 +6,4 @@ export { default as Item } from './compobox-item.svelte';
|
|
|
6
6
|
*/
|
|
7
7
|
export { default as Input } from './combobox-control.svelte';
|
|
8
8
|
export { default as Control } from './combobox-control.svelte';
|
|
9
|
-
export { Arrow, Indicator, List } from '../dropdown/atoms';
|
|
9
|
+
export { Arrow, Indicator, List, Group, Divider, Title } from '../dropdown/atoms';
|