@svelte-atoms/core 1.0.0-alpha.28 → 1.0.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +852 -856
- package/dist/attachments/clickout.svelte.d.ts +1 -1
- package/dist/attachments/clickout.svelte.js +2 -2
- package/dist/components/accordion/accordion-root.svelte +61 -61
- package/dist/components/accordion/accordion-root.svelte.d.ts +1 -1
- package/dist/components/accordion/accordion.stories.svelte +145 -134
- package/dist/components/alert/alert-actions.svelte +43 -43
- package/dist/components/alert/alert-close-button.svelte +70 -70
- package/dist/components/alert/alert-content.svelte +43 -43
- package/dist/components/alert/alert-description.svelte +42 -42
- package/dist/components/alert/alert-icon.svelte +47 -47
- package/dist/components/alert/alert-root.svelte +103 -103
- package/dist/components/alert/alert-title.svelte +42 -42
- package/dist/components/alert/alert.stories.svelte +10 -11
- package/dist/components/atom/html-atom.svelte +75 -19
- package/dist/components/atom/html-atom.svelte.d.ts +1 -1
- package/dist/components/atom/snippet-renderer.svelte +5 -5
- package/dist/components/avatar/avatar.stories.svelte +22 -27
- package/dist/components/badge/badge.stories.svelte +12 -17
- package/dist/components/badge/badge.svelte +19 -19
- package/dist/components/breadcrumb/breadcrumb.stories.svelte +16 -21
- package/dist/components/button/button.stories.svelte +1 -34
- package/dist/components/calendar/calendar-body.svelte +107 -107
- package/dist/components/calendar/calendar-day.svelte +96 -97
- package/dist/components/calendar/calendar-header.svelte +29 -33
- package/dist/components/calendar/calendar-header.svelte.d.ts +0 -1
- package/dist/components/calendar/calendar-root.svelte +206 -208
- package/dist/components/calendar/calendar-week-day.svelte +34 -34
- package/dist/components/calendar/calendar.css +26 -26
- package/dist/components/calendar/calendar.stories.svelte +10 -20
- package/dist/components/calendar/calendar.stories.svelte.d.ts +24 -4
- package/dist/components/card/card-body.svelte +39 -39
- package/dist/components/card/card-footer.svelte +41 -41
- package/dist/components/card/card-root.svelte +91 -91
- package/dist/components/card/card.stories.svelte +133 -145
- package/dist/components/checkbox/checkbox.stories.svelte +22 -27
- package/dist/components/checkbox/checkbox.svelte +155 -157
- package/dist/components/collapsible/collapsible.stories.svelte +172 -173
- package/dist/components/combobox/combobox-root.svelte +65 -65
- package/dist/components/combobox/compobox.stories.svelte +51 -54
- package/dist/components/container/container.stories.svelte +20 -23
- package/dist/components/datagrid/datagrid-root.svelte +2 -2
- package/dist/components/datagrid/datagrid.css +0 -42
- package/dist/components/datagrid/datagrid.stories.svelte +72 -75
- package/dist/components/datagrid/types.d.ts +1 -1
- package/dist/components/date-picker/atoms.d.ts +0 -4
- package/dist/components/date-picker/atoms.js +0 -4
- package/dist/components/date-picker/date-picker-calendar.svelte +67 -42
- package/dist/components/date-picker/date-picker-calendar.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-header.svelte +100 -105
- package/dist/components/date-picker/date-picker-header.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-months.svelte +142 -150
- package/dist/components/date-picker/date-picker-months.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-root.svelte +4 -3
- package/dist/components/date-picker/date-picker-root.svelte.d.ts +2 -15
- package/dist/components/date-picker/date-picker-years.svelte +205 -214
- package/dist/components/date-picker/date-picker-years.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker.stories.svelte +15 -31
- package/dist/components/date-picker/types.d.ts +53 -1
- package/dist/components/dialog/dialog-content.svelte +1 -1
- package/dist/components/dialog/dialog.stories.svelte +64 -67
- package/dist/components/drawer/attachments.svelte.js +8 -9
- package/dist/components/drawer/drawer-content.svelte +57 -42
- package/dist/components/drawer/drawer.stories.svelte +212 -224
- package/dist/components/dropdown/dropdown-root.svelte +59 -59
- package/dist/components/dropdown/dropdown.stories.svelte +80 -83
- package/dist/components/element/html-element.svelte +85 -85
- package/dist/components/element/types.d.ts +1 -1
- package/dist/components/form/form.stories.svelte +96 -99
- package/dist/components/image/image.stories.svelte +20 -23
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/input/input.stories.svelte +35 -38
- package/dist/components/label/label.stories.svelte +15 -26
- package/dist/components/label/label.stories.svelte.d.ts +24 -4
- package/dist/components/lazy/index.d.ts +1 -0
- package/dist/components/lazy/index.js +1 -0
- package/dist/components/lazy/lazy.stories.svelte +28 -0
- package/dist/components/lazy/lazy.stories.svelte.d.ts +19 -0
- package/dist/components/lazy/lazy.svelte +28 -0
- package/dist/components/lazy/lazy.svelte.d.ts +5 -0
- package/dist/components/lazy/types.d.ts +10 -0
- package/dist/components/lazy/types.js +1 -0
- package/dist/components/link/link.stories.svelte +15 -26
- package/dist/components/link/link.stories.svelte.d.ts +24 -4
- package/dist/components/menu/menu-list.svelte +2 -1
- package/dist/components/menu/menu-list.svelte.d.ts +1 -0
- package/dist/components/menu/menu.stories.svelte +33 -36
- package/dist/components/popover/bond.svelte.js +31 -25
- package/dist/components/popover/popover-arrow.svelte +111 -111
- package/dist/components/popover/popover-content.svelte +2 -5
- package/dist/components/popover/popover-indicator.svelte +44 -43
- package/dist/components/popover/popover-root.svelte +1 -1
- package/dist/components/popover/popover.stories.svelte +18 -21
- package/dist/components/qr-code/index.d.ts +1 -0
- package/dist/components/qr-code/index.js +1 -0
- package/dist/components/qr-code/qr-code.stories.svelte +4 -10
- package/dist/components/qr-code/qr-code.svelte +75 -25
- package/dist/components/qr-code/qr-code.svelte.d.ts +2 -4
- package/dist/components/qr-code/types.d.ts +14 -0
- package/dist/components/qr-code/types.js +1 -0
- package/dist/components/radio/radio-group.stories.svelte +41 -50
- package/dist/components/radio/radio.stories.svelte +17 -26
- package/dist/components/radio/radio.svelte +109 -109
- package/dist/components/root/root.svelte +121 -121
- package/dist/components/root/root.svelte.d.ts +1 -1
- package/dist/components/scrollable/scrollable.stories.svelte +116 -126
- package/dist/components/sidebar/bond.svelte.d.ts +0 -5
- package/dist/components/sidebar/bond.svelte.js +1 -12
- package/dist/components/sidebar/sidebar-content.svelte +50 -39
- package/dist/components/sidebar/sidebar-content.svelte.d.ts +2 -2
- package/dist/components/sidebar/sidebar-root.svelte +39 -68
- package/dist/components/sidebar/sidebar-root.svelte.d.ts +2 -2
- package/dist/components/sidebar/sidebar.stories.svelte +43 -52
- package/dist/components/sidebar/types.d.ts +7 -6
- package/dist/components/tabs/tab/bond.svelte.d.ts +4 -1
- package/dist/components/tabs/tab/bond.svelte.js +4 -1
- package/dist/components/tabs/tabs.stories.svelte +56 -59
- package/dist/components/tooltip/tooltip-trigger.svelte +39 -37
- package/dist/components/tooltip/tooltip.stories.svelte +32 -35
- package/dist/components/tree/tree.stories.svelte +142 -134
- package/dist/context/preset.svelte.d.ts +3 -3
- package/dist/utils/function.d.ts +2 -0
- package/dist/utils/function.js +6 -0
- package/llm/variants.md +1259 -1261
- package/package.json +7 -9
- package/dist/actions/animation.svelte.d.ts +0 -6
- package/dist/actions/animation.svelte.js +0 -14
- package/dist/actions/clickout.svelte.d.ts +0 -2
- package/dist/actions/clickout.svelte.js +0 -15
- package/dist/actions/popover.svelte.d.ts +0 -19
- package/dist/actions/popover.svelte.js +0 -81
- package/dist/actions/portal.svelte.d.ts +0 -8
- package/dist/actions/portal.svelte.js +0 -32
- package/dist/attachments/gsap.svelte.d.ts +0 -2
- package/dist/attachments/gsap.svelte.js +0 -26
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import type { Bond } from '../../shared';
|
|
10
10
|
import SnippetRenderer from './snippet-renderer.svelte';
|
|
11
11
|
import type { Component } from 'svelte';
|
|
12
|
+
import { call } from '../../utils/function';
|
|
12
13
|
|
|
13
14
|
type Element = HTMLElementTagNameMap[E];
|
|
14
15
|
|
|
@@ -21,13 +22,24 @@
|
|
|
21
22
|
preset: presetKey = undefined,
|
|
22
23
|
bond = undefined,
|
|
23
24
|
variants = undefined,
|
|
24
|
-
children = undefined,
|
|
25
|
+
children: childrenProp = undefined,
|
|
25
26
|
...restProps
|
|
26
|
-
}: HtmlAtomProps<E, B> & HTMLAttributes<Element> = $props();
|
|
27
|
+
}: HtmlAtomProps<E, B> & Omit<HTMLAttributes<Element>, 'children'> = $props();
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Resolve variant definition to props
|
|
31
|
+
*/
|
|
32
|
+
// Cache for resolved variants to avoid recomputation
|
|
33
|
+
// Key: JSON stringified combination of variant props
|
|
34
|
+
const variantCache = new Map<string, Record<string, any>>();
|
|
35
|
+
|
|
36
|
+
// Memoize preset resolution - only recompute when presetKey or bond changes
|
|
37
|
+
const preset = $derived.by(() => {
|
|
38
|
+
if (!presetKey) return undefined;
|
|
39
|
+
const result = getPreset(presetKey as PresetModuleName)?.apply?.(bond, [bond]);
|
|
40
|
+
// Handle deferred preset result (factory function)
|
|
41
|
+
return call(result);
|
|
42
|
+
});
|
|
31
43
|
|
|
32
44
|
const presetProps = $derived(preset?.variants);
|
|
33
45
|
|
|
@@ -45,6 +57,7 @@
|
|
|
45
57
|
});
|
|
46
58
|
|
|
47
59
|
// Merge preset variants with local variants
|
|
60
|
+
// Memoized to avoid recomputation when inputs haven't changed
|
|
48
61
|
const mergedVariants = $derived.by(() => {
|
|
49
62
|
// No variants at all
|
|
50
63
|
if (!presetProps && !localVariants) return undefined;
|
|
@@ -52,8 +65,8 @@
|
|
|
52
65
|
// Only preset variants (raw object from preset)
|
|
53
66
|
if (presetProps && !localVariants) {
|
|
54
67
|
// Convert preset variants to VariantDefinition-like structure
|
|
55
|
-
const variantDef = {
|
|
56
|
-
class: preset?.class,
|
|
68
|
+
const variantDef: VariantDefinition<any> = {
|
|
69
|
+
class: preset?.class ?? '',
|
|
57
70
|
variants: presetProps,
|
|
58
71
|
compounds: preset?.compounds ?? [],
|
|
59
72
|
defaults: preset?.defaults ?? {}
|
|
@@ -68,9 +81,9 @@
|
|
|
68
81
|
|
|
69
82
|
// Both exist - merge them
|
|
70
83
|
// When both preset and local variants exist, we need to merge the resolved props
|
|
71
|
-
const presetVariantDef = {
|
|
72
|
-
class: preset?.class,
|
|
73
|
-
variants: presetProps,
|
|
84
|
+
const presetVariantDef: VariantDefinition<any> = {
|
|
85
|
+
class: preset?.class ?? '',
|
|
86
|
+
variants: presetProps ?? {},
|
|
74
87
|
compounds: preset?.compounds ?? [],
|
|
75
88
|
defaults: preset?.defaults ?? {}
|
|
76
89
|
};
|
|
@@ -93,9 +106,31 @@
|
|
|
93
106
|
};
|
|
94
107
|
});
|
|
95
108
|
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
)
|
|
109
|
+
const presetClassString = $derived(cn(preset?.class));
|
|
110
|
+
|
|
111
|
+
const _klass = $derived.by(() => {
|
|
112
|
+
const klassStr = cn(klass ?? '');
|
|
113
|
+
// Check for $preset placeholder first
|
|
114
|
+
if (!klassStr.includes('$preset')) {
|
|
115
|
+
// No placeholder - normal merge: variants override direct class
|
|
116
|
+
return cn(klass, mergedVariants?.class ?? '');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Has placeholder - calculate position and inject preset classes
|
|
120
|
+
const parts = klassStr.split('$preset');
|
|
121
|
+
|
|
122
|
+
// Only keep the last $preset placeholder
|
|
123
|
+
const beforeLastPlaceholder = parts.slice(0, -1).join('');
|
|
124
|
+
const afterLastPlaceholder = parts[parts.length - 1];
|
|
125
|
+
|
|
126
|
+
// Merge: before + preset + variants + after
|
|
127
|
+
return cn(
|
|
128
|
+
beforeLastPlaceholder,
|
|
129
|
+
presetClassString,
|
|
130
|
+
mergedVariants?.class ?? '',
|
|
131
|
+
afterLastPlaceholder
|
|
132
|
+
);
|
|
133
|
+
});
|
|
99
134
|
|
|
100
135
|
const _base = $derived(base ?? preset?.base);
|
|
101
136
|
const _as = $derived(as ?? preset?.as);
|
|
@@ -122,7 +157,7 @@
|
|
|
122
157
|
if (isSnippet)
|
|
123
158
|
return {
|
|
124
159
|
component: SnippetRenderer,
|
|
125
|
-
props: { snippet: snippet, class: _klass, as: _as, children, ..._restProps }
|
|
160
|
+
props: { snippet: snippet, class: _klass, as: _as, children: childrenProp, ..._restProps }
|
|
126
161
|
};
|
|
127
162
|
|
|
128
163
|
return {
|
|
@@ -131,9 +166,6 @@
|
|
|
131
166
|
};
|
|
132
167
|
}) as { component: Component; props: Record<string, any> };
|
|
133
168
|
|
|
134
|
-
/**
|
|
135
|
-
* Resolve variant definition to props
|
|
136
|
-
*/
|
|
137
169
|
function resolveVariants(
|
|
138
170
|
def: VariantDefinition<any>,
|
|
139
171
|
bond: Bond | null | undefined,
|
|
@@ -144,6 +176,18 @@
|
|
|
144
176
|
// Merge props with defaults
|
|
145
177
|
const finalProps = { ...defaults, ...props };
|
|
146
178
|
|
|
179
|
+
// Create cache key from final props (only variant-related props)
|
|
180
|
+
const variantKeys = variantMap ? Object.keys(variantMap) : [];
|
|
181
|
+
const relevantProps = Object.fromEntries(
|
|
182
|
+
Object.entries(finalProps).filter(([key]) => variantKeys.includes(key))
|
|
183
|
+
);
|
|
184
|
+
const cacheKey = JSON.stringify({ relevantProps, baseClass, compounds });
|
|
185
|
+
|
|
186
|
+
// Check cache
|
|
187
|
+
if (variantCache.has(cacheKey)) {
|
|
188
|
+
return variantCache.get(cacheKey)!;
|
|
189
|
+
}
|
|
190
|
+
|
|
147
191
|
const classes: ClassValue[] = [];
|
|
148
192
|
const attributes: Record<string, any> = {};
|
|
149
193
|
|
|
@@ -193,13 +237,25 @@
|
|
|
193
237
|
}
|
|
194
238
|
}
|
|
195
239
|
|
|
196
|
-
|
|
240
|
+
const result = {
|
|
197
241
|
class: classes,
|
|
198
242
|
...attributes
|
|
199
243
|
};
|
|
244
|
+
|
|
245
|
+
// Store in cache (limit cache size to prevent memory leaks)
|
|
246
|
+
if (variantCache.size > 100) {
|
|
247
|
+
// Clear oldest entry (first in Map)
|
|
248
|
+
const firstKey = variantCache.keys().next().value;
|
|
249
|
+
if (firstKey) variantCache.delete(firstKey);
|
|
250
|
+
}
|
|
251
|
+
variantCache.set(cacheKey, result);
|
|
252
|
+
|
|
253
|
+
return result;
|
|
200
254
|
}
|
|
201
255
|
</script>
|
|
202
256
|
|
|
203
257
|
<renderer.component {...renderer.props}>
|
|
204
|
-
{
|
|
258
|
+
{#snippet children(args: any)}
|
|
259
|
+
{@render (childrenProp as any)?.(args)}
|
|
260
|
+
{/snippet}
|
|
205
261
|
</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: {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
let { snippet, ...restProps } = $props();
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
{@render snippet?.({ ...restProps })}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let { snippet, ...restProps } = $props();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
{@render snippet?.({ ...restProps })}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import AvatarCmp from './avatar.svelte';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
/>
|
|
24
|
-
</div>
|
|
25
|
-
{/snippet}
|
|
26
|
-
</Root>
|
|
27
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import AvatarCmp from './avatar.svelte';
|
|
4
|
+
import CalendarRegularIcon from '../../icons/icon-arrow-down.svelte';
|
|
5
|
+
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
title: 'ATOMS/Avatar'
|
|
8
|
+
});
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<Story name="Avatar">
|
|
12
|
+
<div class="flex h-full w-full items-center justify-center gap-4">
|
|
13
|
+
<AvatarCmp alt="Abdelhalim Riache" />
|
|
14
|
+
|
|
15
|
+
<AvatarCmp src={CalendarRegularIcon} alt="Abdelhalim Riache" />
|
|
16
|
+
|
|
17
|
+
<AvatarCmp
|
|
18
|
+
src="https://sevennaturalwonders.org/wp-content/uploads/2023/12/1-Mount-Fuji.jpg"
|
|
19
|
+
alt="Mount Fuji"
|
|
20
|
+
/>
|
|
21
|
+
</div>
|
|
22
|
+
</Story>
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
{#snippet children({ args })}
|
|
14
|
-
<BadgeModule>Badge</BadgeModule>
|
|
15
|
-
{/snippet}
|
|
16
|
-
</Root>
|
|
17
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Badge as BadgeModule } from '.';
|
|
4
|
+
|
|
5
|
+
const { Story } = defineMeta({
|
|
6
|
+
title: 'ATOMS/Badge'
|
|
7
|
+
});
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Story name="Badge">
|
|
11
|
+
<BadgeModule>Badge</BadgeModule>
|
|
12
|
+
</Story>
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { HtmlAtom } from '../atom';
|
|
3
|
-
import type { BadgeProps } from './types';
|
|
4
|
-
|
|
5
|
-
let { class: klass = '', as = 'span', children = undefined, ...restProps }: BadgeProps = $props();
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<HtmlAtom
|
|
9
|
-
preset="badge"
|
|
10
|
-
class={[
|
|
11
|
-
'bg-foreground/10 border-border text-foreground inline-flex h-auto items-center rounded-full px-2.5 py-0.5 text-xs font-medium',
|
|
12
|
-
'$preset',
|
|
13
|
-
klass
|
|
14
|
-
]}
|
|
15
|
-
{as}
|
|
16
|
-
{...restProps}
|
|
17
|
-
>
|
|
18
|
-
{@render children?.()}
|
|
19
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { HtmlAtom } from '../atom';
|
|
3
|
+
import type { BadgeProps } from './types';
|
|
4
|
+
|
|
5
|
+
let { class: klass = '', as = 'span', children = undefined, ...restProps }: BadgeProps = $props();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<HtmlAtom
|
|
9
|
+
preset="badge"
|
|
10
|
+
class={[
|
|
11
|
+
'bg-foreground/10 border-border text-foreground inline-flex h-auto w-fit items-center rounded-full px-2.5 py-0.5 text-xs font-medium',
|
|
12
|
+
'$preset',
|
|
13
|
+
klass
|
|
14
|
+
]}
|
|
15
|
+
{as}
|
|
16
|
+
{...restProps}
|
|
17
|
+
>
|
|
18
|
+
{@render children?.()}
|
|
19
|
+
</HtmlAtom>
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<BreadcrumbModule.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<BreadcrumbModule.Item href="/vehicles">Vehicles</BreadcrumbModule.Item>
|
|
18
|
-
</BreadcrumbModule.Root>
|
|
19
|
-
{/snippet}
|
|
20
|
-
</Root>
|
|
21
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Breadcrumb as BreadcrumbModule } from '.';
|
|
4
|
+
|
|
5
|
+
const { Story } = defineMeta({
|
|
6
|
+
title: 'ATOMS/Breadcrumb'
|
|
7
|
+
});
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Story name="Breadcrumb">
|
|
11
|
+
<BreadcrumbModule.Root>
|
|
12
|
+
<BreadcrumbModule.Item href="/">Home</BreadcrumbModule.Item>
|
|
13
|
+
<BreadcrumbModule.Separator>/</BreadcrumbModule.Separator>
|
|
14
|
+
<BreadcrumbModule.Item href="/vehicles">Vehicles</BreadcrumbModule.Item>
|
|
15
|
+
</BreadcrumbModule.Root>
|
|
16
|
+
</Story>
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
<script module>
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import Root from '../root/root.svelte';
|
|
4
3
|
import ButtonCmp from './button.svelte';
|
|
5
|
-
import { defineVariants } from '../../utils/variant';
|
|
6
4
|
|
|
7
5
|
const { Story } = defineMeta({
|
|
8
6
|
title: 'ATOMS/Button',
|
|
@@ -20,41 +18,10 @@
|
|
|
20
18
|
</script>
|
|
21
19
|
|
|
22
20
|
<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
21
|
</script>
|
|
53
22
|
|
|
54
23
|
<Story name="Button">
|
|
55
24
|
{#snippet template(args)}
|
|
56
|
-
<
|
|
57
|
-
<ButtonCmp {variants} {...args}>Clicke me</ButtonCmp>
|
|
58
|
-
</Root>
|
|
25
|
+
<ButtonCmp {...args}>Click me</ButtonCmp>
|
|
59
26
|
{/snippet}
|
|
60
27
|
</Story>
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { backInOut } from 'svelte/easing';
|
|
3
|
-
import CalendarDay from './calendar-day.svelte';
|
|
4
|
-
import { CalendarBond } from './bond.svelte';
|
|
5
|
-
import { cn } from '../../utils';
|
|
6
|
-
import { HtmlAtom } from '../atom';
|
|
7
|
-
|
|
8
|
-
const calendarBond = CalendarBond.get();
|
|
9
|
-
|
|
10
|
-
const currentMonth = $derived(calendarBond?.state.props.currentMonth);
|
|
11
|
-
|
|
12
|
-
let {
|
|
13
|
-
class: klass = '',
|
|
14
|
-
weekday,
|
|
15
|
-
preset = 'calendar.body',
|
|
16
|
-
children = undefined,
|
|
17
|
-
...restProps
|
|
18
|
-
} = $props();
|
|
19
|
-
|
|
20
|
-
const bodyProps = $derived({
|
|
21
|
-
...calendarBond?.body(),
|
|
22
|
-
...restProps
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// const generator = function (pivot: Date, start: Date, end?: Date) {
|
|
26
|
-
// const firstDay = new Date(pivot.getFullYear(), pivot.getMonth(), 1).getDay();
|
|
27
|
-
// const lastMonthDaysCount = monthDays(pivot.getMonth() - 1, pivot.getFullYear());
|
|
28
|
-
// const sample = new Date(
|
|
29
|
-
// pivot.getFullYear(),
|
|
30
|
-
// pivot.getMonth() - 1,
|
|
31
|
-
// lastMonthDaysCount - firstDay
|
|
32
|
-
// );
|
|
33
|
-
|
|
34
|
-
// const array = [];
|
|
35
|
-
// let next = false,
|
|
36
|
-
// prec = false;
|
|
37
|
-
|
|
38
|
-
// for (let index = 0; index < 42; index++) {
|
|
39
|
-
// sample.setDate(sample.getDate() + 1);
|
|
40
|
-
|
|
41
|
-
// prec = pivot.getMonth() > sample.getMonth() || pivot.getFullYear() > sample.getFullYear();
|
|
42
|
-
// next =
|
|
43
|
-
// (pivot.getMonth() < sample.getMonth() && pivot.getFullYear() === sample.getFullYear()) ||
|
|
44
|
-
// (pivot.getMonth() > sample.getMonth() && pivot.getFullYear() < sample.getFullYear());
|
|
45
|
-
|
|
46
|
-
// array.push({
|
|
47
|
-
// id: sample.getTime(),
|
|
48
|
-
// date: sample.getDate(),
|
|
49
|
-
// offmonth: next || prec,
|
|
50
|
-
// next,
|
|
51
|
-
// prec,
|
|
52
|
-
// today: isToday(sample),
|
|
53
|
-
// week: Math.floor(index / 7),
|
|
54
|
-
// month: sample.getMonth(),
|
|
55
|
-
// disabled: false,
|
|
56
|
-
// weekend: sample.getDay() == 0,
|
|
57
|
-
// name: format(sample, 'iiiii'),
|
|
58
|
-
// selected: start?.getTime() === sample.getTime()
|
|
59
|
-
// });
|
|
60
|
-
// }
|
|
61
|
-
|
|
62
|
-
// return array;
|
|
63
|
-
// };
|
|
64
|
-
|
|
65
|
-
// const days = $derived(
|
|
66
|
-
// generator(
|
|
67
|
-
// context_calendar.derived.data.pivote,
|
|
68
|
-
// context_calendar.derived.data.start ?? new Date(),
|
|
69
|
-
// context_calendar.derived.data.end
|
|
70
|
-
// )
|
|
71
|
-
// );
|
|
72
|
-
|
|
73
|
-
function monthDays(month: number, year = 2020) {
|
|
74
|
-
return new Date(year, month + 1, 0).getDate();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function scle(node: HTMLElement, { delay = 0, duration = 400, easing = backInOut }) {
|
|
78
|
-
return {
|
|
79
|
-
delay,
|
|
80
|
-
duration,
|
|
81
|
-
easing,
|
|
82
|
-
css: (_, u) => {
|
|
83
|
-
return `transform: scale(${u})`;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
</script>
|
|
88
|
-
|
|
89
|
-
<HtmlAtom
|
|
90
|
-
class={cn('col-span-full grid h-full w-full grid-cols-subgrid', klass)}
|
|
91
|
-
{preset}
|
|
92
|
-
{...bodyProps}
|
|
93
|
-
>
|
|
94
|
-
{#each currentMonth?.days ?? [] as day (day.id)}
|
|
95
|
-
{#if children}
|
|
96
|
-
{@render children?.({ day })}
|
|
97
|
-
{:else}
|
|
98
|
-
<CalendarDay
|
|
99
|
-
{day}
|
|
100
|
-
onclick={() => {
|
|
101
|
-
console.log('day clicked', day.date);
|
|
102
|
-
calendarBond?.state.selectStart(new Date(day.date));
|
|
103
|
-
}}
|
|
104
|
-
/>
|
|
105
|
-
{/if}
|
|
106
|
-
{/each}
|
|
107
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { backInOut } from 'svelte/easing';
|
|
3
|
+
import CalendarDay from './calendar-day.svelte';
|
|
4
|
+
import { CalendarBond } from './bond.svelte';
|
|
5
|
+
import { cn } from '../../utils';
|
|
6
|
+
import { HtmlAtom } from '../atom';
|
|
7
|
+
|
|
8
|
+
const calendarBond = CalendarBond.get();
|
|
9
|
+
|
|
10
|
+
const currentMonth = $derived(calendarBond?.state.props.currentMonth);
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
class: klass = '',
|
|
14
|
+
weekday,
|
|
15
|
+
preset = 'calendar.body',
|
|
16
|
+
children = undefined,
|
|
17
|
+
...restProps
|
|
18
|
+
} = $props();
|
|
19
|
+
|
|
20
|
+
const bodyProps = $derived({
|
|
21
|
+
...calendarBond?.body(),
|
|
22
|
+
...restProps
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// const generator = function (pivot: Date, start: Date, end?: Date) {
|
|
26
|
+
// const firstDay = new Date(pivot.getFullYear(), pivot.getMonth(), 1).getDay();
|
|
27
|
+
// const lastMonthDaysCount = monthDays(pivot.getMonth() - 1, pivot.getFullYear());
|
|
28
|
+
// const sample = new Date(
|
|
29
|
+
// pivot.getFullYear(),
|
|
30
|
+
// pivot.getMonth() - 1,
|
|
31
|
+
// lastMonthDaysCount - firstDay
|
|
32
|
+
// );
|
|
33
|
+
|
|
34
|
+
// const array = [];
|
|
35
|
+
// let next = false,
|
|
36
|
+
// prec = false;
|
|
37
|
+
|
|
38
|
+
// for (let index = 0; index < 42; index++) {
|
|
39
|
+
// sample.setDate(sample.getDate() + 1);
|
|
40
|
+
|
|
41
|
+
// prec = pivot.getMonth() > sample.getMonth() || pivot.getFullYear() > sample.getFullYear();
|
|
42
|
+
// next =
|
|
43
|
+
// (pivot.getMonth() < sample.getMonth() && pivot.getFullYear() === sample.getFullYear()) ||
|
|
44
|
+
// (pivot.getMonth() > sample.getMonth() && pivot.getFullYear() < sample.getFullYear());
|
|
45
|
+
|
|
46
|
+
// array.push({
|
|
47
|
+
// id: sample.getTime(),
|
|
48
|
+
// date: sample.getDate(),
|
|
49
|
+
// offmonth: next || prec,
|
|
50
|
+
// next,
|
|
51
|
+
// prec,
|
|
52
|
+
// today: isToday(sample),
|
|
53
|
+
// week: Math.floor(index / 7),
|
|
54
|
+
// month: sample.getMonth(),
|
|
55
|
+
// disabled: false,
|
|
56
|
+
// weekend: sample.getDay() == 0,
|
|
57
|
+
// name: format(sample, 'iiiii'),
|
|
58
|
+
// selected: start?.getTime() === sample.getTime()
|
|
59
|
+
// });
|
|
60
|
+
// }
|
|
61
|
+
|
|
62
|
+
// return array;
|
|
63
|
+
// };
|
|
64
|
+
|
|
65
|
+
// const days = $derived(
|
|
66
|
+
// generator(
|
|
67
|
+
// context_calendar.derived.data.pivote,
|
|
68
|
+
// context_calendar.derived.data.start ?? new Date(),
|
|
69
|
+
// context_calendar.derived.data.end
|
|
70
|
+
// )
|
|
71
|
+
// );
|
|
72
|
+
|
|
73
|
+
function monthDays(month: number, year = 2020) {
|
|
74
|
+
return new Date(year, month + 1, 0).getDate();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function scle(node: HTMLElement, { delay = 0, duration = 400, easing = backInOut }) {
|
|
78
|
+
return {
|
|
79
|
+
delay,
|
|
80
|
+
duration,
|
|
81
|
+
easing,
|
|
82
|
+
css: (_, u) => {
|
|
83
|
+
return `transform: scale(${u})`;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<HtmlAtom
|
|
90
|
+
class={cn('col-span-full grid h-full w-full grid-cols-subgrid', klass)}
|
|
91
|
+
{preset}
|
|
92
|
+
{...bodyProps}
|
|
93
|
+
>
|
|
94
|
+
{#each currentMonth?.days ?? [] as day (day.id)}
|
|
95
|
+
{#if children}
|
|
96
|
+
{@render children?.({ day })}
|
|
97
|
+
{:else}
|
|
98
|
+
<CalendarDay
|
|
99
|
+
{day}
|
|
100
|
+
onclick={() => {
|
|
101
|
+
console.log('day clicked', day.date);
|
|
102
|
+
calendarBond?.state.selectStart(new Date(day.date));
|
|
103
|
+
}}
|
|
104
|
+
/>
|
|
105
|
+
{/if}
|
|
106
|
+
{/each}
|
|
107
|
+
</HtmlAtom>
|