svelora 3.0.6 → 3.0.8
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 +48 -0
- package/dist/Chart/Chart.svelte.d.ts +4 -0
- package/dist/Chart/chart.types.d.ts +16 -0
- package/dist/Chart/chart.types.js +1 -0
- package/dist/Chart/index.d.ts +2 -0
- package/dist/Chart/index.js +2 -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/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/NavigationMenu/NavigationMenu.svelte +212 -0
- package/dist/NavigationMenu/NavigationMenu.svelte.d.ts +4 -0
- package/dist/NavigationMenu/index.d.ts +3 -0
- package/dist/NavigationMenu/index.js +3 -0
- package/dist/NavigationMenu/navigation-menu.types.d.ts +104 -0
- package/dist/NavigationMenu/navigation-menu.types.js +1 -0
- package/dist/NavigationMenu/navigation-menu.variants.d.ts +121 -0
- package/dist/NavigationMenu/navigation-menu.variants.js +64 -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/Search/Search.svelte +94 -0
- package/dist/Search/Search.svelte.d.ts +4 -0
- package/dist/Search/index.d.ts +2 -0
- package/dist/Search/index.js +1 -0
- package/dist/Search/search.types.d.ts +40 -0
- package/dist/Search/search.types.js +1 -0
- 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/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 +119 -0
- package/dist/index.d.ts +19 -2
- package/dist/index.js +19 -1
- package/dist/mcp/svelora-docs.data.json +44 -6
- package/package.json +9 -8
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { Popover } from "../Popover/index.js";
|
|
3
|
+
import { Input } from "../Input/index.js";
|
|
4
|
+
import Icon from "../Icon/Icon.svelte";
|
|
5
|
+
import { colorPickerVariants } from "./color-picker.variants.js";
|
|
6
|
+
let { value = $bindable("#000000"), placeholder = "Select color", swatches = [
|
|
7
|
+
"#ef4444",
|
|
8
|
+
"#f97316",
|
|
9
|
+
"#f59e0b",
|
|
10
|
+
"#eab308",
|
|
11
|
+
"#84cc16",
|
|
12
|
+
"#22c55e",
|
|
13
|
+
"#10b981",
|
|
14
|
+
"#14b8a6",
|
|
15
|
+
"#06b6d4",
|
|
16
|
+
"#0ea5e9",
|
|
17
|
+
"#3b82f6",
|
|
18
|
+
"#6366f1",
|
|
19
|
+
"#8b5cf6",
|
|
20
|
+
"#a855f7",
|
|
21
|
+
"#d946ef",
|
|
22
|
+
"#ec4899",
|
|
23
|
+
"#f43f5e",
|
|
24
|
+
"#ffffff",
|
|
25
|
+
"#94a3b8",
|
|
26
|
+
"#000000"
|
|
27
|
+
], disabled = false, class: className, ...restProps } = $props();
|
|
28
|
+
const styles = $derived(colorPickerVariants());
|
|
29
|
+
// Validate hex
|
|
30
|
+
let hexInput = $state(value);
|
|
31
|
+
$effect(() => {
|
|
32
|
+
hexInput = value;
|
|
33
|
+
});
|
|
34
|
+
function handleHexInput(e) {
|
|
35
|
+
const target = e.target;
|
|
36
|
+
let val = target.value;
|
|
37
|
+
if (!val.startsWith("#")) {
|
|
38
|
+
val = "#" + val;
|
|
39
|
+
}
|
|
40
|
+
hexInput = val;
|
|
41
|
+
// Basic hex validation regex (3, 4, 6, or 8 digits)
|
|
42
|
+
if (/^#([A-Fa-f0-9]{3,4}){1,2}$/.test(val)) {
|
|
43
|
+
value = val;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function setSwatch(swatch) {
|
|
47
|
+
value = swatch;
|
|
48
|
+
hexInput = swatch;
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<div class={twMerge(styles.base(), className)} {...restProps}>
|
|
53
|
+
<Popover>
|
|
54
|
+
{#snippet children({ open })}
|
|
55
|
+
<div
|
|
56
|
+
class={styles.trigger()}
|
|
57
|
+
aria-disabled={disabled}
|
|
58
|
+
>
|
|
59
|
+
<div
|
|
60
|
+
class={styles.colorIndicator()}
|
|
61
|
+
style="background-color: {value || '#000'};"
|
|
62
|
+
></div>
|
|
63
|
+
<span class="truncate flex-1 text-left text-on-surface">
|
|
64
|
+
{value || placeholder}
|
|
65
|
+
</span>
|
|
66
|
+
<Icon name="lucide:chevron-down" class="text-on-surface-variant w-4 h-4" />
|
|
67
|
+
</div>
|
|
68
|
+
{/snippet}
|
|
69
|
+
|
|
70
|
+
{#snippet content()}
|
|
71
|
+
<div class={styles.content()}>
|
|
72
|
+
<div class={styles.hexInputWrapper()}>
|
|
73
|
+
<span class="text-sm font-medium">Hex</span>
|
|
74
|
+
<Input
|
|
75
|
+
value={hexInput}
|
|
76
|
+
oninput={handleHexInput}
|
|
77
|
+
class="h-8 font-mono text-xs"
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<div class={styles.swatchGrid()}>
|
|
82
|
+
{#each swatches as swatch}
|
|
83
|
+
<button
|
|
84
|
+
type="button"
|
|
85
|
+
class={styles.swatch()}
|
|
86
|
+
style="background-color: {swatch};"
|
|
87
|
+
title={swatch}
|
|
88
|
+
aria-label={`Select color ${swatch}`}
|
|
89
|
+
onclick={() => setSwatch(swatch)}
|
|
90
|
+
></button>
|
|
91
|
+
{/each}
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<div class="pt-2 border-t border-outline-variant flex flex-col gap-1">
|
|
95
|
+
<span class="text-xs text-on-surface-variant mb-1">Custom Color</span>
|
|
96
|
+
<!-- Native color picker wrapper -->
|
|
97
|
+
<label class="cursor-pointer relative overflow-hidden rounded-md border border-outline-variant w-full h-8 flex items-center justify-center bg-surface-container hover:bg-surface-container-high transition-colors">
|
|
98
|
+
<span class="text-xs font-medium z-10 pointer-events-none mix-blend-difference text-white">Pick Custom</span>
|
|
99
|
+
<input
|
|
100
|
+
type="color"
|
|
101
|
+
bind:value
|
|
102
|
+
class="absolute inset-0 opacity-0 w-full h-full cursor-pointer scale-150"
|
|
103
|
+
/>
|
|
104
|
+
</label>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
{/snippet}
|
|
108
|
+
</Popover>
|
|
109
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
export interface ColorPickerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'value'> {
|
|
3
|
+
/**
|
|
4
|
+
* The bound color value (Hex format).
|
|
5
|
+
* @default '#000000'
|
|
6
|
+
*/
|
|
7
|
+
value?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Placeholder text when no color is selected.
|
|
10
|
+
* @default 'Select color'
|
|
11
|
+
*/
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Array of predefined color swatches.
|
|
15
|
+
*/
|
|
16
|
+
swatches?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Whether the color picker is disabled.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Additional CSS classes.
|
|
24
|
+
*/
|
|
25
|
+
class?: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const colorPickerVariants: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
[key: string]: {
|
|
4
|
+
[key: string]: import("tailwind-merge").ClassNameValue | {
|
|
5
|
+
base?: import("tailwind-merge").ClassNameValue;
|
|
6
|
+
content?: import("tailwind-merge").ClassNameValue;
|
|
7
|
+
trigger?: import("tailwind-merge").ClassNameValue;
|
|
8
|
+
colorIndicator?: import("tailwind-merge").ClassNameValue;
|
|
9
|
+
swatchGrid?: import("tailwind-merge").ClassNameValue;
|
|
10
|
+
swatch?: import("tailwind-merge").ClassNameValue;
|
|
11
|
+
nativeInput?: import("tailwind-merge").ClassNameValue;
|
|
12
|
+
hexInputWrapper?: import("tailwind-merge").ClassNameValue;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
} | {
|
|
16
|
+
[x: string]: {
|
|
17
|
+
[x: string]: import("tailwind-merge").ClassNameValue | {
|
|
18
|
+
base?: import("tailwind-merge").ClassNameValue;
|
|
19
|
+
content?: import("tailwind-merge").ClassNameValue;
|
|
20
|
+
trigger?: import("tailwind-merge").ClassNameValue;
|
|
21
|
+
colorIndicator?: import("tailwind-merge").ClassNameValue;
|
|
22
|
+
swatchGrid?: import("tailwind-merge").ClassNameValue;
|
|
23
|
+
swatch?: import("tailwind-merge").ClassNameValue;
|
|
24
|
+
nativeInput?: import("tailwind-merge").ClassNameValue;
|
|
25
|
+
hexInputWrapper?: import("tailwind-merge").ClassNameValue;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
} | {}, {
|
|
29
|
+
base: string;
|
|
30
|
+
trigger: string;
|
|
31
|
+
colorIndicator: string;
|
|
32
|
+
content: string;
|
|
33
|
+
swatchGrid: string;
|
|
34
|
+
swatch: string;
|
|
35
|
+
nativeInput: string;
|
|
36
|
+
hexInputWrapper: string;
|
|
37
|
+
}, undefined, {
|
|
38
|
+
[key: string]: {
|
|
39
|
+
[key: string]: import("tailwind-merge").ClassNameValue | {
|
|
40
|
+
base?: import("tailwind-merge").ClassNameValue;
|
|
41
|
+
content?: import("tailwind-merge").ClassNameValue;
|
|
42
|
+
trigger?: import("tailwind-merge").ClassNameValue;
|
|
43
|
+
colorIndicator?: import("tailwind-merge").ClassNameValue;
|
|
44
|
+
swatchGrid?: import("tailwind-merge").ClassNameValue;
|
|
45
|
+
swatch?: import("tailwind-merge").ClassNameValue;
|
|
46
|
+
nativeInput?: import("tailwind-merge").ClassNameValue;
|
|
47
|
+
hexInputWrapper?: import("tailwind-merge").ClassNameValue;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
} | {}, {
|
|
51
|
+
base: string;
|
|
52
|
+
trigger: string;
|
|
53
|
+
colorIndicator: string;
|
|
54
|
+
content: string;
|
|
55
|
+
swatchGrid: string;
|
|
56
|
+
swatch: string;
|
|
57
|
+
nativeInput: string;
|
|
58
|
+
hexInputWrapper: string;
|
|
59
|
+
}, import("tailwind-variants").TVReturnType<unknown, {
|
|
60
|
+
base: string;
|
|
61
|
+
trigger: string;
|
|
62
|
+
colorIndicator: string;
|
|
63
|
+
content: string;
|
|
64
|
+
swatchGrid: string;
|
|
65
|
+
swatch: string;
|
|
66
|
+
nativeInput: string;
|
|
67
|
+
hexInputWrapper: string;
|
|
68
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
69
|
+
export type ColorPickerVariantProps = VariantProps<typeof colorPickerVariants>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const colorPickerVariants = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
base: 'relative inline-flex',
|
|
5
|
+
trigger: 'flex items-center gap-2 px-3 py-2 border border-outline-variant rounded-md bg-surface text-sm w-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary',
|
|
6
|
+
colorIndicator: 'w-5 h-5 rounded border border-outline/50 shrink-0',
|
|
7
|
+
content: 'w-64 p-3 flex flex-col gap-3 bg-surface border border-outline-variant rounded-md shadow-md',
|
|
8
|
+
swatchGrid: 'grid grid-cols-6 gap-2',
|
|
9
|
+
swatch: 'w-6 h-6 rounded border border-outline/50 cursor-pointer hover:scale-110 transition-transform focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary',
|
|
10
|
+
nativeInput: 'w-full h-8 cursor-pointer rounded overflow-hidden',
|
|
11
|
+
hexInputWrapper: 'flex items-center gap-2'
|
|
12
|
+
}
|
|
13
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { DateFormatter } from "@internationalized/date";
|
|
3
|
+
import Icon from "../Icon/Icon.svelte";
|
|
4
|
+
import Popover from "../Popover/Popover.svelte";
|
|
5
|
+
import Calendar from "../Calendar/Calendar.svelte";
|
|
6
|
+
import { dateRangePickerVariants } from "./date-range-picker.variants.js";
|
|
7
|
+
let { value = $bindable({
|
|
8
|
+
start: undefined,
|
|
9
|
+
end: undefined
|
|
10
|
+
}), placeholder = "Select date range", numberOfMonths = 2, disabled = false, class: className, onchange, ...restProps } = $props();
|
|
11
|
+
let styles = $derived(dateRangePickerVariants({ disabled }));
|
|
12
|
+
// Internal state for popover
|
|
13
|
+
let open = $state(false);
|
|
14
|
+
// Formatter for displaying dates
|
|
15
|
+
const df = new DateFormatter("en-US", { dateStyle: "medium" });
|
|
16
|
+
let displayText = $derived.by(() => {
|
|
17
|
+
if (value.start) {
|
|
18
|
+
if (value.end) {
|
|
19
|
+
return `${df.format(value.start.toDate("UTC"))} - ${df.format(value.end.toDate("UTC"))}`;
|
|
20
|
+
}
|
|
21
|
+
return df.format(value.start.toDate("UTC"));
|
|
22
|
+
}
|
|
23
|
+
return placeholder;
|
|
24
|
+
});
|
|
25
|
+
function handleDateChange(v) {
|
|
26
|
+
// Range calendar passes an object with start/end
|
|
27
|
+
const rangeValue = v;
|
|
28
|
+
value = rangeValue;
|
|
29
|
+
onchange?.(rangeValue);
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<Popover bind:open>
|
|
34
|
+
{#snippet children({ open })}
|
|
35
|
+
<button
|
|
36
|
+
type="button"
|
|
37
|
+
class={twMerge(styles.trigger() as string, className, !value.start && 'text-surface-500')}
|
|
38
|
+
{disabled}
|
|
39
|
+
{...restProps}
|
|
40
|
+
>
|
|
41
|
+
<div class="flex items-center gap-2 overflow-hidden">
|
|
42
|
+
<Icon name="lucide:calendar" class={styles.icon() as string} />
|
|
43
|
+
<span class={styles.triggerText() as string}>{displayText}</span>
|
|
44
|
+
</div>
|
|
45
|
+
<Icon name="lucide:chevron-down" class={styles.icon() as string} />
|
|
46
|
+
</button>
|
|
47
|
+
{/snippet}
|
|
48
|
+
|
|
49
|
+
{#snippet content()}
|
|
50
|
+
<div class={styles.popoverContent() as string}>
|
|
51
|
+
<Calendar
|
|
52
|
+
range={true}
|
|
53
|
+
value={value as any}
|
|
54
|
+
{numberOfMonths}
|
|
55
|
+
onValueChange={handleDateChange}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
{/snippet}
|
|
59
|
+
</Popover>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { DateValue } from '@internationalized/date';
|
|
3
|
+
export interface DateRange {
|
|
4
|
+
start: DateValue | undefined;
|
|
5
|
+
end: DateValue | undefined;
|
|
6
|
+
}
|
|
7
|
+
export interface DateRangePickerProps extends Omit<HTMLAttributes<HTMLButtonElement>, 'value' | 'onchange'> {
|
|
8
|
+
/**
|
|
9
|
+
* The selected date range.
|
|
10
|
+
*/
|
|
11
|
+
value?: DateRange;
|
|
12
|
+
/**
|
|
13
|
+
* Placeholder text when no dates are selected.
|
|
14
|
+
* @default 'Select date range'
|
|
15
|
+
*/
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Number of months to display side-by-side.
|
|
19
|
+
* @default 2
|
|
20
|
+
*/
|
|
21
|
+
numberOfMonths?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the picker is disabled.
|
|
24
|
+
*/
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Additional CSS classes for the trigger button.
|
|
28
|
+
*/
|
|
29
|
+
class?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Event fired when the date range changes.
|
|
32
|
+
*/
|
|
33
|
+
onchange?: (value: DateRange) => void;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const dateRangePickerVariants: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
disabled: {
|
|
4
|
+
true: {
|
|
5
|
+
trigger: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
}, {
|
|
9
|
+
trigger: string;
|
|
10
|
+
triggerText: string;
|
|
11
|
+
icon: string;
|
|
12
|
+
popoverContent: string;
|
|
13
|
+
calendarWrapper: string;
|
|
14
|
+
}, undefined, {
|
|
15
|
+
disabled: {
|
|
16
|
+
true: {
|
|
17
|
+
trigger: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}, {
|
|
21
|
+
trigger: string;
|
|
22
|
+
triggerText: string;
|
|
23
|
+
icon: string;
|
|
24
|
+
popoverContent: string;
|
|
25
|
+
calendarWrapper: string;
|
|
26
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
27
|
+
disabled: {
|
|
28
|
+
true: {
|
|
29
|
+
trigger: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}, {
|
|
33
|
+
trigger: string;
|
|
34
|
+
triggerText: string;
|
|
35
|
+
icon: string;
|
|
36
|
+
popoverContent: string;
|
|
37
|
+
calendarWrapper: string;
|
|
38
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
39
|
+
export type DateRangePickerVariantProps = VariantProps<typeof dateRangePickerVariants>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const dateRangePickerVariants = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
trigger: 'flex w-full items-center justify-between gap-2 px-3 py-2 text-sm text-left border border-outline-variant bg-surface-50 dark:bg-surface-900 rounded-md hover:bg-surface-100 dark:hover:bg-surface-800 focus:outline-none focus:ring-2 focus:ring-primary transition-colors',
|
|
5
|
+
triggerText: 'truncate flex-1',
|
|
6
|
+
icon: 'w-4 h-4 shrink-0 text-surface-500',
|
|
7
|
+
popoverContent: 'w-auto p-3 bg-surface-50 dark:bg-surface-900 border border-outline-variant rounded-md shadow-md',
|
|
8
|
+
calendarWrapper: 'flex flex-col sm:flex-row gap-4'
|
|
9
|
+
},
|
|
10
|
+
variants: {
|
|
11
|
+
disabled: {
|
|
12
|
+
true: {
|
|
13
|
+
trigger: 'opacity-50 cursor-not-allowed pointer-events-none'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
disabled: false
|
|
19
|
+
}
|
|
20
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { setContext } from "svelte";
|
|
3
|
+
import { listVariants } from "./list.variants.js";
|
|
4
|
+
let { variant = "default", class: className, children, ...restProps } = $props();
|
|
5
|
+
let styles = $derived(listVariants({ variant }));
|
|
6
|
+
// Pass the variant down to children if needed, or just let them style themselves
|
|
7
|
+
// Since the variant affects the parent 'base', but 'bordered' also affects 'item',
|
|
8
|
+
// we should provide the list context so ListItems know the current variant.
|
|
9
|
+
setContext("list-variant", () => variant);
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<ul class={twMerge(styles.base(), className)} {...restProps}>
|
|
13
|
+
{@render children?.()}
|
|
14
|
+
</ul>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { getContext } from "svelte";
|
|
3
|
+
import { listVariants } from "./list.variants.js";
|
|
4
|
+
let { title, description, interactive = false, disabled = false, href, target, class: className, leading, trailing, children, ...restProps } = $props();
|
|
5
|
+
// Get the parent list variant, default to 'default' if used outside a List
|
|
6
|
+
const getListVariant = getContext("list-variant");
|
|
7
|
+
let parentVariant = $derived(getListVariant ? getListVariant() : "default");
|
|
8
|
+
// Determine if it should be interactive automatically if it's a link
|
|
9
|
+
let isInteractive = $derived(interactive || !!href);
|
|
10
|
+
let styles = $derived(listVariants({
|
|
11
|
+
variant: parentVariant,
|
|
12
|
+
interactive: isInteractive,
|
|
13
|
+
disabled
|
|
14
|
+
}));
|
|
15
|
+
// Using svelte:element with conditional tags and spreading restProps causes TS errors.
|
|
16
|
+
// We use a snippet to keep the markup DRY while using explicit if/else tags.
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
{#snippet contentWrapper()}
|
|
20
|
+
{#if leading}
|
|
21
|
+
<div class={styles.leading()}>
|
|
22
|
+
{@render leading()}
|
|
23
|
+
</div>
|
|
24
|
+
{/if}
|
|
25
|
+
|
|
26
|
+
<div class={styles.itemContent()}>
|
|
27
|
+
{#if children}
|
|
28
|
+
{@render children()}
|
|
29
|
+
{:else}
|
|
30
|
+
{#if title}
|
|
31
|
+
<div class={styles.itemTitle()}>{title}</div>
|
|
32
|
+
{/if}
|
|
33
|
+
{#if description}
|
|
34
|
+
<div class={styles.itemDescription()}>{description}</div>
|
|
35
|
+
{/if}
|
|
36
|
+
{/if}
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
{#if trailing}
|
|
40
|
+
<div class={styles.trailing()}>
|
|
41
|
+
{@render trailing()}
|
|
42
|
+
</div>
|
|
43
|
+
{/if}
|
|
44
|
+
{/snippet}
|
|
45
|
+
|
|
46
|
+
<li>
|
|
47
|
+
{#if href}
|
|
48
|
+
<a
|
|
49
|
+
{href}
|
|
50
|
+
{target}
|
|
51
|
+
class={twMerge(styles.item(), className)}
|
|
52
|
+
{...restProps as any}
|
|
53
|
+
>
|
|
54
|
+
{@render contentWrapper()}
|
|
55
|
+
</a>
|
|
56
|
+
{:else}
|
|
57
|
+
<div
|
|
58
|
+
class={twMerge(styles.item(), className)}
|
|
59
|
+
{...restProps as any}
|
|
60
|
+
>
|
|
61
|
+
{@render contentWrapper()}
|
|
62
|
+
</div>
|
|
63
|
+
{/if}
|
|
64
|
+
</li>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes, HTMLLiAttributes } from 'svelte/elements';
|
|
3
|
+
import type { ListVariantProps } from './list.variants.js';
|
|
4
|
+
export interface ListProps extends HTMLAttributes<HTMLUListElement> {
|
|
5
|
+
/**
|
|
6
|
+
* The variant of the list.
|
|
7
|
+
* @default 'default'
|
|
8
|
+
*/
|
|
9
|
+
variant?: ListVariantProps['variant'];
|
|
10
|
+
/**
|
|
11
|
+
* Additional CSS classes.
|
|
12
|
+
*/
|
|
13
|
+
class?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Content of the list.
|
|
16
|
+
*/
|
|
17
|
+
children?: Snippet;
|
|
18
|
+
}
|
|
19
|
+
export interface ListItemProps extends HTMLLiAttributes {
|
|
20
|
+
/**
|
|
21
|
+
* Title of the list item.
|
|
22
|
+
*/
|
|
23
|
+
title?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Description below the title.
|
|
26
|
+
*/
|
|
27
|
+
description?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the item is interactive (hover/active states).
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
interactive?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the item is disabled.
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Optional href. If provided, the item renders as an anchor tag `<a>`.
|
|
40
|
+
*/
|
|
41
|
+
href?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Target attribute for the anchor tag if `href` is provided.
|
|
44
|
+
*/
|
|
45
|
+
target?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Additional CSS classes.
|
|
48
|
+
*/
|
|
49
|
+
class?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Snippet for the leading section (e.g., Avatar, Icon).
|
|
52
|
+
*/
|
|
53
|
+
leading?: Snippet;
|
|
54
|
+
/**
|
|
55
|
+
* Snippet for the trailing section (e.g., Badge, Chevron, Switch).
|
|
56
|
+
*/
|
|
57
|
+
trailing?: Snippet;
|
|
58
|
+
/**
|
|
59
|
+
* Snippet to replace the default title/description content completely.
|
|
60
|
+
*/
|
|
61
|
+
children?: Snippet;
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|