svelora 3.0.5 → 3.0.7
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/dist/BentoGrid/BentoCard.svelte +45 -0
- package/dist/BentoGrid/BentoCard.svelte.d.ts +4 -0
- package/dist/BentoGrid/BentoGrid.svelte +9 -0
- package/dist/BentoGrid/BentoGrid.svelte.d.ts +4 -0
- package/dist/BentoGrid/bento-grid.types.d.ts +47 -0
- package/dist/BentoGrid/bento-grid.types.js +1 -0
- package/dist/BentoGrid/bento-grid.variants.d.ts +30 -0
- package/dist/BentoGrid/bento-grid.variants.js +16 -0
- package/dist/BentoGrid/index.d.ts +5 -0
- package/dist/BentoGrid/index.js +5 -0
- package/dist/Chart/Chart.svelte +47 -0
- package/dist/Chart/Chart.svelte.d.ts +4 -0
- package/dist/Chart/chart.types.d.ts +20 -0
- package/dist/Chart/chart.types.js +1 -0
- package/dist/Chart/chart.variants.d.ts +3 -0
- package/dist/Chart/chart.variants.js +4 -0
- package/dist/Chart/index.d.ts +4 -0
- package/dist/Chart/index.js +4 -0
- package/dist/Chat/ChatBubble.svelte +30 -0
- package/dist/Chat/ChatBubble.svelte.d.ts +4 -0
- package/dist/Chat/ChatInput.svelte +50 -0
- package/dist/Chat/ChatInput.svelte.d.ts +4 -0
- package/dist/Chat/ChatMessage.svelte +15 -0
- package/dist/Chat/ChatMessage.svelte.d.ts +4 -0
- package/dist/Chat/chat.types.d.ts +63 -0
- package/dist/Chat/chat.types.js +1 -0
- package/dist/Chat/chat.variants.d.ts +117 -0
- package/dist/Chat/chat.variants.js +47 -0
- package/dist/Chat/index.d.ts +6 -0
- package/dist/Chat/index.js +6 -0
- package/dist/ColorPicker/ColorPicker.svelte +109 -0
- package/dist/ColorPicker/ColorPicker.svelte.d.ts +4 -0
- package/dist/ColorPicker/color-picker.types.d.ts +26 -0
- package/dist/ColorPicker/color-picker.types.js +1 -0
- package/dist/ColorPicker/color-picker.variants.d.ts +69 -0
- package/dist/ColorPicker/color-picker.variants.js +13 -0
- package/dist/ColorPicker/index.d.ts +4 -0
- package/dist/ColorPicker/index.js +4 -0
- package/dist/DateRangePicker/DateRangePicker.svelte +59 -0
- package/dist/DateRangePicker/DateRangePicker.svelte.d.ts +4 -0
- package/dist/DateRangePicker/date-range-picker.types.d.ts +34 -0
- package/dist/DateRangePicker/date-range-picker.types.js +1 -0
- package/dist/DateRangePicker/date-range-picker.variants.d.ts +39 -0
- package/dist/DateRangePicker/date-range-picker.variants.js +20 -0
- package/dist/DateRangePicker/index.d.ts +4 -0
- package/dist/DateRangePicker/index.js +4 -0
- package/dist/Fonts/fonts.js +3 -1
- package/dist/Link/Link.context-harness.svelte +8 -0
- package/dist/Link/Link.context-harness.svelte.d.ts +7 -0
- package/dist/Link/Link.svelte +57 -30
- package/dist/Link/index.d.ts +2 -0
- package/dist/Link/index.js +1 -0
- package/dist/Link/location-context.d.ts +4 -0
- package/dist/Link/location-context.js +1 -0
- package/dist/List/List.svelte +14 -0
- package/dist/List/List.svelte.d.ts +4 -0
- package/dist/List/ListItem.svelte +64 -0
- package/dist/List/ListItem.svelte.d.ts +4 -0
- package/dist/List/index.d.ts +5 -0
- package/dist/List/index.js +5 -0
- package/dist/List/list.types.d.ts +62 -0
- package/dist/List/list.types.js +1 -0
- package/dist/List/list.variants.d.ts +99 -0
- package/dist/List/list.variants.js +42 -0
- package/dist/Marquee/Marquee.svelte +50 -0
- package/dist/Marquee/Marquee.svelte.d.ts +4 -0
- package/dist/Marquee/index.d.ts +4 -0
- package/dist/Marquee/index.js +4 -0
- package/dist/Marquee/marquee.types.d.ts +38 -0
- package/dist/Marquee/marquee.types.js +1 -0
- package/dist/Marquee/marquee.variants.d.ts +78 -0
- package/dist/Marquee/marquee.variants.js +28 -0
- package/dist/Menu/Menu.svelte +134 -0
- package/dist/Menu/Menu.svelte.d.ts +4 -0
- package/dist/Menu/index.d.ts +4 -0
- package/dist/Menu/index.js +4 -0
- package/dist/Menu/menu.types.d.ts +82 -0
- package/dist/Menu/menu.types.js +1 -0
- package/dist/Menu/menu.variants.d.ts +46 -0
- package/dist/Menu/menu.variants.js +32 -0
- package/dist/NumberTicker/NumberTicker.svelte +59 -0
- package/dist/NumberTicker/NumberTicker.svelte.d.ts +4 -0
- package/dist/NumberTicker/index.d.ts +4 -0
- package/dist/NumberTicker/index.js +4 -0
- package/dist/NumberTicker/number-ticker.types.d.ts +26 -0
- package/dist/NumberTicker/number-ticker.types.js +1 -0
- package/dist/NumberTicker/number-ticker.variants.d.ts +27 -0
- package/dist/NumberTicker/number-ticker.variants.js +6 -0
- package/dist/PasswordInput/PasswordInput.svelte +74 -0
- package/dist/PasswordInput/PasswordInput.svelte.d.ts +4 -0
- package/dist/PasswordInput/index.d.ts +4 -0
- package/dist/PasswordInput/index.js +4 -0
- package/dist/PasswordInput/password-input.types.d.ts +18 -0
- package/dist/PasswordInput/password-input.types.js +1 -0
- package/dist/PasswordInput/password-input.variants.d.ts +57 -0
- package/dist/PasswordInput/password-input.variants.js +11 -0
- package/dist/Prose/Prose.svelte +13 -0
- package/dist/Prose/Prose.svelte.d.ts +4 -0
- package/dist/Prose/index.d.ts +4 -0
- package/dist/Prose/index.js +4 -0
- package/dist/Prose/prose.types.d.ts +22 -0
- package/dist/Prose/prose.types.js +1 -0
- package/dist/Prose/prose.variants.d.ts +45 -0
- package/dist/Prose/prose.variants.js +45 -0
- package/dist/Rating/Rating.svelte +93 -0
- package/dist/Rating/Rating.svelte.d.ts +4 -0
- package/dist/Rating/index.d.ts +4 -0
- package/dist/Rating/index.js +4 -0
- package/dist/Rating/rating.types.d.ts +59 -0
- package/dist/Rating/rating.types.js +1 -0
- package/dist/Rating/rating.variants.d.ts +93 -0
- package/dist/Rating/rating.variants.js +32 -0
- package/dist/Resizable/Resizable.svelte +9 -0
- package/dist/Resizable/Resizable.svelte.d.ts +4 -0
- package/dist/Resizable/index.d.ts +4 -0
- package/dist/Resizable/index.js +4 -0
- package/dist/Resizable/resizable.types.d.ts +18 -0
- package/dist/Resizable/resizable.types.js +1 -0
- package/dist/Resizable/resizable.variants.d.ts +48 -0
- package/dist/Resizable/resizable.variants.js +17 -0
- package/dist/ScrollArea/ScrollArea.svelte +54 -0
- package/dist/ScrollArea/ScrollArea.svelte.d.ts +4 -0
- package/dist/ScrollArea/index.d.ts +4 -0
- package/dist/ScrollArea/index.js +4 -0
- package/dist/ScrollArea/scroll-area.types.d.ts +27 -0
- package/dist/ScrollArea/scroll-area.types.js +1 -0
- package/dist/ScrollArea/scroll-area.variants.d.ts +45 -0
- package/dist/ScrollArea/scroll-area.variants.js +27 -0
- package/dist/SelectMenu/SelectMenu.svelte +46 -14
- package/dist/Sidebar/Sidebar.svelte +30 -0
- package/dist/Sidebar/Sidebar.svelte.d.ts +4 -0
- package/dist/Sidebar/index.d.ts +4 -0
- package/dist/Sidebar/index.js +4 -0
- package/dist/Sidebar/sidebar.types.d.ts +31 -0
- package/dist/Sidebar/sidebar.types.js +1 -0
- package/dist/Sidebar/sidebar.variants.d.ts +69 -0
- package/dist/Sidebar/sidebar.variants.js +23 -0
- package/dist/Spotlight/Spotlight.svelte +31 -0
- package/dist/Spotlight/Spotlight.svelte.d.ts +4 -0
- package/dist/Spotlight/index.d.ts +4 -0
- package/dist/Spotlight/index.js +4 -0
- package/dist/Spotlight/spotlight.types.d.ts +22 -0
- package/dist/Spotlight/spotlight.types.js +1 -0
- package/dist/Spotlight/spotlight.variants.d.ts +39 -0
- package/dist/Spotlight/spotlight.variants.js +8 -0
- package/dist/Stepper/Stepper.svelte +12 -9
- package/dist/TagsInput/TagsInput.svelte +100 -0
- package/dist/TagsInput/TagsInput.svelte.d.ts +4 -0
- package/dist/TagsInput/index.d.ts +4 -0
- package/dist/TagsInput/index.js +4 -0
- package/dist/TagsInput/tags-input.types.d.ts +32 -0
- package/dist/TagsInput/tags-input.types.js +1 -0
- package/dist/TagsInput/tags-input.variants.d.ts +45 -0
- package/dist/TagsInput/tags-input.variants.js +22 -0
- package/dist/TreeView/TreeView.svelte +95 -0
- package/dist/TreeView/TreeView.svelte.d.ts +4 -0
- package/dist/TreeView/index.d.ts +4 -0
- package/dist/TreeView/index.js +4 -0
- package/dist/TreeView/tree-view.types.d.ts +68 -0
- package/dist/TreeView/tree-view.types.js +1 -0
- package/dist/TreeView/tree-view.variants.d.ts +69 -0
- package/dist/TreeView/tree-view.variants.js +30 -0
- package/dist/docs/navigation.js +162 -0
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/useDebouncedState.svelte.d.ts +30 -0
- package/dist/hooks/useDebouncedState.svelte.js +45 -0
- package/dist/hooks/useEventListener.svelte.d.ts +30 -0
- package/dist/hooks/useEventListener.svelte.js +16 -0
- package/dist/hooks/useFocusTrap.svelte.d.ts +42 -0
- package/dist/hooks/useFocusTrap.svelte.js +87 -0
- package/dist/hooks/useIntersectionObserver.svelte.d.ts +30 -0
- package/dist/hooks/useIntersectionObserver.svelte.js +46 -0
- package/dist/hooks/useLocalStorage.svelte.d.ts +39 -0
- package/dist/hooks/useLocalStorage.svelte.js +73 -0
- package/dist/hooks/useResizeObserver.svelte.d.ts +50 -0
- package/dist/hooks/useResizeObserver.svelte.js +71 -0
- package/dist/hooks/useScrollLock.svelte.d.ts +28 -0
- package/dist/hooks/useScrollLock.svelte.js +79 -0
- package/dist/hooks/useThrottle.svelte.d.ts +37 -0
- package/dist/hooks/useThrottle.svelte.js +72 -0
- package/dist/hooks/useTimers.svelte.d.ts +62 -0
- package/dist/hooks/useTimers.svelte.js +90 -0
- package/dist/hooks/utils.d.ts +1 -0
- package/dist/hooks/utils.js +3 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +18 -0
- package/dist/mcp/svelora-docs.data.json +59 -5
- package/package.json +8 -6
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import Icon from "../Icon/Icon.svelte";
|
|
3
|
+
import Button from "../Button/Button.svelte";
|
|
4
|
+
import { bentoGridVariants } from "./bento-grid.variants.js";
|
|
5
|
+
let { name, description, icon, href, cta = "Learn more", class: className, background, actionSnippet, ...restProps } = $props();
|
|
6
|
+
let styles = $derived(bentoGridVariants());
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<div class={twMerge(styles.cardBase(), className)} {...restProps}>
|
|
10
|
+
<div class={styles.cardBackground()}>
|
|
11
|
+
{#if background}
|
|
12
|
+
{@render background()}
|
|
13
|
+
{/if}
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<!-- Push content up slightly on hover by adjusting group styles or locally -->
|
|
17
|
+
<div class={twMerge(styles.cardContent(), href && 'group-hover:-translate-y-4')}>
|
|
18
|
+
{#if icon}
|
|
19
|
+
<div class={styles.cardIconWrapper()}>
|
|
20
|
+
<Icon {name} class="w-6 h-6" />
|
|
21
|
+
</div>
|
|
22
|
+
{/if}
|
|
23
|
+
|
|
24
|
+
<h3 class={styles.cardTitle()}>{name}</h3>
|
|
25
|
+
|
|
26
|
+
{#if description}
|
|
27
|
+
<p class={styles.cardDescription()}>{description}</p>
|
|
28
|
+
{/if}
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
{#if href || actionSnippet}
|
|
32
|
+
<div class={twMerge(styles.cardAction(), !href && !actionSnippet && 'hidden')}>
|
|
33
|
+
{#if actionSnippet}
|
|
34
|
+
{@render actionSnippet()}
|
|
35
|
+
{:else if href}
|
|
36
|
+
<Button {href} variant="ghost" size="sm" class="pl-0 hover:bg-transparent">
|
|
37
|
+
{cta}
|
|
38
|
+
{#snippet trailingSlot()}
|
|
39
|
+
<Icon name="lucide:arrow-right" class="w-4 h-4 ml-1" />
|
|
40
|
+
{/snippet}
|
|
41
|
+
</Button>
|
|
42
|
+
{/if}
|
|
43
|
+
</div>
|
|
44
|
+
{/if}
|
|
45
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { bentoGridVariants } from "./bento-grid.variants.js";
|
|
3
|
+
let { class: className, children, ...restProps } = $props();
|
|
4
|
+
let styles = $derived(bentoGridVariants());
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class={twMerge(styles.gridBase(), className)} {...restProps}>
|
|
8
|
+
{@render children?.()}
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
export interface BentoGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/**
|
|
5
|
+
* Additional CSS classes.
|
|
6
|
+
*/
|
|
7
|
+
class?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The cards to render inside the grid.
|
|
10
|
+
*/
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
}
|
|
13
|
+
export interface BentoCardProps extends HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
/**
|
|
15
|
+
* Title of the card.
|
|
16
|
+
*/
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* Description text.
|
|
20
|
+
*/
|
|
21
|
+
description?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Icon name.
|
|
24
|
+
*/
|
|
25
|
+
icon?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The href to navigate to when the call-to-action is clicked.
|
|
28
|
+
*/
|
|
29
|
+
href?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Text for the call-to-action button.
|
|
32
|
+
* @default 'Learn more'
|
|
33
|
+
*/
|
|
34
|
+
cta?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Additional CSS classes. Useful for setting grid column/row spans (e.g. `col-span-2`).
|
|
37
|
+
*/
|
|
38
|
+
class?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Snippet for background visual elements (e.g. gradients, images).
|
|
41
|
+
*/
|
|
42
|
+
background?: Snippet;
|
|
43
|
+
/**
|
|
44
|
+
* Snippet for overriding or extending the action area.
|
|
45
|
+
*/
|
|
46
|
+
actionSnippet?: Snippet;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const bentoGridVariants: import("tailwind-variants").TVReturnType<{}, {
|
|
3
|
+
gridBase: string;
|
|
4
|
+
cardBase: string;
|
|
5
|
+
cardBackground: string;
|
|
6
|
+
cardContent: string;
|
|
7
|
+
cardIconWrapper: string;
|
|
8
|
+
cardTitle: string;
|
|
9
|
+
cardDescription: string;
|
|
10
|
+
cardAction: string;
|
|
11
|
+
}, undefined, {}, {
|
|
12
|
+
gridBase: string;
|
|
13
|
+
cardBase: string;
|
|
14
|
+
cardBackground: string;
|
|
15
|
+
cardContent: string;
|
|
16
|
+
cardIconWrapper: string;
|
|
17
|
+
cardTitle: string;
|
|
18
|
+
cardDescription: string;
|
|
19
|
+
cardAction: string;
|
|
20
|
+
}, import("tailwind-variants").TVReturnType<{}, {
|
|
21
|
+
gridBase: string;
|
|
22
|
+
cardBase: string;
|
|
23
|
+
cardBackground: string;
|
|
24
|
+
cardContent: string;
|
|
25
|
+
cardIconWrapper: string;
|
|
26
|
+
cardTitle: string;
|
|
27
|
+
cardDescription: string;
|
|
28
|
+
cardAction: string;
|
|
29
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
30
|
+
export type BentoGridVariantProps = VariantProps<typeof bentoGridVariants>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const bentoGridVariants = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
gridBase: 'grid grid-cols-1 md:grid-cols-3 gap-4 max-w-7xl mx-auto w-full',
|
|
5
|
+
cardBase: 'group relative flex flex-col justify-between overflow-hidden rounded-xl bg-surface-50 dark:bg-surface-900 border border-outline-variant transition-all hover:shadow-md dark:hover:shadow-surface-800/50',
|
|
6
|
+
cardBackground: 'absolute inset-0 transition-all duration-300 pointer-events-none',
|
|
7
|
+
cardContent: 'pointer-events-none z-10 flex transform-gpu flex-col gap-1 p-6 transition-all duration-300',
|
|
8
|
+
cardIconWrapper: 'mb-2 w-10 h-10 flex items-center justify-center rounded-lg bg-primary-100 dark:bg-primary-900/30 text-primary-600 dark:text-primary-400',
|
|
9
|
+
cardTitle: 'text-lg font-semibold text-surface-900 dark:text-surface-50',
|
|
10
|
+
cardDescription: 'text-sm text-surface-500 dark:text-surface-400',
|
|
11
|
+
cardAction: 'pointer-events-auto absolute bottom-0 left-0 w-full p-6 opacity-0 translate-y-4 transition-all duration-300 group-hover:opacity-100 group-hover:translate-y-0'
|
|
12
|
+
},
|
|
13
|
+
variants: {
|
|
14
|
+
// Variants can be added if we want different styles of grids
|
|
15
|
+
}
|
|
16
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
import { Chart as ChartJS, Title, Tooltip, Legend, BarElement, CategoryScale, LinearScale, PointElement, LineElement, ArcElement, RadialLinearScale, Filler } from "chart.js";
|
|
4
|
+
import { Bar, Line, Pie, Doughnut, Radar, PolarArea, Scatter, Bubble } from "svelte-chartjs";
|
|
5
|
+
import { chartVariants } from "./chart.variants.js";
|
|
6
|
+
// Register all common elements
|
|
7
|
+
ChartJS.register(Title, Tooltip, Legend, BarElement, CategoryScale, LinearScale, PointElement, LineElement, ArcElement, RadialLinearScale, Filler);
|
|
8
|
+
// Set default styling to match Tailwind/Svelora theme
|
|
9
|
+
ChartJS.defaults.color = "currentColor";
|
|
10
|
+
ChartJS.defaults.font.family = "inherit";
|
|
11
|
+
ChartJS.defaults.plugins.tooltip.backgroundColor = "rgba(0, 0, 0, 0.8)";
|
|
12
|
+
ChartJS.defaults.plugins.tooltip.titleColor = "#ffffff";
|
|
13
|
+
ChartJS.defaults.plugins.tooltip.bodyColor = "#ffffff";
|
|
14
|
+
ChartJS.defaults.plugins.tooltip.cornerRadius = 6;
|
|
15
|
+
ChartJS.defaults.plugins.tooltip.padding = 10;
|
|
16
|
+
let { type, data, options = {}, class: className, ...restProps } = $props();
|
|
17
|
+
let styles = $derived(chartVariants());
|
|
18
|
+
// Map string types to components
|
|
19
|
+
const components = {
|
|
20
|
+
bar: Bar,
|
|
21
|
+
line: Line,
|
|
22
|
+
pie: Pie,
|
|
23
|
+
doughnut: Doughnut,
|
|
24
|
+
radar: Radar,
|
|
25
|
+
polarArea: PolarArea,
|
|
26
|
+
scatter: Scatter,
|
|
27
|
+
bubble: Bubble
|
|
28
|
+
};
|
|
29
|
+
// Default responsive options
|
|
30
|
+
const defaultOptions = {
|
|
31
|
+
responsive: true,
|
|
32
|
+
maintainAspectRatio: false
|
|
33
|
+
};
|
|
34
|
+
let mergedOptions = $derived({
|
|
35
|
+
...defaultOptions,
|
|
36
|
+
...options
|
|
37
|
+
});
|
|
38
|
+
// We must use "as any" or "as typeof SvelteComponent" because svelte-chartjs types
|
|
39
|
+
// are sometimes tricky with svelte:component in Svelte 5.
|
|
40
|
+
const ChartComponent = $derived(components[type]);
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<div class={twMerge(styles, className)} {...restProps}>
|
|
44
|
+
{#if ChartComponent}
|
|
45
|
+
<ChartComponent data={data as any} options={mergedOptions as any} />
|
|
46
|
+
{/if}
|
|
47
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ChartData, ChartOptions, ChartType } from 'chart.js';
|
|
3
|
+
export interface ChartProps extends Omit<HTMLAttributes<HTMLDivElement>, 'type'> {
|
|
4
|
+
/**
|
|
5
|
+
* Type of the chart.
|
|
6
|
+
*/
|
|
7
|
+
type: ChartType;
|
|
8
|
+
/**
|
|
9
|
+
* The data object for the chart.
|
|
10
|
+
*/
|
|
11
|
+
data: ChartData<ChartType, unknown, unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Configuration options for the chart.
|
|
14
|
+
*/
|
|
15
|
+
options?: ChartOptions<ChartType>;
|
|
16
|
+
/**
|
|
17
|
+
* Additional CSS classes.
|
|
18
|
+
*/
|
|
19
|
+
class?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const chartVariants: import("tailwind-variants").TVReturnType<{} | {} | {}, undefined, "w-full h-full relative", {} | {}, undefined, import("tailwind-variants").TVReturnType<unknown, undefined, "w-full h-full relative", unknown, unknown, undefined>>;
|
|
3
|
+
export type ChartVariantProps = VariantProps<typeof chartVariants>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { setContext } from "svelte";
|
|
3
|
+
import { chatVariants } from "./chat.variants.js";
|
|
4
|
+
let { position = "start", name, time, class: className, avatar, children, ...restProps } = $props();
|
|
5
|
+
let styles = $derived(chatVariants({ position }));
|
|
6
|
+
// Provide position context to child ChatMessage components for proper rounded corners
|
|
7
|
+
setContext("chat-bubble-position", () => position);
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<div class={twMerge(styles.bubbleBase() as string, className as string)} {...restProps}>
|
|
11
|
+
{#if avatar}
|
|
12
|
+
<div class={styles.bubbleAvatar()}>
|
|
13
|
+
{@render avatar()}
|
|
14
|
+
</div>
|
|
15
|
+
{/if}
|
|
16
|
+
|
|
17
|
+
<div class={styles.bubbleContent()}>
|
|
18
|
+
{#if name || time}
|
|
19
|
+
<div class={styles.bubbleHeader()}>
|
|
20
|
+
{#if name}
|
|
21
|
+
<span class={styles.bubbleName()}>{name}</span>
|
|
22
|
+
{/if}
|
|
23
|
+
{#if time}
|
|
24
|
+
<span class={styles.bubbleTime()}>{time}</span>
|
|
25
|
+
{/if}
|
|
26
|
+
</div>
|
|
27
|
+
{/if}
|
|
28
|
+
{@render children?.()}
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { chatVariants } from "./chat.variants.js";
|
|
3
|
+
let { value = $bindable(""), placeholder = "Type a message...", disabled = false, class: className, leading, trailing, ...restProps } = $props();
|
|
4
|
+
let styles = $derived(chatVariants());
|
|
5
|
+
// Auto-resize textarea function could be added here
|
|
6
|
+
function autoResize(node) {
|
|
7
|
+
function resize() {
|
|
8
|
+
node.style.height = "auto";
|
|
9
|
+
node.style.height = node.scrollHeight + "px";
|
|
10
|
+
}
|
|
11
|
+
node.addEventListener("input", resize);
|
|
12
|
+
// Initial resize
|
|
13
|
+
setTimeout(resize, 0);
|
|
14
|
+
return { destroy() {
|
|
15
|
+
node.removeEventListener("input", resize);
|
|
16
|
+
} };
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<div class={twMerge(styles.inputBase() as string, className as string)} {...restProps}>
|
|
21
|
+
{#if leading}
|
|
22
|
+
<div class={styles.inputActions()}>
|
|
23
|
+
{@render leading()}
|
|
24
|
+
</div>
|
|
25
|
+
{/if}
|
|
26
|
+
|
|
27
|
+
<div class={styles.inputFieldWrapper()}>
|
|
28
|
+
<textarea
|
|
29
|
+
bind:value
|
|
30
|
+
{placeholder}
|
|
31
|
+
{disabled}
|
|
32
|
+
rows="1"
|
|
33
|
+
use:autoResize
|
|
34
|
+
class={styles.inputField()}
|
|
35
|
+
onkeydown={(e) => {
|
|
36
|
+
// If you want Shift+Enter for new line, and Enter to submit:
|
|
37
|
+
// if (e.key === 'Enter' && !e.shiftKey) {
|
|
38
|
+
// e.preventDefault()
|
|
39
|
+
// // Dispatch submit event
|
|
40
|
+
// }
|
|
41
|
+
}}
|
|
42
|
+
></textarea>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
{#if trailing}
|
|
46
|
+
<div class={styles.inputActions()}>
|
|
47
|
+
{@render trailing()}
|
|
48
|
+
</div>
|
|
49
|
+
{/if}
|
|
50
|
+
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { getContext } from "svelte";
|
|
3
|
+
import { chatVariants } from "./chat.variants.js";
|
|
4
|
+
let { variant = "surface", position: propPosition, class: className, children, ...restProps } = $props();
|
|
5
|
+
const getPositionContext = getContext("chat-bubble-position");
|
|
6
|
+
let position = $derived(propPosition ?? (getPositionContext ? getPositionContext() : "start"));
|
|
7
|
+
let styles = $derived(chatVariants({
|
|
8
|
+
variant,
|
|
9
|
+
position
|
|
10
|
+
}));
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div class={twMerge(styles.messageBase() as string, className as string)} {...restProps}>
|
|
14
|
+
{@render children?.()}
|
|
15
|
+
</div>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { ChatVariantProps } from './chat.variants.js';
|
|
4
|
+
export interface ChatBubbleProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* Position of the chat bubble (start for receiver, end for sender).
|
|
7
|
+
* @default 'start'
|
|
8
|
+
*/
|
|
9
|
+
position?: ChatVariantProps['position'];
|
|
10
|
+
/**
|
|
11
|
+
* Name of the sender.
|
|
12
|
+
*/
|
|
13
|
+
name?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Timestamp of the message.
|
|
16
|
+
*/
|
|
17
|
+
time?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Snippet for the avatar element.
|
|
20
|
+
*/
|
|
21
|
+
avatar?: Snippet;
|
|
22
|
+
/**
|
|
23
|
+
* The actual chat messages.
|
|
24
|
+
*/
|
|
25
|
+
children?: Snippet;
|
|
26
|
+
}
|
|
27
|
+
export interface ChatMessageProps extends HTMLAttributes<HTMLDivElement> {
|
|
28
|
+
/**
|
|
29
|
+
* Style variant of the message bubble.
|
|
30
|
+
*/
|
|
31
|
+
variant?: ChatVariantProps['variant'];
|
|
32
|
+
/**
|
|
33
|
+
* Position inheritance (used internally for rounded corners).
|
|
34
|
+
* Automatically inherited from ChatBubble if used within it.
|
|
35
|
+
*/
|
|
36
|
+
position?: ChatVariantProps['position'];
|
|
37
|
+
/**
|
|
38
|
+
* The message text or content.
|
|
39
|
+
*/
|
|
40
|
+
children?: Snippet;
|
|
41
|
+
}
|
|
42
|
+
export interface ChatInputProps extends HTMLAttributes<HTMLDivElement> {
|
|
43
|
+
/**
|
|
44
|
+
* Value of the input field.
|
|
45
|
+
*/
|
|
46
|
+
value?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Placeholder text.
|
|
49
|
+
*/
|
|
50
|
+
placeholder?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the input is disabled.
|
|
53
|
+
*/
|
|
54
|
+
disabled?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Snippet for leading actions (e.g. attachment button).
|
|
57
|
+
*/
|
|
58
|
+
leading?: Snippet;
|
|
59
|
+
/**
|
|
60
|
+
* Snippet for trailing actions (e.g. send button).
|
|
61
|
+
*/
|
|
62
|
+
trailing?: Snippet;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const chatVariants: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
position: {
|
|
4
|
+
start: {
|
|
5
|
+
bubbleBase: string;
|
|
6
|
+
bubbleContent: string;
|
|
7
|
+
bubbleHeader: string;
|
|
8
|
+
messageBase: string;
|
|
9
|
+
};
|
|
10
|
+
end: {
|
|
11
|
+
bubbleBase: string;
|
|
12
|
+
bubbleContent: string;
|
|
13
|
+
bubbleHeader: string;
|
|
14
|
+
messageBase: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
variant: {
|
|
18
|
+
primary: {
|
|
19
|
+
messageBase: string;
|
|
20
|
+
};
|
|
21
|
+
surface: {
|
|
22
|
+
messageBase: string;
|
|
23
|
+
};
|
|
24
|
+
outline: {
|
|
25
|
+
messageBase: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}, {
|
|
29
|
+
bubbleBase: string;
|
|
30
|
+
bubbleAvatar: string;
|
|
31
|
+
bubbleContent: string;
|
|
32
|
+
bubbleHeader: string;
|
|
33
|
+
bubbleName: string;
|
|
34
|
+
bubbleTime: string;
|
|
35
|
+
messageBase: string;
|
|
36
|
+
inputBase: string;
|
|
37
|
+
inputFieldWrapper: string;
|
|
38
|
+
inputField: string;
|
|
39
|
+
inputActions: string;
|
|
40
|
+
}, undefined, {
|
|
41
|
+
position: {
|
|
42
|
+
start: {
|
|
43
|
+
bubbleBase: string;
|
|
44
|
+
bubbleContent: string;
|
|
45
|
+
bubbleHeader: string;
|
|
46
|
+
messageBase: string;
|
|
47
|
+
};
|
|
48
|
+
end: {
|
|
49
|
+
bubbleBase: string;
|
|
50
|
+
bubbleContent: string;
|
|
51
|
+
bubbleHeader: string;
|
|
52
|
+
messageBase: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
variant: {
|
|
56
|
+
primary: {
|
|
57
|
+
messageBase: string;
|
|
58
|
+
};
|
|
59
|
+
surface: {
|
|
60
|
+
messageBase: string;
|
|
61
|
+
};
|
|
62
|
+
outline: {
|
|
63
|
+
messageBase: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}, {
|
|
67
|
+
bubbleBase: string;
|
|
68
|
+
bubbleAvatar: string;
|
|
69
|
+
bubbleContent: string;
|
|
70
|
+
bubbleHeader: string;
|
|
71
|
+
bubbleName: string;
|
|
72
|
+
bubbleTime: string;
|
|
73
|
+
messageBase: string;
|
|
74
|
+
inputBase: string;
|
|
75
|
+
inputFieldWrapper: string;
|
|
76
|
+
inputField: string;
|
|
77
|
+
inputActions: string;
|
|
78
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
79
|
+
position: {
|
|
80
|
+
start: {
|
|
81
|
+
bubbleBase: string;
|
|
82
|
+
bubbleContent: string;
|
|
83
|
+
bubbleHeader: string;
|
|
84
|
+
messageBase: string;
|
|
85
|
+
};
|
|
86
|
+
end: {
|
|
87
|
+
bubbleBase: string;
|
|
88
|
+
bubbleContent: string;
|
|
89
|
+
bubbleHeader: string;
|
|
90
|
+
messageBase: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
variant: {
|
|
94
|
+
primary: {
|
|
95
|
+
messageBase: string;
|
|
96
|
+
};
|
|
97
|
+
surface: {
|
|
98
|
+
messageBase: string;
|
|
99
|
+
};
|
|
100
|
+
outline: {
|
|
101
|
+
messageBase: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
}, {
|
|
105
|
+
bubbleBase: string;
|
|
106
|
+
bubbleAvatar: string;
|
|
107
|
+
bubbleContent: string;
|
|
108
|
+
bubbleHeader: string;
|
|
109
|
+
bubbleName: string;
|
|
110
|
+
bubbleTime: string;
|
|
111
|
+
messageBase: string;
|
|
112
|
+
inputBase: string;
|
|
113
|
+
inputFieldWrapper: string;
|
|
114
|
+
inputField: string;
|
|
115
|
+
inputActions: string;
|
|
116
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
117
|
+
export type ChatVariantProps = VariantProps<typeof chatVariants>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const chatVariants = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
bubbleBase: 'flex w-full gap-3 py-2',
|
|
5
|
+
bubbleAvatar: 'shrink-0 mt-1',
|
|
6
|
+
bubbleContent: 'flex flex-col gap-1 min-w-0 max-w-[80%]',
|
|
7
|
+
bubbleHeader: 'flex items-center gap-2 text-xs text-surface-500 dark:text-surface-400',
|
|
8
|
+
bubbleName: 'font-semibold text-surface-900 dark:text-surface-50',
|
|
9
|
+
bubbleTime: '',
|
|
10
|
+
messageBase: 'px-4 py-2.5 rounded-2xl text-sm break-words',
|
|
11
|
+
inputBase: 'flex items-end gap-2 p-3 bg-surface-50 dark:bg-surface-900 border-t border-outline-variant',
|
|
12
|
+
inputFieldWrapper: 'flex-1 relative bg-surface-100 dark:bg-surface-800 rounded-2xl border border-outline-variant focus-within:border-primary focus-within:ring-1 focus-within:ring-primary transition-colors',
|
|
13
|
+
inputField: 'w-full bg-transparent border-0 px-4 py-3 min-h-[44px] max-h-32 resize-none focus:ring-0 text-sm outline-none',
|
|
14
|
+
inputActions: 'shrink-0 flex items-center gap-1'
|
|
15
|
+
},
|
|
16
|
+
variants: {
|
|
17
|
+
position: {
|
|
18
|
+
start: {
|
|
19
|
+
bubbleBase: 'justify-start',
|
|
20
|
+
bubbleContent: 'items-start',
|
|
21
|
+
bubbleHeader: 'flex-row',
|
|
22
|
+
messageBase: 'rounded-tl-sm'
|
|
23
|
+
},
|
|
24
|
+
end: {
|
|
25
|
+
bubbleBase: 'justify-end flex-row-reverse',
|
|
26
|
+
bubbleContent: 'items-end',
|
|
27
|
+
bubbleHeader: 'flex-row-reverse',
|
|
28
|
+
messageBase: 'rounded-tr-sm'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
variant: {
|
|
32
|
+
primary: {
|
|
33
|
+
messageBase: 'bg-primary text-on-primary'
|
|
34
|
+
},
|
|
35
|
+
surface: {
|
|
36
|
+
messageBase: 'bg-surface-200 dark:bg-surface-800 text-surface-900 dark:text-surface-50'
|
|
37
|
+
},
|
|
38
|
+
outline: {
|
|
39
|
+
messageBase: 'bg-transparent border border-outline-variant text-surface-900 dark:text-surface-50'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
defaultVariants: {
|
|
44
|
+
position: 'start',
|
|
45
|
+
variant: 'surface'
|
|
46
|
+
}
|
|
47
|
+
});
|