@svelte-atoms/core 1.0.0-alpha.27 → 1.0.0-alpha.29
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 -645
- package/dist/components/accordion/accordion-root.svelte +61 -61
- package/dist/components/accordion/item/accordion-item-body.svelte +42 -42
- package/dist/components/accordion/item/accordion-item-header.svelte +50 -50
- package/dist/components/accordion/item/accordion-item-indicator.svelte +50 -50
- package/dist/components/accordion/item/accordion-item-root.svelte +65 -65
- package/dist/components/alert/alert-actions.svelte +43 -42
- package/dist/components/alert/alert-close-button.svelte +70 -72
- package/dist/components/alert/alert-content.svelte +43 -42
- package/dist/components/alert/alert-description.svelte +42 -41
- package/dist/components/alert/alert-icon.svelte +47 -46
- package/dist/components/alert/alert-root.svelte +103 -102
- package/dist/components/alert/alert-title.svelte +42 -41
- package/dist/components/alert/alert.stories.svelte +384 -23
- package/dist/components/alert/alert.stories.svelte.d.ts +2 -5
- package/dist/components/atom/html-atom.svelte +207 -201
- package/dist/components/atom/html-atom.svelte.d.ts +1 -1
- package/dist/components/atom/snippet-renderer.svelte +5 -0
- package/dist/components/atom/snippet-renderer.svelte.d.ts +5 -0
- package/dist/components/avatar/avatar.stories.svelte.d.ts +1 -1
- package/dist/components/badge/badge.stories.svelte.d.ts +1 -1
- package/dist/components/breadcrumb/breadcrumb.stories.svelte.d.ts +1 -1
- package/dist/components/button/button.stories.svelte +17 -14
- package/dist/components/calendar/atoms.d.ts +5 -0
- package/dist/components/calendar/atoms.js +5 -0
- package/dist/components/calendar/bond.svelte.d.ts +72 -0
- package/dist/components/calendar/bond.svelte.js +132 -0
- package/dist/components/calendar/calendar-body.svelte +107 -0
- package/dist/components/calendar/calendar-body.svelte.d.ts +8 -0
- package/dist/components/calendar/calendar-day.svelte +96 -0
- package/dist/components/calendar/calendar-day.svelte.d.ts +4 -0
- package/dist/components/calendar/calendar-header.svelte +29 -0
- package/dist/components/calendar/calendar-header.svelte.d.ts +6 -0
- package/dist/components/calendar/calendar-root.svelte +206 -0
- package/dist/components/calendar/calendar-root.svelte.d.ts +8 -0
- package/dist/components/calendar/calendar-week-day.svelte +34 -0
- package/dist/components/calendar/calendar-week-day.svelte.d.ts +9 -0
- package/dist/components/calendar/calendar.css +26 -0
- package/dist/components/calendar/calendar.stories.svelte +31 -0
- package/dist/components/calendar/calendar.stories.svelte.d.ts +26 -0
- package/dist/components/calendar/index.d.ts +4 -0
- package/dist/components/calendar/index.js +4 -0
- package/dist/components/calendar/runes.svelte.d.ts +3 -0
- package/dist/components/calendar/runes.svelte.js +25 -0
- package/dist/components/calendar/types.d.ts +62 -0
- package/dist/components/calendar/types.js +1 -0
- package/dist/components/card/card-body.svelte +39 -39
- package/dist/components/card/card-description.svelte +41 -41
- package/dist/components/card/card-footer.svelte +41 -41
- package/dist/components/card/card-header.svelte +41 -41
- package/dist/components/card/card-media.svelte +41 -41
- package/dist/components/card/card-root.svelte +91 -91
- package/dist/components/card/card-subtitle.svelte +41 -41
- package/dist/components/card/card-title.svelte +45 -45
- package/dist/components/collapsible/collapsible-body.svelte +39 -39
- package/dist/components/collapsible/collapsible-header.svelte +39 -39
- package/dist/components/collapsible/collapsible-indicator.svelte +50 -50
- package/dist/components/collapsible/collapsible-root.svelte +66 -66
- package/dist/components/combobox/combobox-root.svelte +65 -65
- package/dist/components/container/container.stories.svelte.d.ts +1 -1
- package/dist/components/contextmenu/contextmenu-trigger.svelte.d.ts +1 -1
- package/dist/components/datagrid/bond.svelte.d.ts +2 -2
- package/dist/components/datagrid/datagrid-body.svelte +37 -37
- package/dist/components/datagrid/datagrid-checkbox.svelte +101 -101
- package/dist/components/datagrid/datagrid-footer.svelte +34 -34
- package/dist/components/datagrid/datagrid-header.svelte +49 -49
- package/dist/components/datagrid/datagrid-root.svelte +2 -2
- package/dist/components/datagrid/datagrid.css +5 -47
- package/dist/components/datagrid/td/datagrid-td.svelte +66 -66
- package/dist/components/datagrid/th/datagrid-th.svelte +106 -106
- package/dist/components/datagrid/tr/datagrid-tr.svelte +88 -88
- package/dist/components/datagrid/types.d.ts +1 -1
- package/dist/components/date-picker/atoms.d.ts +3 -0
- package/dist/components/date-picker/atoms.js +3 -0
- package/dist/components/date-picker/bond.svelte.d.ts +67 -0
- package/dist/components/date-picker/bond.svelte.js +174 -0
- package/dist/components/date-picker/date-picker-calendar.svelte +67 -0
- package/dist/components/date-picker/date-picker-calendar.svelte.d.ts +4 -0
- package/dist/components/date-picker/date-picker-header.svelte +100 -0
- package/dist/components/date-picker/date-picker-header.svelte.d.ts +4 -0
- package/dist/components/date-picker/date-picker-months.svelte +142 -0
- package/dist/components/date-picker/date-picker-months.svelte.d.ts +4 -0
- package/dist/components/date-picker/date-picker-root.svelte +95 -0
- package/dist/components/date-picker/date-picker-root.svelte.d.ts +4 -0
- package/dist/components/date-picker/date-picker-years.svelte +205 -0
- package/dist/components/date-picker/date-picker-years.svelte.d.ts +4 -0
- package/dist/components/date-picker/date-picker.stories.svelte +42 -0
- package/dist/components/date-picker/date-picker.stories.svelte.d.ts +3 -0
- package/dist/components/date-picker/index.d.ts +3 -0
- package/dist/components/date-picker/index.js +3 -0
- package/dist/components/date-picker/types.d.ts +53 -0
- package/dist/components/date-picker/types.js +1 -0
- package/dist/components/dialog/dialog-body.svelte +39 -39
- package/dist/components/dialog/dialog-close-button.svelte +58 -58
- package/dist/components/dialog/dialog-content.svelte +1 -1
- package/dist/components/dialog/dialog-description.svelte +40 -40
- package/dist/components/dialog/dialog-footer.svelte +39 -39
- package/dist/components/dialog/dialog-header.svelte +39 -39
- package/dist/components/dialog/dialog-root.svelte +110 -110
- package/dist/components/dialog/dialog-title.svelte +41 -41
- package/dist/components/drawer/drawer-backdrop.svelte +38 -38
- package/dist/components/drawer/drawer-body.svelte +42 -42
- package/dist/components/drawer/drawer-content.svelte +42 -42
- package/dist/components/drawer/drawer-description.svelte +44 -44
- package/dist/components/drawer/drawer-footer.svelte +41 -41
- package/dist/components/drawer/drawer-header.svelte +43 -43
- package/dist/components/drawer/drawer-root.svelte +93 -93
- package/dist/components/drawer/drawer-title.svelte +44 -44
- package/dist/components/dropdown/dropdown-query.svelte +54 -54
- package/dist/components/dropdown/dropdown-root.svelte +59 -59
- package/dist/components/dropdown/dropdown-trigger.svelte +41 -41
- package/dist/components/dropdown/dropdown-value.svelte +60 -60
- package/dist/components/element/types.d.ts +1 -1
- package/dist/components/form/bond.svelte.d.ts +1 -1
- package/dist/components/form/field/field-control.svelte +48 -48
- package/dist/components/form/field/field-label.svelte +24 -24
- package/dist/components/form/field/field-root.svelte +59 -59
- package/dist/components/icon/icon.svelte +44 -44
- package/dist/components/image/image.stories.svelte.d.ts +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/components/input/input-control.svelte +103 -103
- package/dist/components/label/label.svelte +25 -25
- package/dist/components/lazy/index.d.ts +1 -0
- package/dist/components/lazy/index.js +1 -0
- package/dist/components/lazy/lazy.stories.svelte +35 -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/menu/menu-list.svelte +40 -39
- package/dist/components/menu/menu-list.svelte.d.ts +1 -0
- package/dist/components/popover/popover-arrow.svelte +111 -111
- package/dist/components/popover/popover-content.svelte +178 -139
- package/dist/components/popover/popover-root.svelte +16 -17
- package/dist/components/popover/popover.stories.svelte +0 -15
- package/dist/components/portal/portal-root.svelte +83 -83
- package/dist/components/portal/teleport.svelte +50 -50
- package/dist/components/qr-code/index.d.ts +2 -0
- package/dist/components/qr-code/index.js +2 -0
- package/dist/components/qr-code/qr-code.stories.svelte +27 -0
- package/dist/components/qr-code/qr-code.stories.svelte.d.ts +26 -0
- package/dist/components/qr-code/qr-code.svelte +75 -0
- package/dist/components/qr-code/qr-code.svelte.d.ts +4 -0
- package/dist/components/qr-code/types.d.ts +14 -0
- package/dist/components/qr-code/types.js +1 -0
- package/dist/components/radio/radio.svelte +109 -109
- package/dist/components/radio/types.svelte.d.ts +1 -1
- package/dist/components/scrollable/scrollable-container.svelte +82 -82
- package/dist/components/scrollable/scrollable-content.svelte +41 -41
- package/dist/components/scrollable/scrollable-root.svelte +100 -100
- package/dist/components/scrollable/scrollable-thumb.svelte +75 -75
- package/dist/components/scrollable/scrollable-track.svelte +59 -59
- package/dist/components/scrollable/scrollable.stories.svelte.d.ts +1 -1
- 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 +39 -39
- package/dist/components/sidebar/sidebar-content.svelte.d.ts +2 -2
- package/dist/components/sidebar/sidebar-root.svelte +41 -68
- package/dist/components/sidebar/sidebar-root.svelte.d.ts +2 -2
- package/dist/components/sidebar/sidebar.stories.svelte +54 -52
- package/dist/components/sidebar/types.d.ts +6 -6
- package/dist/components/tabs/tab/tab-body.svelte +52 -52
- package/dist/components/tabs/tab/tab-description.svelte +41 -41
- package/dist/components/tabs/tab/tab-header.svelte +71 -71
- package/dist/components/tabs/tab/tab-root.svelte +86 -86
- package/dist/components/toast/toast-description.svelte +38 -38
- package/dist/components/toast/toast-root.svelte +61 -61
- package/dist/components/toast/toast-title.svelte +35 -35
- package/dist/components/tree/tree-body.svelte +39 -39
- package/dist/components/tree/tree-header.svelte +54 -54
- package/dist/components/tree/tree-indicator.svelte +40 -40
- package/dist/components/tree/tree-root.svelte +65 -65
- package/dist/components/virtual/virtual-root.svelte +239 -239
- package/dist/context/preset.svelte.d.ts +1 -1
- package/dist/icons/icon-arrow-down.svelte.d.ts +1 -1
- package/dist/icons/icon-checkmark.svelte.d.ts +1 -1
- package/dist/icons/icon-close.svelte.d.ts +1 -1
- package/dist/icons/icon-more-vert.svelte.d.ts +1 -1
- package/dist/runes/container.svelte.d.ts +2 -2
- package/dist/shared/bond.svelte.d.ts +1 -1
- package/dist/utils/state.d.ts +1 -1
- package/dist/utils/state.js +2 -1
- package/llm/variants.md +650 -103
- package/package.json +465 -437
|
@@ -1,201 +1,207 @@
|
|
|
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,
|
|
4
|
-
import { RootBond } from '../root';
|
|
5
|
-
import { HtmlElement } from '../element';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from '
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
if (
|
|
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
|
-
const
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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: childrenProp = undefined,
|
|
25
|
+
...restProps
|
|
26
|
+
}: HtmlAtomProps<E, B> & Omit<HTMLAttributes<Element>, 'children'> = $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: childrenProp, ..._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
|
+
{#snippet children(args)}
|
|
205
|
+
{@render childrenProp?.(args)}
|
|
206
|
+
{/snippet}
|
|
207
|
+
</renderer.component>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
2
|
import type { Base, HtmlAtomProps } from './types';
|
|
3
3
|
declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base>(): {
|
|
4
|
-
props: HtmlAtomProps<E, B> & HTMLAttributes<HTMLElementTagNameMap[E]>;
|
|
4
|
+
props: HtmlAtomProps<E, B> & Omit<HTMLAttributes<HTMLElementTagNameMap[E]>, "children">;
|
|
5
5
|
exports: {};
|
|
6
6
|
bindings: "";
|
|
7
7
|
slots: {};
|
|
@@ -5,7 +5,17 @@
|
|
|
5
5
|
import { defineVariants } from '../../utils/variant';
|
|
6
6
|
|
|
7
7
|
const { Story } = defineMeta({
|
|
8
|
-
title: 'ATOMS/Button'
|
|
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
|
+
}
|
|
9
19
|
});
|
|
10
20
|
</script>
|
|
11
21
|
|
|
@@ -29,7 +39,8 @@
|
|
|
29
39
|
'bg-transparent hover:bg-foreground/5 active:bg-foreground/10 border border-border text-foreground'
|
|
30
40
|
},
|
|
31
41
|
ghost: {
|
|
32
|
-
class:
|
|
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'
|
|
33
44
|
}
|
|
34
45
|
}
|
|
35
46
|
},
|
|
@@ -41,17 +52,9 @@
|
|
|
41
52
|
</script>
|
|
42
53
|
|
|
43
54
|
<Story name="Button">
|
|
44
|
-
|
|
45
|
-
|
|
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 })}
|
|
55
|
+
{#snippet template(args)}
|
|
56
|
+
<Root class="p-4">
|
|
54
57
|
<ButtonCmp {variants} {...args}>Clicke me</ButtonCmp>
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
</Root>
|
|
59
|
+
{/snippet}
|
|
57
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
|
+
}
|