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