@svelte-atoms/core 1.0.0-alpha.27 → 1.0.0-alpha.28

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 (163) hide show
  1. package/README.md +856 -645
  2. package/dist/components/accordion/accordion-root.svelte +61 -61
  3. package/dist/components/accordion/item/accordion-item-body.svelte +42 -42
  4. package/dist/components/accordion/item/accordion-item-header.svelte +50 -50
  5. package/dist/components/accordion/item/accordion-item-indicator.svelte +50 -50
  6. package/dist/components/accordion/item/accordion-item-root.svelte +65 -65
  7. package/dist/components/alert/alert-actions.svelte +2 -1
  8. package/dist/components/alert/alert-close-button.svelte +18 -20
  9. package/dist/components/alert/alert-content.svelte +2 -1
  10. package/dist/components/alert/alert-description.svelte +2 -1
  11. package/dist/components/alert/alert-icon.svelte +2 -1
  12. package/dist/components/alert/alert-root.svelte +3 -2
  13. package/dist/components/alert/alert-title.svelte +2 -1
  14. package/dist/components/alert/alert.stories.svelte +401 -40
  15. package/dist/components/alert/alert.stories.svelte.d.ts +2 -5
  16. package/dist/components/atom/html-atom.svelte +205 -201
  17. package/dist/components/atom/snippet-renderer.svelte +5 -0
  18. package/dist/components/atom/snippet-renderer.svelte.d.ts +5 -0
  19. package/dist/components/avatar/avatar.stories.svelte.d.ts +1 -1
  20. package/dist/components/badge/badge.stories.svelte.d.ts +1 -1
  21. package/dist/components/breadcrumb/breadcrumb.stories.svelte.d.ts +1 -1
  22. package/dist/components/button/button.stories.svelte +60 -57
  23. package/dist/components/calendar/atoms.d.ts +5 -0
  24. package/dist/components/calendar/atoms.js +5 -0
  25. package/dist/components/calendar/bond.svelte.d.ts +72 -0
  26. package/dist/components/calendar/bond.svelte.js +132 -0
  27. package/dist/components/calendar/calendar-body.svelte +107 -0
  28. package/dist/components/calendar/calendar-body.svelte.d.ts +8 -0
  29. package/dist/components/calendar/calendar-day.svelte +97 -0
  30. package/dist/components/calendar/calendar-day.svelte.d.ts +4 -0
  31. package/dist/components/calendar/calendar-header.svelte +33 -0
  32. package/dist/components/calendar/calendar-header.svelte.d.ts +7 -0
  33. package/dist/components/calendar/calendar-root.svelte +208 -0
  34. package/dist/components/calendar/calendar-root.svelte.d.ts +8 -0
  35. package/dist/components/calendar/calendar-week-day.svelte +34 -0
  36. package/dist/components/calendar/calendar-week-day.svelte.d.ts +9 -0
  37. package/dist/components/calendar/calendar.css +26 -0
  38. package/dist/components/calendar/calendar.stories.svelte +36 -0
  39. package/dist/components/calendar/calendar.stories.svelte.d.ts +6 -0
  40. package/dist/components/calendar/index.d.ts +4 -0
  41. package/dist/components/calendar/index.js +4 -0
  42. package/dist/components/calendar/runes.svelte.d.ts +3 -0
  43. package/dist/components/calendar/runes.svelte.js +25 -0
  44. package/dist/components/calendar/types.d.ts +62 -0
  45. package/dist/components/calendar/types.js +1 -0
  46. package/dist/components/card/card-body.svelte +39 -39
  47. package/dist/components/card/card-description.svelte +41 -41
  48. package/dist/components/card/card-footer.svelte +41 -41
  49. package/dist/components/card/card-header.svelte +41 -41
  50. package/dist/components/card/card-media.svelte +41 -41
  51. package/dist/components/card/card-root.svelte +91 -91
  52. package/dist/components/card/card-subtitle.svelte +41 -41
  53. package/dist/components/card/card-title.svelte +45 -45
  54. package/dist/components/collapsible/collapsible-body.svelte +39 -39
  55. package/dist/components/collapsible/collapsible-header.svelte +39 -39
  56. package/dist/components/collapsible/collapsible-indicator.svelte +50 -50
  57. package/dist/components/collapsible/collapsible-root.svelte +66 -66
  58. package/dist/components/combobox/combobox-root.svelte +65 -65
  59. package/dist/components/container/container.stories.svelte.d.ts +1 -1
  60. package/dist/components/contextmenu/contextmenu-trigger.svelte.d.ts +1 -1
  61. package/dist/components/datagrid/bond.svelte.d.ts +2 -2
  62. package/dist/components/datagrid/datagrid-body.svelte +37 -37
  63. package/dist/components/datagrid/datagrid-checkbox.svelte +101 -101
  64. package/dist/components/datagrid/datagrid-footer.svelte +34 -34
  65. package/dist/components/datagrid/datagrid-header.svelte +49 -49
  66. package/dist/components/datagrid/datagrid-root.svelte +59 -59
  67. package/dist/components/datagrid/td/datagrid-td.svelte +66 -66
  68. package/dist/components/datagrid/th/datagrid-th.svelte +106 -106
  69. package/dist/components/datagrid/tr/datagrid-tr.svelte +88 -88
  70. package/dist/components/date-picker/atoms.d.ts +7 -0
  71. package/dist/components/date-picker/atoms.js +7 -0
  72. package/dist/components/date-picker/bond.svelte.d.ts +67 -0
  73. package/dist/components/date-picker/bond.svelte.js +174 -0
  74. package/dist/components/date-picker/date-picker-calendar.svelte +42 -0
  75. package/dist/components/date-picker/date-picker-calendar.svelte.d.ts +7 -0
  76. package/dist/components/date-picker/date-picker-header.svelte +105 -0
  77. package/dist/components/date-picker/date-picker-header.svelte.d.ts +7 -0
  78. package/dist/components/date-picker/date-picker-months.svelte +150 -0
  79. package/dist/components/date-picker/date-picker-months.svelte.d.ts +7 -0
  80. package/dist/components/date-picker/date-picker-root.svelte +94 -0
  81. package/dist/components/date-picker/date-picker-root.svelte.d.ts +17 -0
  82. package/dist/components/date-picker/date-picker-years.svelte +214 -0
  83. package/dist/components/date-picker/date-picker-years.svelte.d.ts +7 -0
  84. package/dist/components/date-picker/date-picker.stories.svelte +51 -0
  85. package/dist/components/date-picker/date-picker.stories.svelte.d.ts +3 -0
  86. package/dist/components/date-picker/index.d.ts +3 -0
  87. package/dist/components/date-picker/index.js +3 -0
  88. package/dist/components/date-picker/types.d.ts +1 -0
  89. package/dist/components/date-picker/types.js +1 -0
  90. package/dist/components/dialog/dialog-body.svelte +39 -39
  91. package/dist/components/dialog/dialog-close-button.svelte +58 -58
  92. package/dist/components/dialog/dialog-content.svelte +62 -62
  93. package/dist/components/dialog/dialog-description.svelte +40 -40
  94. package/dist/components/dialog/dialog-footer.svelte +39 -39
  95. package/dist/components/dialog/dialog-header.svelte +39 -39
  96. package/dist/components/dialog/dialog-root.svelte +110 -110
  97. package/dist/components/dialog/dialog-title.svelte +41 -41
  98. package/dist/components/drawer/drawer-backdrop.svelte +38 -38
  99. package/dist/components/drawer/drawer-body.svelte +42 -42
  100. package/dist/components/drawer/drawer-content.svelte +42 -42
  101. package/dist/components/drawer/drawer-description.svelte +44 -44
  102. package/dist/components/drawer/drawer-footer.svelte +41 -41
  103. package/dist/components/drawer/drawer-header.svelte +43 -43
  104. package/dist/components/drawer/drawer-root.svelte +93 -93
  105. package/dist/components/drawer/drawer-title.svelte +44 -44
  106. package/dist/components/dropdown/dropdown-query.svelte +54 -54
  107. package/dist/components/dropdown/dropdown-root.svelte +59 -59
  108. package/dist/components/dropdown/dropdown-trigger.svelte +41 -41
  109. package/dist/components/dropdown/dropdown-value.svelte +60 -60
  110. package/dist/components/element/html-element.svelte +85 -85
  111. package/dist/components/form/bond.svelte.d.ts +1 -1
  112. package/dist/components/form/field/field-control.svelte +48 -48
  113. package/dist/components/form/field/field-label.svelte +24 -24
  114. package/dist/components/form/field/field-root.svelte +59 -59
  115. package/dist/components/icon/icon.svelte +44 -44
  116. package/dist/components/image/image.stories.svelte.d.ts +1 -1
  117. package/dist/components/index.d.ts +3 -0
  118. package/dist/components/index.js +3 -0
  119. package/dist/components/input/input-control.svelte +103 -103
  120. package/dist/components/label/label.svelte +25 -25
  121. package/dist/components/popover/popover-arrow.svelte +111 -111
  122. package/dist/components/popover/popover-content.svelte +46 -7
  123. package/dist/components/popover/popover-root.svelte +48 -49
  124. package/dist/components/popover/popover.stories.svelte +52 -67
  125. package/dist/components/portal/portal-root.svelte +83 -83
  126. package/dist/components/portal/teleport.svelte +50 -50
  127. package/dist/components/qr-code/index.d.ts +1 -0
  128. package/dist/components/qr-code/index.js +1 -0
  129. package/dist/components/qr-code/qr-code.stories.svelte +24 -0
  130. package/dist/components/qr-code/qr-code.stories.svelte.d.ts +26 -0
  131. package/dist/components/qr-code/qr-code.svelte +25 -0
  132. package/dist/components/qr-code/qr-code.svelte.d.ts +6 -0
  133. package/dist/components/radio/radio.svelte +109 -109
  134. package/dist/components/radio/types.svelte.d.ts +1 -1
  135. package/dist/components/scrollable/scrollable-container.svelte +82 -82
  136. package/dist/components/scrollable/scrollable-content.svelte +41 -41
  137. package/dist/components/scrollable/scrollable-root.svelte +100 -100
  138. package/dist/components/scrollable/scrollable-thumb.svelte +75 -75
  139. package/dist/components/scrollable/scrollable-track.svelte +59 -59
  140. package/dist/components/scrollable/scrollable.stories.svelte.d.ts +1 -1
  141. package/dist/components/tabs/tab/tab-body.svelte +52 -52
  142. package/dist/components/tabs/tab/tab-description.svelte +41 -41
  143. package/dist/components/tabs/tab/tab-header.svelte +71 -71
  144. package/dist/components/tabs/tab/tab-root.svelte +86 -86
  145. package/dist/components/toast/toast-description.svelte +38 -38
  146. package/dist/components/toast/toast-root.svelte +61 -61
  147. package/dist/components/toast/toast-title.svelte +35 -35
  148. package/dist/components/tree/tree-body.svelte +39 -39
  149. package/dist/components/tree/tree-header.svelte +54 -54
  150. package/dist/components/tree/tree-indicator.svelte +40 -40
  151. package/dist/components/tree/tree-root.svelte +65 -65
  152. package/dist/components/virtual/virtual-root.svelte +239 -239
  153. package/dist/context/preset.svelte.d.ts +1 -1
  154. package/dist/icons/icon-arrow-down.svelte.d.ts +1 -1
  155. package/dist/icons/icon-checkmark.svelte.d.ts +1 -1
  156. package/dist/icons/icon-close.svelte.d.ts +1 -1
  157. package/dist/icons/icon-more-vert.svelte.d.ts +1 -1
  158. package/dist/runes/container.svelte.d.ts +2 -2
  159. package/dist/shared/bond.svelte.d.ts +1 -1
  160. package/dist/utils/state.d.ts +1 -1
  161. package/dist/utils/state.js +2 -1
  162. package/llm/variants.md +1261 -712
  163. package/package.json +464 -437
@@ -1,201 +1,205 @@
1
- <script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
2
- import type { HTMLAttributes } from 'svelte/elements';
3
- import type { Base, ComponentBase, HtmlAtomProps, SnippetBase } from './types';
4
- import { RootBond } from '../root';
5
- import { HtmlElement } from '../element';
6
- import {
7
- cn,
8
- toClassValue,
9
- type ClassValue,
10
- type VariantDefinition
11
- } from '../../utils';
12
- import { getPreset } from '../../context';
13
- import type { PresetModuleName } from '../../context/preset.svelte';
14
- import type { Bond } from '../../shared';
15
-
16
- type Element = HTMLElementTagNameMap[E];
17
-
18
- const rootBond = RootBond.get();
19
-
20
- let {
21
- class: klass = '',
22
- as = 'div',
23
- base = undefined,
24
- preset: presetKey = undefined,
25
- bond = undefined,
26
- variants = undefined,
27
- children = undefined,
28
- ...restProps
29
- }: HtmlAtomProps<E, B> & HTMLAttributes<Element> = $props();
30
-
31
- const preset = $derived(
32
- presetKey ? getPreset(presetKey as PresetModuleName)?.apply?.(bond, [bond]) : undefined
33
- );
34
-
35
- const presetProps = $derived(preset?.variants);
36
-
37
- // Resolve local variants - either VariantDefinition or function
38
- const localVariants = $derived.by(() => {
39
- if (!variants) return undefined;
40
-
41
- // If it's a function, call it directly
42
- if (typeof variants === 'function') {
43
- return variants(bond as Bond, restProps);
44
- }
45
-
46
- // Otherwise it's a VariantDefinition, resolve it
47
- return resolveVariants(variants, bond as Bond, restProps);
48
- });
49
-
50
- // Merge preset variants with local variants
51
- const mergedVariants = $derived.by(() => {
52
- // No variants at all
53
- if (!presetProps && !localVariants) return undefined;
54
-
55
- // Only preset variants (raw object from preset)
56
- if (presetProps && !localVariants) {
57
- // Convert preset variants to VariantDefinition-like structure
58
- const variantDef = {
59
- class: preset?.class,
60
- variants: presetProps,
61
- compounds: preset?.compounds ?? [],
62
- defaults: preset?.defaults ?? {}
63
- };
64
- return resolveVariants(variantDef, bond as Bond, restProps);
65
- }
66
-
67
- // Only local variants
68
- if (!presetProps && localVariants) {
69
- return localVariants;
70
- }
71
-
72
- // Both exist - merge them
73
- // When both preset and local variants exist, we need to merge the resolved props
74
- const presetVariantDef = {
75
- class: preset?.class,
76
- variants: presetProps,
77
- compounds: preset?.compounds ?? [],
78
- defaults: preset?.defaults ?? {}
79
- };
80
-
81
- const presetResolved = resolveVariants(presetVariantDef, bond as Bond, restProps);
82
-
83
- // Merge the resolved variant props
84
- // Local variant classes and attributes override preset
85
- const presetClasses = Array.isArray(presetResolved.class)
86
- ? presetResolved.class
87
- : [presetResolved.class];
88
- const localClasses = Array.isArray(localVariants?.class)
89
- ? localVariants.class
90
- : [localVariants?.class];
91
-
92
- return {
93
- class: [...presetClasses, ...localClasses].filter(Boolean),
94
- ...presetResolved,
95
- ...localVariants
96
- };
97
- });
98
-
99
- const _klass = $derived(
100
- cn(klass, mergedVariants?.class ?? '').replaceAll('$preset', cn(preset?.class))
101
- );
102
-
103
- const _base = $derived(base ?? preset?.base);
104
- const _as = $derived(as ?? preset?.as);
105
- const _restProps = $derived.by(() => {
106
- const {
107
- class: klassPreset,
108
- base,
109
- as,
110
- variants: presetProps,
111
- ...restPresetProps
112
- } = preset ?? {};
113
- const { class: variantClass, ...variantsRestProps } = mergedVariants ?? {};
114
-
115
- return { ...restPresetProps, ...variantsRestProps, ...restProps };
116
- });
117
-
118
- const isSnippet = $derived(typeof _base === 'function' && _base.length === 1 && !_base.prototype);
119
-
120
- const snippet = $derived(_base as SnippetBase);
121
-
122
- const atom = rootBond?.state?.props?.renderers?.html ?? HtmlElement;
123
-
124
- const Component = $derived(base ?? atom) as ComponentBase;
125
-
126
- /**
127
- * Resolve variant definition to props
128
- */
129
- function resolveVariants(
130
- def: VariantDefinition<any>,
131
- bond: Bond | null | undefined,
132
- props: Record<string, any>
133
- ): Record<string, any> {
134
- const { variants: variantMap, compounds, defaults, class: baseClass } = def;
135
-
136
- // Merge props with defaults
137
- const finalProps = { ...defaults, ...props };
138
-
139
- const classes: ClassValue[] = [];
140
- const attributes: Record<string, any> = {};
141
-
142
- // Add base class
143
- if (baseClass) classes.push(baseClass);
144
-
145
- // Add variant classes
146
- if (variantMap) {
147
- for (const [key, value] of Object.entries(finalProps)) {
148
- const variantValue = variantMap[key]?.[value as string];
149
- if (variantValue !== undefined) {
150
- const resolved = typeof variantValue === 'function' ? variantValue(bond) : variantValue;
151
-
152
- if (typeof resolved === 'string') {
153
- classes.push(resolved);
154
- } else if (typeof resolved === 'object' && resolved !== null) {
155
- if ('class' in resolved) {
156
- classes.push(resolved.class);
157
- }
158
- // Add other attributes
159
- Object.entries(resolved).forEach(([k, v]) => {
160
- if (k !== 'class') {
161
- attributes[k] = v;
162
- }
163
- });
164
- }
165
- }
166
- }
167
- }
168
-
169
- // Add compound variants
170
- if (compounds) {
171
- for (const compound of compounds) {
172
- const { class: compoundClass, ...compoundProps } = compound;
173
- const matches = Object.entries(compoundProps).every(
174
- ([key, value]) => finalProps[key] === value
175
- );
176
- if (matches) {
177
- if (compoundClass) classes.push(compoundClass);
178
- // Add compound attributes
179
- Object.entries(compound).forEach(([k, v]) => {
180
- if (k !== 'class' && !Object.keys(compoundProps).includes(k)) {
181
- attributes[k] = v;
182
- }
183
- });
184
- }
185
- }
186
- }
187
-
188
- return {
189
- class: classes,
190
- ...attributes
191
- };
192
- }
193
- </script>
194
-
195
- {#if isSnippet}
196
- {@render snippet({ class: _klass, as: _as, base: _base, children, ..._restProps })}
197
- {:else}
198
- <Component class={_klass} as={_as} {..._restProps}>
199
- {@render children?.()}
200
- </Component>
201
- {/if}
1
+ <script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { Base, HtmlAtomProps, SnippetBase } from './types';
4
+ import { RootBond } from '../root';
5
+ import { HtmlElement } from '../element';
6
+ import { cn, type ClassValue, type VariantDefinition } from '../../utils';
7
+ import { getPreset } from '../../context';
8
+ import type { PresetModuleName } from '../../context/preset.svelte';
9
+ import type { Bond } from '../../shared';
10
+ import SnippetRenderer from './snippet-renderer.svelte';
11
+ import type { Component } from 'svelte';
12
+
13
+ type Element = HTMLElementTagNameMap[E];
14
+
15
+ const rootBond = RootBond.get();
16
+
17
+ let {
18
+ class: klass = '',
19
+ as = 'div',
20
+ base = undefined,
21
+ preset: presetKey = undefined,
22
+ bond = undefined,
23
+ variants = undefined,
24
+ children = undefined,
25
+ ...restProps
26
+ }: HtmlAtomProps<E, B> & HTMLAttributes<Element> = $props();
27
+
28
+ const preset = $derived(
29
+ presetKey ? getPreset(presetKey as PresetModuleName)?.apply?.(bond, [bond]) : undefined
30
+ );
31
+
32
+ const presetProps = $derived(preset?.variants);
33
+
34
+ // Resolve local variants - either VariantDefinition or function
35
+ const localVariants = $derived.by(() => {
36
+ if (!variants) return undefined;
37
+
38
+ // If it's a function, call it directly
39
+ if (typeof variants === 'function') {
40
+ return variants(bond as Bond, restProps);
41
+ }
42
+
43
+ // Otherwise it's a VariantDefinition, resolve it
44
+ return resolveVariants(variants, bond as Bond, restProps);
45
+ });
46
+
47
+ // Merge preset variants with local variants
48
+ const mergedVariants = $derived.by(() => {
49
+ // No variants at all
50
+ if (!presetProps && !localVariants) return undefined;
51
+
52
+ // Only preset variants (raw object from preset)
53
+ if (presetProps && !localVariants) {
54
+ // Convert preset variants to VariantDefinition-like structure
55
+ const variantDef = {
56
+ class: preset?.class,
57
+ variants: presetProps,
58
+ compounds: preset?.compounds ?? [],
59
+ defaults: preset?.defaults ?? {}
60
+ };
61
+ return resolveVariants(variantDef, bond as Bond, restProps);
62
+ }
63
+
64
+ // Only local variants
65
+ if (!presetProps && localVariants) {
66
+ return localVariants;
67
+ }
68
+
69
+ // Both exist - merge them
70
+ // When both preset and local variants exist, we need to merge the resolved props
71
+ const presetVariantDef = {
72
+ class: preset?.class,
73
+ variants: presetProps,
74
+ compounds: preset?.compounds ?? [],
75
+ defaults: preset?.defaults ?? {}
76
+ };
77
+
78
+ const presetResolved = resolveVariants(presetVariantDef, bond as Bond, restProps);
79
+
80
+ // Merge the resolved variant props
81
+ // Local variant classes and attributes override preset
82
+ const presetClasses = Array.isArray(presetResolved.class)
83
+ ? presetResolved.class
84
+ : [presetResolved.class];
85
+ const localClasses = Array.isArray(localVariants?.class)
86
+ ? localVariants.class
87
+ : [localVariants?.class];
88
+
89
+ return {
90
+ class: [...presetClasses, ...localClasses].filter(Boolean),
91
+ ...presetResolved,
92
+ ...localVariants
93
+ };
94
+ });
95
+
96
+ const _klass = $derived(
97
+ cn(klass, mergedVariants?.class ?? '').replaceAll('$preset', cn(preset?.class))
98
+ );
99
+
100
+ const _base = $derived(base ?? preset?.base);
101
+ const _as = $derived(as ?? preset?.as);
102
+ const _restProps = $derived.by(() => {
103
+ const {
104
+ class: klassPreset,
105
+ base,
106
+ as,
107
+ variants: presetProps,
108
+ ...restPresetProps
109
+ } = preset ?? {};
110
+ const { class: variantClass, ...variantsRestProps } = mergedVariants ?? {};
111
+
112
+ return { ...restPresetProps, ...variantsRestProps, ...restProps };
113
+ });
114
+
115
+ const isSnippet = $derived(typeof _base === 'function' && _base.length === 1 && !_base.prototype);
116
+
117
+ const snippet = $derived(_base as SnippetBase);
118
+
119
+ const atom = rootBond?.state?.props?.renderers?.html ?? HtmlElement;
120
+
121
+ const renderer = $derived.by(() => {
122
+ if (isSnippet)
123
+ return {
124
+ component: SnippetRenderer,
125
+ props: { snippet: snippet, class: _klass, as: _as, children, ..._restProps }
126
+ };
127
+
128
+ return {
129
+ component: base ?? atom,
130
+ props: { class: _klass, as: _as, ..._restProps }
131
+ };
132
+ }) as { component: Component; props: Record<string, any> };
133
+
134
+ /**
135
+ * Resolve variant definition to props
136
+ */
137
+ function resolveVariants(
138
+ def: VariantDefinition<any>,
139
+ bond: Bond | null | undefined,
140
+ props: Record<string, any>
141
+ ): Record<string, any> {
142
+ const { variants: variantMap, compounds, defaults, class: baseClass } = def;
143
+
144
+ // Merge props with defaults
145
+ const finalProps = { ...defaults, ...props };
146
+
147
+ const classes: ClassValue[] = [];
148
+ const attributes: Record<string, any> = {};
149
+
150
+ // Add base class
151
+ if (baseClass) classes.push(baseClass);
152
+
153
+ // Add variant classes
154
+ if (variantMap) {
155
+ for (const [key, value] of Object.entries(finalProps)) {
156
+ const variantValue = variantMap[key]?.[value as string];
157
+ if (variantValue !== undefined) {
158
+ const resolved = typeof variantValue === 'function' ? variantValue(bond) : variantValue;
159
+
160
+ if (typeof resolved === 'string') {
161
+ classes.push(resolved);
162
+ } else if (typeof resolved === 'object' && resolved !== null) {
163
+ if ('class' in resolved) {
164
+ classes.push(resolved.class);
165
+ }
166
+ // Add other attributes
167
+ Object.entries(resolved).forEach(([k, v]) => {
168
+ if (k !== 'class') {
169
+ attributes[k] = v;
170
+ }
171
+ });
172
+ }
173
+ }
174
+ }
175
+ }
176
+
177
+ // Add compound variants
178
+ if (compounds) {
179
+ for (const compound of compounds) {
180
+ const { class: compoundClass, ...compoundProps } = compound;
181
+ const matches = Object.entries(compoundProps).every(
182
+ ([key, value]) => finalProps[key] === value
183
+ );
184
+ if (matches) {
185
+ if (compoundClass) classes.push(compoundClass);
186
+ // Add compound attributes
187
+ Object.entries(compound).forEach(([k, v]) => {
188
+ if (k !== 'class' && !Object.keys(compoundProps).includes(k)) {
189
+ attributes[k] = v;
190
+ }
191
+ });
192
+ }
193
+ }
194
+ }
195
+
196
+ return {
197
+ class: classes,
198
+ ...attributes
199
+ };
200
+ }
201
+ </script>
202
+
203
+ <renderer.component {...renderer.props}>
204
+ {@render children?.()}
205
+ </renderer.component>
@@ -0,0 +1,5 @@
1
+ <script lang="ts">
2
+ let { snippet, ...restProps } = $props();
3
+ </script>
4
+
5
+ {@render snippet?.({ ...restProps })}
@@ -0,0 +1,5 @@
1
+ declare const SnippetRenderer: import("svelte").Component<{
2
+ snippet: any;
3
+ } & Record<string, any>, {}, "">;
4
+ type SnippetRenderer = ReturnType<typeof SnippetRenderer>;
5
+ export default SnippetRenderer;
@@ -4,7 +4,7 @@ type Avatar = SvelteComponent<{
4
4
  }, {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  }, {}> & {
7
- $$bindings?: string | undefined;
7
+ $$bindings?: string;
8
8
  };
9
9
  declare const Avatar: $$__sveltets_2_IsomorphicComponent<{
10
10
  [x: string]: never;
@@ -4,7 +4,7 @@ type Badge = SvelteComponent<{
4
4
  }, {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  }, {}> & {
7
- $$bindings?: string | undefined;
7
+ $$bindings?: string;
8
8
  };
9
9
  declare const Badge: $$__sveltets_2_IsomorphicComponent<{
10
10
  [x: string]: never;
@@ -4,7 +4,7 @@ type Breadcrumb = SvelteComponent<{
4
4
  }, {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  }, {}> & {
7
- $$bindings?: string | undefined;
7
+ $$bindings?: string;
8
8
  };
9
9
  declare const Breadcrumb: $$__sveltets_2_IsomorphicComponent<{
10
10
  [x: string]: never;
@@ -1,57 +1,60 @@
1
- <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
3
- import Root from '../root/root.svelte';
4
- import ButtonCmp from './button.svelte';
5
- import { defineVariants } from '../../utils/variant';
6
-
7
- const { Story } = defineMeta({
8
- title: 'ATOMS/Button'
9
- });
10
- </script>
11
-
12
- <script lang="ts">
13
- const variants = defineVariants((bond) => ({
14
- variants: {
15
- variant: {
16
- primary: {
17
- class: 'bg-primary text-primary-foreground hover:bg-primary/80 active:bg-primary/90'
18
- },
19
- secondary: {
20
- class:
21
- 'bg-secondary text-secondary-foreground hover:bg-secondary/80 active:bg-secondary/90'
22
- },
23
- destructive: {
24
- class:
25
- 'bg-destructive text-destructive-foreground hover:bg-destructive/80 active:bg-destructive/90'
26
- },
27
- outline: {
28
- class:
29
- 'bg-transparent hover:bg-foreground/5 active:bg-foreground/10 border border-border text-foreground'
30
- },
31
- ghost: {
32
- class: 'hover:bg-accent hover:text-accent-foreground'
33
- }
34
- }
35
- },
36
- compounds: [],
37
- defaults: {
38
- variant: 'destructive'
39
- }
40
- }));
41
- </script>
42
-
43
- <Story name="Button">
44
- <Root class="p-4">
45
- {#snippet children({ args })}
46
- <ButtonCmp variant="primary">Clicke me</ButtonCmp>
47
- {/snippet}
48
- </Root>
49
- </Story>
50
-
51
- <Story name="Button - Local Variants">
52
- <Root class="p-4">
53
- {#snippet children({ args })}
54
- <ButtonCmp {variants} {...args}>Clicke me</ButtonCmp>
55
- {/snippet}
56
- </Root>
57
- </Story>
1
+ <script module>
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Root from '../root/root.svelte';
4
+ import ButtonCmp from './button.svelte';
5
+ import { defineVariants } from '../../utils/variant';
6
+
7
+ const { Story } = defineMeta({
8
+ title: 'ATOMS/Button',
9
+ argTypes: {
10
+ variant: {
11
+ control: 'select',
12
+ options: ['primary', 'secondary', 'destructive', 'outline', 'ghost'],
13
+ description: 'Button variant style',
14
+ table: {
15
+ defaultValue: { summary: 'primary' }
16
+ }
17
+ }
18
+ }
19
+ });
20
+ </script>
21
+
22
+ <script lang="ts">
23
+ const variants = defineVariants((bond) => ({
24
+ variants: {
25
+ variant: {
26
+ primary: {
27
+ class: 'bg-primary text-primary-foreground hover:bg-primary/80 active:bg-primary/90'
28
+ },
29
+ secondary: {
30
+ class:
31
+ 'bg-secondary text-secondary-foreground hover:bg-secondary/80 active:bg-secondary/90'
32
+ },
33
+ destructive: {
34
+ class:
35
+ 'bg-destructive text-destructive-foreground hover:bg-destructive/80 active:bg-destructive/90'
36
+ },
37
+ outline: {
38
+ class:
39
+ 'bg-transparent hover:bg-foreground/5 active:bg-foreground/10 border border-border text-foreground'
40
+ },
41
+ ghost: {
42
+ class:
43
+ 'bg-transparent text-foreground hover:bg-foreground/5 active:bg-foreground/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2'
44
+ }
45
+ }
46
+ },
47
+ compounds: [],
48
+ defaults: {
49
+ variant: 'destructive'
50
+ }
51
+ }));
52
+ </script>
53
+
54
+ <Story name="Button">
55
+ {#snippet template(args)}
56
+ <Root class="p-4">
57
+ <ButtonCmp {variants} {...args}>Clicke me</ButtonCmp>
58
+ </Root>
59
+ {/snippet}
60
+ </Story>
@@ -0,0 +1,5 @@
1
+ export { default as Root } from './calendar-root.svelte';
2
+ export { default as Body } from './calendar-body.svelte';
3
+ export { default as Day } from './calendar-day.svelte';
4
+ export { default as Header } from './calendar-header.svelte';
5
+ export { default as WeekDay } from './calendar-week-day.svelte';
@@ -0,0 +1,5 @@
1
+ export { default as Root } from './calendar-root.svelte';
2
+ export { default as Body } from './calendar-body.svelte';
3
+ export { default as Day } from './calendar-day.svelte';
4
+ export { default as Header } from './calendar-header.svelte';
5
+ export { default as WeekDay } from './calendar-week-day.svelte';
@@ -0,0 +1,72 @@
1
+ import { Bond, BondState, type BondStateProps } from '../../shared/bond.svelte';
2
+ import type { CalendarRange, Day, Month } from './types';
3
+ export type CalendarBondProps = BondStateProps & {
4
+ value?: Date;
5
+ range: CalendarRange;
6
+ start?: Date;
7
+ end?: Date;
8
+ min?: Date;
9
+ max?: Date;
10
+ pivote?: Date;
11
+ disabled?: boolean;
12
+ type?: 'range' | 'single';
13
+ currentMonth?: Month;
14
+ previousMonth?: Month;
15
+ nextMonth?: Month;
16
+ extend?: Record<string, unknown>;
17
+ };
18
+ export type CalendarBondElements = {
19
+ root: HTMLElement;
20
+ body: HTMLElement;
21
+ day: HTMLElement;
22
+ weekDay: HTMLElement;
23
+ header: HTMLElement;
24
+ };
25
+ export declare class CalendarBond<Props extends CalendarBondProps = CalendarBondProps, State extends CalendarBondState<Props> = CalendarBondState<Props>> extends Bond<Props, State, CalendarBondElements> {
26
+ static CONTEXT_KEY: string;
27
+ constructor(s: State);
28
+ share(): this;
29
+ root(): {
30
+ [x: symbol]: (node: HTMLElement) => void;
31
+ id: string;
32
+ 'aria-label': string;
33
+ 'aria-disabled': boolean;
34
+ role: string;
35
+ };
36
+ body(): {
37
+ [x: symbol]: (node: HTMLElement) => void;
38
+ id: string;
39
+ role: string;
40
+ 'aria-labelledby': string;
41
+ };
42
+ day(day: Day): {
43
+ id: string;
44
+ role: string;
45
+ 'aria-selected': boolean;
46
+ 'aria-disabled': boolean;
47
+ tabindex: number;
48
+ };
49
+ weekDay(): {
50
+ id: string;
51
+ role: string;
52
+ };
53
+ header(): {
54
+ [x: symbol]: (node: HTMLElement) => void;
55
+ id: string;
56
+ role: string;
57
+ };
58
+ static get(): CalendarBond | undefined;
59
+ static set(bond: CalendarBond): CalendarBond;
60
+ }
61
+ export declare class CalendarBondState<Props extends CalendarBondProps> extends BondState<Props> {
62
+ constructor(props: () => Props);
63
+ selectDate(date: Date): void;
64
+ selectStart(date: Date): void;
65
+ selectEnd(date: Date): void;
66
+ unselect(): void;
67
+ unselectStart(): void;
68
+ unselectEnd(): void;
69
+ nextMonth(): void;
70
+ previousMonth(): void;
71
+ isDaySelected(day: Day): boolean;
72
+ }