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,93 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import Icon from "../Icon/Icon.svelte";
|
|
3
|
+
import { ratingVariants } from "./rating.variants.js";
|
|
4
|
+
let { value = $bindable(0), max = 5, size = "md", allowHalf = false, disabled = false, readonly = false, iconFull = "lucide:star", iconEmpty = "lucide:star", activeColor = "text-warning-500 fill-warning-500", inactiveColor = "text-surface-300 dark:text-surface-600", class: className, onchange, ...restProps } = $props();
|
|
5
|
+
let styles = $derived(ratingVariants({
|
|
6
|
+
size,
|
|
7
|
+
disabled,
|
|
8
|
+
readonly
|
|
9
|
+
}));
|
|
10
|
+
let hoverValue = $state(null);
|
|
11
|
+
// Calculate array of stars
|
|
12
|
+
let stars = $derived(Array.from({ length: max }, (_, i) => i + 1));
|
|
13
|
+
function handleMouseMove(e, index) {
|
|
14
|
+
if (disabled || readonly) return;
|
|
15
|
+
if (allowHalf) {
|
|
16
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
17
|
+
const x = e.clientX - rect.left;
|
|
18
|
+
const isHalf = x < rect.width / 2;
|
|
19
|
+
hoverValue = isHalf ? index - .5 : index;
|
|
20
|
+
} else {
|
|
21
|
+
hoverValue = index;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function handleMouseLeave() {
|
|
25
|
+
if (disabled || readonly) return;
|
|
26
|
+
hoverValue = null;
|
|
27
|
+
}
|
|
28
|
+
function handleClick(index) {
|
|
29
|
+
if (disabled || readonly) return;
|
|
30
|
+
value = hoverValue ?? index;
|
|
31
|
+
onchange?.(value);
|
|
32
|
+
}
|
|
33
|
+
function handleKeyDown(e, index) {
|
|
34
|
+
if (disabled || readonly) return;
|
|
35
|
+
let newValue = value;
|
|
36
|
+
if (e.key === "ArrowRight" || e.key === "ArrowUp") {
|
|
37
|
+
newValue = Math.min(max, value + (allowHalf ? .5 : 1));
|
|
38
|
+
} else if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
|
|
39
|
+
newValue = Math.max(0, value - (allowHalf ? .5 : 1));
|
|
40
|
+
} else if (e.key === "Enter" || e.key === " ") {
|
|
41
|
+
newValue = index;
|
|
42
|
+
} else {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
value = newValue;
|
|
47
|
+
onchange?.(value);
|
|
48
|
+
}
|
|
49
|
+
function getStarState(index) {
|
|
50
|
+
const currentValue = hoverValue ?? value;
|
|
51
|
+
if (currentValue >= index) return "full";
|
|
52
|
+
if (allowHalf && currentValue >= index - .5) return "half";
|
|
53
|
+
return "empty";
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<div
|
|
58
|
+
class={twMerge(styles.base() as string, className)}
|
|
59
|
+
onmouseleave={handleMouseLeave}
|
|
60
|
+
{...restProps}
|
|
61
|
+
role="radiogroup"
|
|
62
|
+
>
|
|
63
|
+
{#each stars as starIndex}
|
|
64
|
+
{@const state = getStarState(starIndex)}
|
|
65
|
+
|
|
66
|
+
<button
|
|
67
|
+
type="button"
|
|
68
|
+
role="radio"
|
|
69
|
+
aria-checked={value >= starIndex}
|
|
70
|
+
aria-label={`Rate ${starIndex} out of ${max} stars`}
|
|
71
|
+
class={styles.starWrapper() as string}
|
|
72
|
+
disabled={disabled || readonly}
|
|
73
|
+
tabindex={disabled || readonly ? -1 : 0}
|
|
74
|
+
onmousemove={(e) => handleMouseMove(e, starIndex)}
|
|
75
|
+
onclick={() => handleClick(starIndex)}
|
|
76
|
+
onkeydown={(e) => handleKeyDown(e, starIndex)}
|
|
77
|
+
>
|
|
78
|
+
{#if state === 'full'}
|
|
79
|
+
<Icon name={iconFull} class={twMerge(styles.star() as string, activeColor)} />
|
|
80
|
+
{:else if state === 'half'}
|
|
81
|
+
<!-- Simple half star implementation using CSS clip-path or two icons -->
|
|
82
|
+
<div class="relative">
|
|
83
|
+
<Icon name={iconEmpty} class={twMerge(styles.star() as string, inactiveColor)} />
|
|
84
|
+
<div class="absolute inset-0 overflow-hidden w-1/2">
|
|
85
|
+
<Icon name={iconFull} class={twMerge(styles.star() as string, activeColor)} />
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
{:else}
|
|
89
|
+
<Icon name={iconEmpty} class={twMerge(styles.star() as string, inactiveColor)} />
|
|
90
|
+
{/if}
|
|
91
|
+
</button>
|
|
92
|
+
{/each}
|
|
93
|
+
</div>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { RatingVariantProps } from './rating.variants.js';
|
|
3
|
+
export interface RatingProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onchange'> {
|
|
4
|
+
/**
|
|
5
|
+
* The current rating value.
|
|
6
|
+
*/
|
|
7
|
+
value?: number;
|
|
8
|
+
/**
|
|
9
|
+
* The maximum rating value (number of stars).
|
|
10
|
+
* @default 5
|
|
11
|
+
*/
|
|
12
|
+
max?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Size of the stars.
|
|
15
|
+
* @default 'md'
|
|
16
|
+
*/
|
|
17
|
+
size?: RatingVariantProps['size'];
|
|
18
|
+
/**
|
|
19
|
+
* Whether the rating allows half-star selection.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
allowHalf?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the rating is disabled.
|
|
25
|
+
*/
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the rating is read-only (cannot be changed by user).
|
|
29
|
+
*/
|
|
30
|
+
readonly?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Icon to use for the full star.
|
|
33
|
+
* @default 'lucide:star'
|
|
34
|
+
*/
|
|
35
|
+
iconFull?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Icon to use for the empty star.
|
|
38
|
+
* @default 'lucide:star'
|
|
39
|
+
*/
|
|
40
|
+
iconEmpty?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Color class for the active/filled stars.
|
|
43
|
+
* @default 'text-warning-500 fill-warning-500'
|
|
44
|
+
*/
|
|
45
|
+
activeColor?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Color class for the inactive/empty stars.
|
|
48
|
+
* @default 'text-surface-300 dark:text-surface-600'
|
|
49
|
+
*/
|
|
50
|
+
inactiveColor?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Additional CSS classes.
|
|
53
|
+
*/
|
|
54
|
+
class?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Event fired when the rating changes.
|
|
57
|
+
*/
|
|
58
|
+
onchange?: (value: number) => void;
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const ratingVariants: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
size: {
|
|
4
|
+
sm: {
|
|
5
|
+
star: string;
|
|
6
|
+
};
|
|
7
|
+
md: {
|
|
8
|
+
star: string;
|
|
9
|
+
};
|
|
10
|
+
lg: {
|
|
11
|
+
star: string;
|
|
12
|
+
};
|
|
13
|
+
xl: {
|
|
14
|
+
star: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
disabled: {
|
|
18
|
+
true: {
|
|
19
|
+
base: string;
|
|
20
|
+
starWrapper: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly: {
|
|
24
|
+
true: {
|
|
25
|
+
starWrapper: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}, {
|
|
29
|
+
base: string;
|
|
30
|
+
starWrapper: string;
|
|
31
|
+
star: string;
|
|
32
|
+
}, undefined, {
|
|
33
|
+
size: {
|
|
34
|
+
sm: {
|
|
35
|
+
star: string;
|
|
36
|
+
};
|
|
37
|
+
md: {
|
|
38
|
+
star: string;
|
|
39
|
+
};
|
|
40
|
+
lg: {
|
|
41
|
+
star: string;
|
|
42
|
+
};
|
|
43
|
+
xl: {
|
|
44
|
+
star: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
disabled: {
|
|
48
|
+
true: {
|
|
49
|
+
base: string;
|
|
50
|
+
starWrapper: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
readonly: {
|
|
54
|
+
true: {
|
|
55
|
+
starWrapper: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
}, {
|
|
59
|
+
base: string;
|
|
60
|
+
starWrapper: string;
|
|
61
|
+
star: string;
|
|
62
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
63
|
+
size: {
|
|
64
|
+
sm: {
|
|
65
|
+
star: string;
|
|
66
|
+
};
|
|
67
|
+
md: {
|
|
68
|
+
star: string;
|
|
69
|
+
};
|
|
70
|
+
lg: {
|
|
71
|
+
star: string;
|
|
72
|
+
};
|
|
73
|
+
xl: {
|
|
74
|
+
star: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
disabled: {
|
|
78
|
+
true: {
|
|
79
|
+
base: string;
|
|
80
|
+
starWrapper: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
readonly: {
|
|
84
|
+
true: {
|
|
85
|
+
starWrapper: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
}, {
|
|
89
|
+
base: string;
|
|
90
|
+
starWrapper: string;
|
|
91
|
+
star: string;
|
|
92
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
93
|
+
export type RatingVariantProps = VariantProps<typeof ratingVariants>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const ratingVariants = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
base: 'flex items-center gap-1',
|
|
5
|
+
starWrapper: 'relative cursor-pointer transition-transform hover:scale-110 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-full',
|
|
6
|
+
star: 'transition-colors duration-200'
|
|
7
|
+
},
|
|
8
|
+
variants: {
|
|
9
|
+
size: {
|
|
10
|
+
sm: { star: 'w-4 h-4' },
|
|
11
|
+
md: { star: 'w-5 h-5' },
|
|
12
|
+
lg: { star: 'w-6 h-6' },
|
|
13
|
+
xl: { star: 'w-8 h-8' }
|
|
14
|
+
},
|
|
15
|
+
disabled: {
|
|
16
|
+
true: {
|
|
17
|
+
base: 'opacity-50 cursor-not-allowed',
|
|
18
|
+
starWrapper: 'cursor-not-allowed hover:scale-100'
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
readonly: {
|
|
22
|
+
true: {
|
|
23
|
+
starWrapper: 'cursor-default hover:scale-100'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
size: 'md',
|
|
29
|
+
disabled: false,
|
|
30
|
+
readonly: false
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { resizableVariants } from "./resizable.variants.js";
|
|
3
|
+
let { direction = "both", class: className, children, ...restProps } = $props();
|
|
4
|
+
let styles = $derived(resizableVariants({ direction }));
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class={twMerge(styles.base(), className)} {...restProps}>
|
|
8
|
+
{@render children?.()}
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { ResizableVariantProps } from './resizable.variants.js';
|
|
4
|
+
export interface ResizableProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* The direction in which the element can be resized.
|
|
7
|
+
* @default 'both'
|
|
8
|
+
*/
|
|
9
|
+
direction?: ResizableVariantProps['direction'];
|
|
10
|
+
/**
|
|
11
|
+
* Additional CSS classes.
|
|
12
|
+
*/
|
|
13
|
+
class?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Content inside the resizable container.
|
|
16
|
+
*/
|
|
17
|
+
children?: Snippet;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const resizableVariants: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
direction: {
|
|
4
|
+
horizontal: {
|
|
5
|
+
base: string;
|
|
6
|
+
};
|
|
7
|
+
vertical: {
|
|
8
|
+
base: string;
|
|
9
|
+
};
|
|
10
|
+
both: {
|
|
11
|
+
base: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}, {
|
|
15
|
+
base: string;
|
|
16
|
+
handle: string;
|
|
17
|
+
}, undefined, {
|
|
18
|
+
direction: {
|
|
19
|
+
horizontal: {
|
|
20
|
+
base: string;
|
|
21
|
+
};
|
|
22
|
+
vertical: {
|
|
23
|
+
base: string;
|
|
24
|
+
};
|
|
25
|
+
both: {
|
|
26
|
+
base: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}, {
|
|
30
|
+
base: string;
|
|
31
|
+
handle: string;
|
|
32
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
33
|
+
direction: {
|
|
34
|
+
horizontal: {
|
|
35
|
+
base: string;
|
|
36
|
+
};
|
|
37
|
+
vertical: {
|
|
38
|
+
base: string;
|
|
39
|
+
};
|
|
40
|
+
both: {
|
|
41
|
+
base: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
}, {
|
|
45
|
+
base: string;
|
|
46
|
+
handle: string;
|
|
47
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
48
|
+
export type ResizableVariantProps = VariantProps<typeof resizableVariants>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const resizableVariants = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
base: 'relative overflow-auto border border-outline-variant bg-surface-50 dark:bg-surface-900',
|
|
5
|
+
handle: 'absolute right-0 bottom-0 w-4 h-4 cursor-se-resize flex items-center justify-center opacity-0 hover:opacity-100 transition-opacity'
|
|
6
|
+
},
|
|
7
|
+
variants: {
|
|
8
|
+
direction: {
|
|
9
|
+
horizontal: { base: 'resize-x' },
|
|
10
|
+
vertical: { base: 'resize-y' },
|
|
11
|
+
both: { base: 'resize' }
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
direction: 'both'
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { scrollAreaVariants } from "./scroll-area.variants.js";
|
|
3
|
+
let { orientation = "vertical", hideScrollbar = false, class: className, viewportClass, children, ...restProps } = $props();
|
|
4
|
+
let styles = $derived(scrollAreaVariants({
|
|
5
|
+
orientation,
|
|
6
|
+
hideScrollbar
|
|
7
|
+
}));
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<div class={twMerge(styles.root(), className)} {...restProps}>
|
|
11
|
+
<div
|
|
12
|
+
class={twMerge(
|
|
13
|
+
styles.viewport(),
|
|
14
|
+
!hideScrollbar && 'svelora-scrollbar',
|
|
15
|
+
viewportClass
|
|
16
|
+
)}
|
|
17
|
+
data-orientation={orientation}
|
|
18
|
+
>
|
|
19
|
+
{@render children?.()}
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<style>
|
|
24
|
+
/* Custom scrollbar styling for Webkit browsers */
|
|
25
|
+
:global(.svelora-scrollbar::-webkit-scrollbar) {
|
|
26
|
+
width: 6px;
|
|
27
|
+
height: 6px;
|
|
28
|
+
}
|
|
29
|
+
:global(.svelora-scrollbar::-webkit-scrollbar-track) {
|
|
30
|
+
background: transparent;
|
|
31
|
+
}
|
|
32
|
+
:global(.svelora-scrollbar::-webkit-scrollbar-thumb) {
|
|
33
|
+
background-color: var(--color-outline-variant, rgba(156, 163, 175, 0.5));
|
|
34
|
+
border-radius: 9999px;
|
|
35
|
+
}
|
|
36
|
+
:global(.svelora-scrollbar::-webkit-scrollbar-thumb:hover) {
|
|
37
|
+
background-color: var(--color-outline, rgba(107, 114, 128, 0.8));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Firefox support */
|
|
41
|
+
:global(.svelora-scrollbar) {
|
|
42
|
+
scrollbar-width: thin;
|
|
43
|
+
scrollbar-color: var(--color-outline-variant, rgba(156, 163, 175, 0.5)) transparent;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Hide scrollbar utility */
|
|
47
|
+
:global(.scrollbar-none::-webkit-scrollbar) {
|
|
48
|
+
display: none;
|
|
49
|
+
}
|
|
50
|
+
:global(.scrollbar-none) {
|
|
51
|
+
-ms-overflow-style: none; /* IE and Edge */
|
|
52
|
+
scrollbar-width: none; /* Firefox */
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { ScrollAreaVariantProps } from './scroll-area.variants.js';
|
|
4
|
+
export interface ScrollAreaProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* Orientation of the scrolling area.
|
|
7
|
+
* @default 'vertical'
|
|
8
|
+
*/
|
|
9
|
+
orientation?: ScrollAreaVariantProps['orientation'];
|
|
10
|
+
/**
|
|
11
|
+
* Whether to hide the scrollbar track/thumb completely while still allowing scrolling.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
hideScrollbar?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Additional CSS classes for the root container.
|
|
17
|
+
*/
|
|
18
|
+
class?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Additional CSS classes for the viewport (the scrollable area).
|
|
21
|
+
*/
|
|
22
|
+
viewportClass?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Content to be scrolled.
|
|
25
|
+
*/
|
|
26
|
+
children?: Snippet;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const scrollAreaVariants: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
orientation: {
|
|
4
|
+
vertical: string;
|
|
5
|
+
horizontal: string;
|
|
6
|
+
both: string;
|
|
7
|
+
};
|
|
8
|
+
hideScrollbar: {
|
|
9
|
+
true: {
|
|
10
|
+
viewport: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}, {
|
|
14
|
+
root: string;
|
|
15
|
+
viewport: string;
|
|
16
|
+
}, undefined, {
|
|
17
|
+
orientation: {
|
|
18
|
+
vertical: string;
|
|
19
|
+
horizontal: string;
|
|
20
|
+
both: string;
|
|
21
|
+
};
|
|
22
|
+
hideScrollbar: {
|
|
23
|
+
true: {
|
|
24
|
+
viewport: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}, {
|
|
28
|
+
root: string;
|
|
29
|
+
viewport: string;
|
|
30
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
31
|
+
orientation: {
|
|
32
|
+
vertical: string;
|
|
33
|
+
horizontal: string;
|
|
34
|
+
both: string;
|
|
35
|
+
};
|
|
36
|
+
hideScrollbar: {
|
|
37
|
+
true: {
|
|
38
|
+
viewport: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}, {
|
|
42
|
+
root: string;
|
|
43
|
+
viewport: string;
|
|
44
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
45
|
+
export type ScrollAreaVariantProps = VariantProps<typeof scrollAreaVariants>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const scrollAreaVariants = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
root: 'relative overflow-hidden',
|
|
5
|
+
viewport: 'h-full w-full rounded-[inherit] overflow-auto'
|
|
6
|
+
// Note: For actual custom scrollbars without a JS library, we can use
|
|
7
|
+
// global CSS webkit scrollbar styles or a plugin.
|
|
8
|
+
// Here we just define standard utility classes to hide or style them if Tailwind scrollbar plugin is used.
|
|
9
|
+
// We'll add a custom class `svelora-scrollbar` to be styled in global css if needed.
|
|
10
|
+
},
|
|
11
|
+
variants: {
|
|
12
|
+
orientation: {
|
|
13
|
+
vertical: '',
|
|
14
|
+
horizontal: '',
|
|
15
|
+
both: ''
|
|
16
|
+
},
|
|
17
|
+
hideScrollbar: {
|
|
18
|
+
true: {
|
|
19
|
+
viewport: 'scrollbar-none' // Requires tailwind-scrollbar plugin or custom CSS
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
orientation: 'vertical',
|
|
25
|
+
hideScrollbar: false
|
|
26
|
+
}
|
|
27
|
+
});
|