@x33025/sveltely 0.0.58 → 0.1.0
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/actions/tooltip.d.ts +10 -0
- package/dist/actions/tooltip.js +255 -0
- package/dist/components/{AnimatedNumber.demo.svelte → Library/AnimatedNumber/AnimatedNumber.demo.svelte} +6 -10
- package/dist/components/{AnimatedNumber.demo.svelte.d.ts → Library/AnimatedNumber/AnimatedNumber.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/AnimatedNumber/AnimatedNumber.svelte +29 -0
- package/dist/components/Library/AnimatedNumber/AnimatedNumber.svelte.d.ts +9 -0
- package/dist/components/Library/AnimatedNumber/index.d.ts +1 -0
- package/dist/components/Library/AnimatedNumber/index.js +1 -0
- package/dist/components/{AsyncButton.demo.svelte → Library/AsyncButton/AsyncButton.demo.svelte} +0 -1
- package/dist/components/Library/AsyncButton/AsyncButton.svelte +178 -0
- package/dist/components/{AsyncButton.svelte.d.ts → Library/AsyncButton/AsyncButton.svelte.d.ts} +7 -2
- package/dist/components/Library/AsyncButton/index.d.ts +1 -0
- package/dist/components/Library/AsyncButton/index.js +1 -0
- package/dist/components/Library/Button/Button.demo.svelte +17 -0
- package/dist/components/Library/Button/Button.demo.svelte.d.ts +23 -0
- package/dist/components/Library/Button/Button.svelte +134 -0
- package/dist/components/Library/Button/Button.svelte.d.ts +17 -0
- package/dist/components/Library/Button/index.d.ts +1 -0
- package/dist/components/Library/Button/index.js +1 -0
- package/dist/components/Library/Calendar/Calendar.demo.svelte +30 -0
- package/dist/components/Library/Calendar/Calendar.demo.svelte.d.ts +10 -0
- package/dist/components/Library/Calendar/Calendar.svelte +310 -0
- package/dist/components/Library/Calendar/Calendar.svelte.d.ts +10 -0
- package/dist/components/Library/Calendar/index.d.ts +1 -0
- package/dist/components/Library/Calendar/index.js +1 -0
- package/dist/components/Library/Checkbox/Checkbox.demo.svelte +20 -0
- package/dist/components/Library/Checkbox/Checkbox.demo.svelte.d.ts +8 -0
- package/dist/components/Library/Checkbox/Checkbox.svelte +134 -0
- package/dist/components/Library/Checkbox/Checkbox.svelte.d.ts +11 -0
- package/dist/components/Library/Checkbox/index.d.ts +1 -0
- package/dist/components/Library/Checkbox/index.js +1 -0
- package/dist/components/{ChipInput.demo.svelte → Library/ChipInput/ChipInput.demo.svelte} +1 -2
- package/dist/components/{ChipInput.demo.svelte.d.ts → Library/ChipInput/ChipInput.demo.svelte.d.ts} +0 -1
- package/dist/components/{ChipInput.svelte → Library/ChipInput/ChipInput.svelte} +77 -3
- package/dist/components/{ChipInput.svelte.d.ts → Library/ChipInput/ChipInput.svelte.d.ts} +2 -1
- package/dist/components/Library/ChipInput/index.d.ts +1 -0
- package/dist/components/Library/ChipInput/index.js +1 -0
- package/dist/components/Library/Dropdown/Dropdown.demo.svelte +54 -0
- package/dist/components/Library/Dropdown/Dropdown.demo.svelte.d.ts +8 -0
- package/dist/components/Library/Dropdown/Dropdown.svelte +346 -0
- package/dist/components/Library/Dropdown/Dropdown.svelte.d.ts +40 -0
- package/dist/components/Library/Dropdown/index.d.ts +2 -0
- package/dist/components/Library/Dropdown/index.js +1 -0
- package/dist/components/Library/Dropdown/types.d.ts +27 -0
- package/dist/components/Library/Dropdown/types.js +1 -0
- package/dist/components/{Popover/Popover.svelte → Library/Floating/Floating.svelte} +155 -101
- package/dist/components/Library/Floating/Floating.svelte.d.ts +30 -0
- package/dist/components/Library/Floating/registry.svelte.d.ts +6 -0
- package/dist/components/{Popover → Library/Floating}/registry.svelte.js +2 -23
- package/dist/components/{GlowEffect.svelte → Library/GlowEffect/GlowEffect.svelte} +15 -6
- package/dist/components/{GlowEffect.svelte.d.ts → Library/GlowEffect/GlowEffect.svelte.d.ts} +3 -2
- package/dist/components/Library/GlowEffect/index.d.ts +1 -0
- package/dist/components/Library/GlowEffect/index.js +1 -0
- package/dist/components/Library/NavigationStack/NavigationStack.svelte +242 -0
- package/dist/components/Library/NavigationStack/NavigationStack.svelte.d.ts +15 -0
- package/dist/components/Library/NavigationStack/SidebarToggle.svelte +52 -0
- package/dist/components/Library/NavigationStack/SidebarToggle.svelte.d.ts +10 -0
- package/dist/components/Library/NavigationStack/Toolbar.svelte +59 -0
- package/dist/components/Library/NavigationStack/Toolbar.svelte.d.ts +11 -0
- package/dist/components/{Pagination.demo.svelte → Library/Pagination/Pagination.demo.svelte} +0 -1
- package/dist/components/{Pagination.demo.svelte.d.ts → Library/Pagination/Pagination.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/Pagination/Pagination.svelte +227 -0
- package/dist/components/{Pagination.svelte.d.ts → Library/Pagination/Pagination.svelte.d.ts} +3 -3
- package/dist/components/Library/Pagination/index.d.ts +1 -0
- package/dist/components/Library/Pagination/index.js +1 -0
- package/dist/components/Library/Popover/Popover.demo.svelte +21 -0
- package/dist/components/Library/Popover/Popover.svelte +92 -0
- package/dist/components/Library/Popover/Popover.svelte.d.ts +14 -0
- package/dist/components/{Popover → Library/Popover}/PopoverDebugOverlay.svelte +1 -1
- package/dist/components/Library/Popover/index.d.ts +1 -0
- package/dist/components/Library/Popover/index.js +1 -0
- package/dist/components/Library/ScrollView/ScrollView.svelte +89 -0
- package/dist/components/Library/ScrollView/ScrollView.svelte.d.ts +12 -0
- package/dist/components/Library/ScrollView/index.d.ts +1 -0
- package/dist/components/Library/ScrollView/index.js +1 -0
- package/dist/components/{SearchInput.demo.svelte → Library/SearchInput/SearchInput.demo.svelte} +2 -3
- package/dist/components/{SearchInput.demo.svelte.d.ts → Library/SearchInput/SearchInput.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/SearchInput/SearchInput.svelte +88 -0
- package/dist/components/{SearchInput.svelte.d.ts → Library/SearchInput/SearchInput.svelte.d.ts} +3 -3
- package/dist/components/Library/SearchInput/index.d.ts +1 -0
- package/dist/components/Library/SearchInput/index.js +1 -0
- package/dist/components/{SegmentedPicker.demo.svelte → Library/SegmentedPicker/SegmentedPicker.demo.svelte} +1 -2
- package/dist/components/{SegmentedPicker.demo.svelte.d.ts → Library/SegmentedPicker/SegmentedPicker.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/SegmentedPicker/SegmentedPicker.svelte +106 -0
- package/dist/components/{SegmentedPicker.svelte.d.ts → Library/SegmentedPicker/SegmentedPicker.svelte.d.ts} +2 -2
- package/dist/components/Library/SegmentedPicker/index.d.ts +1 -0
- package/dist/components/Library/SegmentedPicker/index.js +1 -0
- package/dist/components/{Sheet → Library/Sheet}/Sheet.demo.svelte +4 -17
- package/dist/components/Library/Sheet/Sheet.demo.svelte.d.ts +23 -0
- package/dist/components/Library/Sheet/Sheet.svelte +113 -0
- package/dist/components/{Sheet → Library/Sheet}/Sheet.svelte.d.ts +4 -2
- package/dist/components/{Slider.demo.svelte → Library/Slider/Slider.demo.svelte} +2 -3
- package/dist/components/{Slider.demo.svelte.d.ts → Library/Slider/Slider.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/Slider/Slider.svelte +122 -0
- package/dist/components/{Slider.svelte.d.ts → Library/Slider/Slider.svelte.d.ts} +2 -3
- package/dist/components/Library/Slider/index.d.ts +1 -0
- package/dist/components/Library/Slider/index.js +1 -0
- package/dist/components/{Spinner.demo.svelte → Library/Spinner/Spinner.demo.svelte} +3 -1
- package/dist/components/Library/Spinner/Spinner.svelte +32 -0
- package/dist/components/{Spinner.svelte.d.ts → Library/Spinner/Spinner.svelte.d.ts} +3 -2
- package/dist/components/Library/Spinner/index.d.ts +1 -0
- package/dist/components/Library/Spinner/index.js +1 -0
- package/dist/components/Library/Switch/Switch.demo.svelte +20 -0
- package/dist/components/Library/Switch/Switch.demo.svelte.d.ts +8 -0
- package/dist/components/Library/Switch/Switch.svelte +168 -0
- package/dist/components/Library/Switch/Switch.svelte.d.ts +11 -0
- package/dist/components/Library/Switch/index.d.ts +1 -0
- package/dist/components/Library/Switch/index.js +1 -0
- package/dist/components/Library/TextShimmer/TextShimmer.demo.svelte +14 -0
- package/dist/components/Library/TextShimmer/TextShimmer.demo.svelte.d.ts +23 -0
- package/dist/components/Library/TextShimmer/TextShimmer.svelte +88 -0
- package/dist/components/Library/TextShimmer/TextShimmer.svelte.d.ts +11 -0
- package/dist/components/Library/TextShimmer/index.d.ts +1 -0
- package/dist/components/Library/TextShimmer/index.js +1 -0
- package/dist/components/Library/TimePicker/TimePicker.demo.svelte +18 -0
- package/dist/components/Library/TimePicker/TimePicker.demo.svelte.d.ts +10 -0
- package/dist/components/Library/TimePicker/TimePicker.svelte +143 -0
- package/dist/components/Library/TimePicker/TimePicker.svelte.d.ts +13 -0
- package/dist/components/Library/TimePicker/index.d.ts +2 -0
- package/dist/components/Library/TimePicker/index.js +1 -0
- package/dist/components/{TokenSearchInput.demo.svelte → Library/TokenSearchInput/TokenSearchInput.demo.svelte} +1 -2
- package/dist/components/{TokenSearchInput.demo.svelte.d.ts → Library/TokenSearchInput/TokenSearchInput.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/TokenSearchInput/TokenSearchInput.svelte +230 -0
- package/dist/components/{TokenSearchInput.svelte.d.ts → Library/TokenSearchInput/TokenSearchInput.svelte.d.ts} +2 -3
- package/dist/components/Library/TokenSearchInput/index.d.ts +1 -0
- package/dist/components/Library/TokenSearchInput/index.js +1 -0
- package/dist/components/Library/Tooltip/Tooltip.demo.svelte +14 -0
- package/dist/components/{Tooltip.demo.svelte.d.ts → Library/Tooltip/Tooltip.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/Tooltip/index.d.ts +2 -0
- package/dist/components/Library/Tooltip/index.js +1 -0
- package/dist/components/Library/WheelPicker/WheelColumn.svelte +302 -0
- package/dist/components/Library/WheelPicker/WheelColumn.svelte.d.ts +29 -0
- package/dist/components/Library/WheelPicker/WheelPicker.svelte +114 -0
- package/dist/components/Library/WheelPicker/WheelPicker.svelte.d.ts +9 -0
- package/dist/components/Library/WheelPicker/index.d.ts +2 -0
- package/dist/components/Library/WheelPicker/index.js +1 -0
- package/dist/components/Library/WheelPicker/types.d.ts +10 -0
- package/dist/components/Library/WheelPicker/types.js +1 -0
- package/dist/components/Local/ComponentGrid.svelte +7 -6
- package/dist/components/Local/ComponentGrid.svelte.d.ts +1 -1
- package/dist/components/Local/HeroCard.svelte +18 -8
- package/dist/components/Local/HeroCard.svelte.d.ts +1 -1
- package/dist/components/Local/StyleControls.svelte +119 -0
- package/dist/components/Local/StyleControls.svelte.d.ts +15 -0
- package/dist/index.d.ts +24 -15
- package/dist/index.js +23 -15
- package/dist/style/index.css +61 -325
- package/dist/style/surface.d.ts +17 -0
- package/dist/style/surface.js +54 -0
- package/dist/style.css +86 -601
- package/dist/utils/positioning.d.ts +3 -2
- package/dist/utils/positioning.js +9 -5
- package/package.json +1 -1
- package/dist/components/AnimatedNumber.svelte +0 -18
- package/dist/components/AnimatedNumber.svelte.d.ts +0 -8
- package/dist/components/AsyncButton.svelte +0 -93
- package/dist/components/NavigationStack/NavigationStack.svelte +0 -76
- package/dist/components/NavigationStack/NavigationStack.svelte.d.ts +0 -10
- package/dist/components/NavigationStack/SidebarToggle.svelte +0 -36
- package/dist/components/NavigationStack/SidebarToggle.svelte.d.ts +0 -9
- package/dist/components/NavigationStack/Toolbar.svelte +0 -25
- package/dist/components/NavigationStack/Toolbar.svelte.d.ts +0 -9
- package/dist/components/Pagination.svelte +0 -144
- package/dist/components/Popover/Popover.demo.svelte +0 -35
- package/dist/components/Popover/Popover.svelte.d.ts +0 -13
- package/dist/components/Popover/index.d.ts +0 -2
- package/dist/components/Popover/index.js +0 -2
- package/dist/components/Popover/registry.svelte.d.ts +0 -18
- package/dist/components/SearchInput.svelte +0 -39
- package/dist/components/SegmentedPicker.svelte +0 -51
- package/dist/components/Sheet/Sheet.demo.svelte.d.ts +0 -8
- package/dist/components/Sheet/Sheet.svelte +0 -60
- package/dist/components/Slider.svelte +0 -47
- package/dist/components/Spinner.svelte +0 -7
- package/dist/components/TextShimmer.svelte +0 -60
- package/dist/components/TextShimmer.svelte.d.ts +0 -10
- package/dist/components/TokenSearchInput.svelte +0 -124
- package/dist/components/Tooltip.demo.svelte +0 -16
- package/dist/components/Tooltip.svelte +0 -79
- package/dist/components/Tooltip.svelte.d.ts +0 -12
- /package/dist/components/{AsyncButton.demo.svelte.d.ts → Library/AsyncButton/AsyncButton.demo.svelte.d.ts} +0 -0
- /package/dist/components/{NavigationStack → Library/NavigationStack}/index.d.ts +0 -0
- /package/dist/components/{NavigationStack → Library/NavigationStack}/index.js +0 -0
- /package/dist/components/{Popover → Library/Popover}/Popover.demo.svelte.d.ts +0 -0
- /package/dist/components/{Popover → Library/Popover}/PopoverDebugOverlay.svelte.d.ts +0 -0
- /package/dist/components/{Sheet → Library/Sheet}/index.d.ts +0 -0
- /package/dist/components/{Sheet → Library/Sheet}/index.js +0 -0
- /package/dist/components/{Spinner.demo.svelte.d.ts → Library/Spinner/Spinner.demo.svelte.d.ts} +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { portalContent } from '../../../actions/portal';
|
|
4
|
+
import { extractStyleProps, surfaceStyle, type StyleProps } from '../../../style/surface';
|
|
5
|
+
interface Props {
|
|
6
|
+
trigger?: Snippet;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
label?: string;
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
maxWidth?: string;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
trigger,
|
|
16
|
+
open = $bindable(false),
|
|
17
|
+
label = 'Dialog',
|
|
18
|
+
onClose,
|
|
19
|
+
maxWidth = '32rem',
|
|
20
|
+
children,
|
|
21
|
+
...restProps
|
|
22
|
+
}: Props & StyleProps & Record<string, unknown> = $props();
|
|
23
|
+
|
|
24
|
+
const extractedStyleProps = $derived.by(() => extractStyleProps(restProps));
|
|
25
|
+
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
26
|
+
const rootStyle = $derived.by(() => surfaceStyle(styleProps, 'sheet'));
|
|
27
|
+
const panelStyle = $derived.by(() => {
|
|
28
|
+
const declarations = [`max-width: ${maxWidth};`];
|
|
29
|
+
const stylePropDeclarations = surfaceStyle(styleProps, 'sheet');
|
|
30
|
+
if (stylePropDeclarations) declarations.push(stylePropDeclarations);
|
|
31
|
+
return declarations.join(' ');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
function close() {
|
|
35
|
+
if (!open) return;
|
|
36
|
+
open = false;
|
|
37
|
+
onClose?.();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function show() {
|
|
41
|
+
open = true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
$effect(() => {
|
|
45
|
+
if (!open) return;
|
|
46
|
+
const onKey = (event: KeyboardEvent) => {
|
|
47
|
+
if (event.key === 'Escape') close();
|
|
48
|
+
};
|
|
49
|
+
window.addEventListener('keydown', onKey);
|
|
50
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
51
|
+
});
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
{#if trigger}
|
|
55
|
+
<button type="button" class="sheet-trigger" style={rootStyle} onclick={show}>
|
|
56
|
+
{@render trigger()}
|
|
57
|
+
</button>
|
|
58
|
+
{/if}
|
|
59
|
+
|
|
60
|
+
{#if open}
|
|
61
|
+
<div class="center fixed inset-0 z-50 flex" use:portalContent>
|
|
62
|
+
<button
|
|
63
|
+
type="button"
|
|
64
|
+
aria-label="Close dialog"
|
|
65
|
+
class="sheet-overlay absolute inset-0"
|
|
66
|
+
onclick={close}
|
|
67
|
+
></button>
|
|
68
|
+
<div
|
|
69
|
+
role="dialog"
|
|
70
|
+
aria-modal="true"
|
|
71
|
+
aria-label={label}
|
|
72
|
+
style={panelStyle}
|
|
73
|
+
class="sheet relative z-10 flex max-h-full w-full flex-col overflow-auto"
|
|
74
|
+
>
|
|
75
|
+
<div class="flex-1">
|
|
76
|
+
{#if children}
|
|
77
|
+
{@render children()}
|
|
78
|
+
{/if}
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
{/if}
|
|
83
|
+
|
|
84
|
+
<style>
|
|
85
|
+
.sheet-trigger {
|
|
86
|
+
display: inline-flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
border: 1px solid var(--sveltely-border-color);
|
|
89
|
+
border-radius: var(--sveltely-border-radius);
|
|
90
|
+
background: white;
|
|
91
|
+
color: var(--color-zinc-800);
|
|
92
|
+
gap: var(--sveltely-gap);
|
|
93
|
+
padding: calc(var(--sveltely-padding-y) * 0.67) var(--sveltely-padding-x);
|
|
94
|
+
font-size: 0.875rem;
|
|
95
|
+
line-height: 1.25rem;
|
|
96
|
+
transition: color 150ms, border-color 150ms, background-color 150ms;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.sheet-trigger:hover {
|
|
100
|
+
background: var(--sveltely-hover-color);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.sheet {
|
|
104
|
+
border-radius: var(--sveltely-border-radius);
|
|
105
|
+
background: white;
|
|
106
|
+
padding: calc(var(--sveltely-padding-y) * 1.33) calc(var(--sveltely-padding-x) * 1.33);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.sheet-overlay {
|
|
110
|
+
background: rgb(0 0 0 / 0.2);
|
|
111
|
+
backdrop-filter: blur(4px);
|
|
112
|
+
}
|
|
113
|
+
</style>
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type StyleProps } from '../../../style/surface';
|
|
2
3
|
interface Props {
|
|
4
|
+
trigger?: Snippet;
|
|
3
5
|
open?: boolean;
|
|
4
6
|
label?: string;
|
|
5
7
|
onClose?: () => void;
|
|
6
|
-
class?: string;
|
|
7
8
|
maxWidth?: string;
|
|
8
9
|
children?: Snippet;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
type $$ComponentProps = Props & StyleProps & Record<string, unknown>;
|
|
12
|
+
declare const Sheet: import("svelte").Component<$$ComponentProps, {}, "open">;
|
|
11
13
|
type Sheet = ReturnType<typeof Sheet>;
|
|
12
14
|
export default Sheet;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
export const demo = {
|
|
3
3
|
name: 'Slider',
|
|
4
|
-
description: 'Range input with shared slider styling.'
|
|
5
|
-
isProminent: false
|
|
4
|
+
description: 'Range input with shared slider styling.'
|
|
6
5
|
};
|
|
7
6
|
</script>
|
|
8
7
|
|
|
@@ -13,6 +12,6 @@
|
|
|
13
12
|
</script>
|
|
14
13
|
|
|
15
14
|
<div class="vstack w-full max-w-sm gap-2">
|
|
16
|
-
<Slider bind:value min={0} max={100}
|
|
15
|
+
<Slider bind:value min={0} max={100} />
|
|
17
16
|
<p class="text-xs text-zinc-500">Value: {value}</p>
|
|
18
17
|
</div>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { extractStyleProps, surfaceStyle, type StyleProps } from '../../../style/surface';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
value = $bindable(0),
|
|
6
|
+
min = 0,
|
|
7
|
+
max = 100,
|
|
8
|
+
step = 1,
|
|
9
|
+
disabled = false,
|
|
10
|
+
...props
|
|
11
|
+
}: {
|
|
12
|
+
value?: number;
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
15
|
+
step?: number | string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
} & StyleProps & Record<string, unknown> = $props();
|
|
18
|
+
|
|
19
|
+
const extractedStyleProps = $derived.by(() => extractStyleProps(props));
|
|
20
|
+
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
21
|
+
const inputProps = $derived(extractedStyleProps.restProps);
|
|
22
|
+
|
|
23
|
+
const percent = $derived.by(() => {
|
|
24
|
+
const minValue = Number(min);
|
|
25
|
+
const maxValue = Number(max);
|
|
26
|
+
const currentValue = Number(value);
|
|
27
|
+
const range = maxValue - minValue;
|
|
28
|
+
if (!Number.isFinite(range) || range <= 0) return 0;
|
|
29
|
+
const raw = ((currentValue - minValue) / range) * 100;
|
|
30
|
+
return Math.max(0, Math.min(100, raw));
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const sliderStyle = $derived.by(() => {
|
|
34
|
+
const declarations = [`--slider-pct: ${percent}%;`];
|
|
35
|
+
const stylePropDeclarations = surfaceStyle(styleProps, 'slider');
|
|
36
|
+
if (stylePropDeclarations) declarations.push(stylePropDeclarations);
|
|
37
|
+
return declarations.join(' ');
|
|
38
|
+
});
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<input
|
|
42
|
+
type="range"
|
|
43
|
+
bind:value
|
|
44
|
+
{min}
|
|
45
|
+
{max}
|
|
46
|
+
{step}
|
|
47
|
+
{disabled}
|
|
48
|
+
class="slider"
|
|
49
|
+
style={sliderStyle}
|
|
50
|
+
{...inputProps}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
<style>
|
|
54
|
+
.slider {
|
|
55
|
+
--slider-track-height: 6px;
|
|
56
|
+
--slider-thumb-size: 16px;
|
|
57
|
+
--slider-thumb-ring-width: clamp(1px, calc((var(--sveltely-inset) * 0.333333) + 1px), 6px);
|
|
58
|
+
appearance: none;
|
|
59
|
+
width: 100%;
|
|
60
|
+
height: var(--slider-track-height);
|
|
61
|
+
border-radius: var(--sveltely-border-radius);
|
|
62
|
+
background: transparent;
|
|
63
|
+
outline: none;
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.slider:focus-visible {
|
|
68
|
+
outline: 2px solid color-mix(in oklab, var(--sveltely-primary-color) 35%, white);
|
|
69
|
+
outline-offset: 4px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.slider:disabled {
|
|
73
|
+
opacity: 0.5;
|
|
74
|
+
cursor: not-allowed;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.slider::-webkit-slider-runnable-track {
|
|
78
|
+
height: var(--slider-track-height);
|
|
79
|
+
border-radius: var(--sveltely-border-radius);
|
|
80
|
+
background: linear-gradient(
|
|
81
|
+
to right,
|
|
82
|
+
var(--sveltely-primary-color) 0%,
|
|
83
|
+
var(--sveltely-primary-color) var(--slider-pct),
|
|
84
|
+
var(--color-zinc-300) var(--slider-pct),
|
|
85
|
+
var(--color-zinc-300) 100%
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.slider::-webkit-slider-thumb {
|
|
90
|
+
appearance: none;
|
|
91
|
+
box-sizing: border-box;
|
|
92
|
+
width: var(--slider-thumb-size);
|
|
93
|
+
height: var(--slider-thumb-size);
|
|
94
|
+
border-radius: var(--sveltely-border-radius);
|
|
95
|
+
border: var(--slider-thumb-ring-width) solid var(--color-white);
|
|
96
|
+
background: var(--sveltely-primary-color);
|
|
97
|
+
margin-top: calc((var(--slider-track-height) - var(--slider-thumb-size)) / 2);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.slider::-moz-range-track {
|
|
101
|
+
height: var(--slider-track-height);
|
|
102
|
+
border: none;
|
|
103
|
+
border-radius: var(--sveltely-border-radius);
|
|
104
|
+
background: var(--color-zinc-300);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.slider::-moz-range-progress {
|
|
108
|
+
height: var(--slider-track-height);
|
|
109
|
+
border: none;
|
|
110
|
+
border-radius: var(--sveltely-border-radius);
|
|
111
|
+
background: var(--sveltely-primary-color);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.slider::-moz-range-thumb {
|
|
115
|
+
box-sizing: border-box;
|
|
116
|
+
width: var(--slider-thumb-size);
|
|
117
|
+
height: var(--slider-thumb-size);
|
|
118
|
+
border-radius: var(--sveltely-border-radius);
|
|
119
|
+
border: var(--slider-thumb-ring-width) solid var(--color-white);
|
|
120
|
+
background: var(--sveltely-primary-color);
|
|
121
|
+
}
|
|
122
|
+
</style>
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { type StyleProps } from '../../../style/surface';
|
|
1
2
|
type $$ComponentProps = {
|
|
2
3
|
value?: number;
|
|
3
4
|
min?: number;
|
|
4
5
|
max?: number;
|
|
5
6
|
step?: number | string;
|
|
6
7
|
disabled?: boolean;
|
|
7
|
-
|
|
8
|
-
style?: string;
|
|
9
|
-
} & Record<string, unknown>;
|
|
8
|
+
} & StyleProps & Record<string, unknown>;
|
|
10
9
|
declare const Slider: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
11
10
|
type Slider = ReturnType<typeof Slider>;
|
|
12
11
|
export default Slider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Slider.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Slider.svelte';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { LoaderIcon } from '@lucide/svelte';
|
|
3
|
+
import { extractStyleProps, surfaceStyle, type StyleProps } from '../../../style/surface';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
size = 'calc(var(--sveltely-font-size) * 1.143)',
|
|
7
|
+
...props
|
|
8
|
+
}: {
|
|
9
|
+
size?: number | string;
|
|
10
|
+
} & StyleProps & Record<string, unknown> = $props();
|
|
11
|
+
|
|
12
|
+
const extractedStyleProps = $derived.by(() => extractStyleProps(props));
|
|
13
|
+
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
14
|
+
const iconProps = $derived(extractedStyleProps.restProps);
|
|
15
|
+
const spinnerStyle = $derived.by(() => {
|
|
16
|
+
const declarations = [
|
|
17
|
+
`width: ${typeof size === 'number' ? `${size}px` : size};`,
|
|
18
|
+
`height: ${typeof size === 'number' ? `${size}px` : size};`
|
|
19
|
+
];
|
|
20
|
+
const stylePropDeclarations = surfaceStyle(styleProps, 'spinner');
|
|
21
|
+
if (stylePropDeclarations) declarations.push(stylePropDeclarations);
|
|
22
|
+
return declarations.join(' ');
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<LoaderIcon
|
|
27
|
+
role="status"
|
|
28
|
+
aria-label="Loading"
|
|
29
|
+
class="animate-spin"
|
|
30
|
+
style={spinnerStyle}
|
|
31
|
+
{...iconProps}
|
|
32
|
+
/>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { type StyleProps } from '../../../style/surface';
|
|
1
2
|
type $$ComponentProps = {
|
|
2
|
-
|
|
3
|
-
} & Record<string, unknown>;
|
|
3
|
+
size?: number | string;
|
|
4
|
+
} & StyleProps & Record<string, unknown>;
|
|
4
5
|
declare const Spinner: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
5
6
|
type Spinner = ReturnType<typeof Spinner>;
|
|
6
7
|
export default Spinner;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Spinner.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Spinner.svelte';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export const demo = {
|
|
3
|
+
name: 'Switch',
|
|
4
|
+
description: 'Token-driven switch with bindable checked state.'
|
|
5
|
+
};
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import Switch from './Switch.svelte';
|
|
10
|
+
|
|
11
|
+
let notificationsEnabled = $state(true);
|
|
12
|
+
let weeklySummaryEnabled = $state(false);
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div class="vstack gap-3">
|
|
16
|
+
<Switch bind:checked={notificationsEnabled} label="Enable notifications" />
|
|
17
|
+
<Switch bind:checked={weeklySummaryEnabled}>
|
|
18
|
+
<span>Send weekly summary email</span>
|
|
19
|
+
</Switch>
|
|
20
|
+
</div>
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
4
|
+
import { extractStyleProps, surfaceStyle, type StyleProps } from '../../../style/surface';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
checked?: boolean;
|
|
8
|
+
label?: string;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
} & StyleProps &
|
|
11
|
+
Omit<HTMLInputAttributes, 'type' | 'children' | 'class' | 'style' | 'checked'>;
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
checked = $bindable(false),
|
|
15
|
+
label,
|
|
16
|
+
children,
|
|
17
|
+
disabled = false,
|
|
18
|
+
...restProps
|
|
19
|
+
}: Props = $props();
|
|
20
|
+
|
|
21
|
+
const extractedStyleProps = $derived.by(() => extractStyleProps(restProps));
|
|
22
|
+
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
23
|
+
const props = $derived(extractedStyleProps.restProps);
|
|
24
|
+
const rootStyle = $derived.by(() => surfaceStyle(styleProps, 'switch'));
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<div
|
|
28
|
+
class="switch inline-flex items-center"
|
|
29
|
+
style={rootStyle}
|
|
30
|
+
data-disabled={disabled ? 'true' : 'false'}
|
|
31
|
+
>
|
|
32
|
+
<label class="switch-control">
|
|
33
|
+
<input bind:checked type="checkbox" {disabled} {...props} />
|
|
34
|
+
<span class="switch-track" aria-hidden="true">
|
|
35
|
+
<span class="switch-thumb"></span>
|
|
36
|
+
</span>
|
|
37
|
+
</label>
|
|
38
|
+
|
|
39
|
+
{#if children || label}
|
|
40
|
+
<span class="switch-label">
|
|
41
|
+
{#if children}
|
|
42
|
+
{@render children()}
|
|
43
|
+
{:else if label}
|
|
44
|
+
{label}
|
|
45
|
+
{/if}
|
|
46
|
+
</span>
|
|
47
|
+
{/if}
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<style>
|
|
51
|
+
.switch {
|
|
52
|
+
--switch-font-size: var(--sveltely-font-size);
|
|
53
|
+
--switch-scale: calc(var(--switch-font-size) / 1rem);
|
|
54
|
+
--switch-height: calc(
|
|
55
|
+
(var(--switch-font-size) * 0.92) + (var(--sveltely-padding-y) * 0.45 * var(--switch-scale))
|
|
56
|
+
);
|
|
57
|
+
--switch-width: calc(var(--switch-height) * 1.7);
|
|
58
|
+
--switch-resolved-inset: calc(var(--switch-inset, var(--sveltely-inset)) * 0.333333);
|
|
59
|
+
--switch-thumb-inset: min(var(--switch-resolved-inset), calc(var(--switch-height) * 0.16));
|
|
60
|
+
--switch-border-width: 1px;
|
|
61
|
+
--switch-resolved-border-radius: var(--switch-border-radius, var(--sveltely-border-radius));
|
|
62
|
+
--switch-inner-height: calc(var(--switch-height) - (var(--switch-border-width) * 2));
|
|
63
|
+
--switch-resolved-thumb-border-radius: clamp(
|
|
64
|
+
0rem,
|
|
65
|
+
calc(var(--switch-resolved-border-radius) - var(--switch-thumb-inset)),
|
|
66
|
+
var(--switch-resolved-border-radius)
|
|
67
|
+
);
|
|
68
|
+
--switch-thumb-size: calc(var(--switch-inner-height) - (var(--switch-thumb-inset) * 2));
|
|
69
|
+
--switch-thumb-left: var(--switch-thumb-inset);
|
|
70
|
+
--switch-thumb-left-checked: calc(
|
|
71
|
+
var(--switch-width) - (var(--switch-border-width) * 2) - var(--switch-thumb-size) -
|
|
72
|
+
var(--switch-thumb-inset)
|
|
73
|
+
);
|
|
74
|
+
gap: var(--switch-gap, var(--sveltely-gap));
|
|
75
|
+
font-size: var(--switch-font-size);
|
|
76
|
+
line-height: 1.25;
|
|
77
|
+
color: var(--switch-color, var(--color-zinc-800));
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
user-select: none;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.switch[data-disabled='true'] {
|
|
83
|
+
cursor: not-allowed;
|
|
84
|
+
opacity: 0.5;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.switch-control {
|
|
88
|
+
cursor: inherit;
|
|
89
|
+
display: inline-block;
|
|
90
|
+
position: relative;
|
|
91
|
+
flex: 0 0 auto;
|
|
92
|
+
width: var(--switch-width);
|
|
93
|
+
height: var(--switch-height);
|
|
94
|
+
box-sizing: border-box;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.switch-control input {
|
|
98
|
+
position: absolute;
|
|
99
|
+
inset: 0;
|
|
100
|
+
margin: 0;
|
|
101
|
+
opacity: 0;
|
|
102
|
+
cursor: inherit;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.switch-track {
|
|
106
|
+
display: block;
|
|
107
|
+
width: 100%;
|
|
108
|
+
height: 100%;
|
|
109
|
+
border: var(--switch-border-width) solid var(--switch-border-color, var(--sveltely-border-color));
|
|
110
|
+
border-radius: var(--switch-resolved-border-radius);
|
|
111
|
+
background: var(--switch-background, var(--sveltely-inactive-color));
|
|
112
|
+
box-sizing: border-box;
|
|
113
|
+
position: relative;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
transition:
|
|
116
|
+
border-color 150ms,
|
|
117
|
+
background-color 150ms;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.switch-thumb {
|
|
121
|
+
display: block;
|
|
122
|
+
position: absolute;
|
|
123
|
+
left: var(--switch-thumb-left);
|
|
124
|
+
top: var(--switch-thumb-inset);
|
|
125
|
+
width: var(--switch-thumb-size);
|
|
126
|
+
height: var(--switch-thumb-size);
|
|
127
|
+
box-sizing: border-box;
|
|
128
|
+
border-radius: var(--switch-thumb-border-radius, var(--switch-resolved-thumb-border-radius));
|
|
129
|
+
background: var(--switch-thumb-background, white);
|
|
130
|
+
transition:
|
|
131
|
+
left 180ms ease,
|
|
132
|
+
background-color 150ms;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.switch:hover .switch-track {
|
|
136
|
+
background: var(--switch-hover-background, var(--sveltely-inactive-hover-color));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.switch-control input:checked + .switch-track {
|
|
140
|
+
border-color: var(--switch-checked-border-color, var(--sveltely-active-color));
|
|
141
|
+
background: var(--switch-checked-background, var(--sveltely-active-color));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.switch:hover .switch-control input:checked + .switch-track {
|
|
145
|
+
border-color: var(
|
|
146
|
+
--switch-checked-hover-border-color,
|
|
147
|
+
var(--sveltely-active-hover-color)
|
|
148
|
+
);
|
|
149
|
+
background: var(
|
|
150
|
+
--switch-checked-hover-background,
|
|
151
|
+
var(--sveltely-active-hover-color)
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.switch-control input:checked + .switch-track .switch-thumb {
|
|
156
|
+
background: var(--switch-checked-thumb-background, white);
|
|
157
|
+
left: var(--switch-thumb-left-checked);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.switch-control input:focus-visible + .switch-track {
|
|
161
|
+
outline: 2px solid color-mix(in oklab, var(--sveltely-primary-color) 24%, white);
|
|
162
|
+
outline-offset: 2px;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.switch-label {
|
|
166
|
+
min-width: 0;
|
|
167
|
+
}
|
|
168
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
3
|
+
import { type StyleProps } from '../../../style/surface';
|
|
4
|
+
type Props = {
|
|
5
|
+
checked?: boolean;
|
|
6
|
+
label?: string;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
} & StyleProps & Omit<HTMLInputAttributes, 'type' | 'children' | 'class' | 'style' | 'checked'>;
|
|
9
|
+
declare const Switch: import("svelte").Component<Props, {}, "checked">;
|
|
10
|
+
type Switch = ReturnType<typeof Switch>;
|
|
11
|
+
export default Switch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Switch.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Switch.svelte';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export const demo = {
|
|
3
|
+
name: 'TextShimmer',
|
|
4
|
+
description: 'Animated shimmering text that follows the global font-size token.'
|
|
5
|
+
};
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import TextShimmer from './TextShimmer.svelte';
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<div class="vstack gap-2">
|
|
13
|
+
<TextShimmer as="h2" text="Sveltely shimmer" />
|
|
14
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const demo: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
};
|
|
5
|
+
import TextShimmer from './TextShimmer.svelte';
|
|
6
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
7
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
8
|
+
$$bindings?: Bindings;
|
|
9
|
+
} & Exports;
|
|
10
|
+
(internal: unknown, props: {
|
|
11
|
+
$$events?: Events;
|
|
12
|
+
$$slots?: Slots;
|
|
13
|
+
}): Exports & {
|
|
14
|
+
$set?: any;
|
|
15
|
+
$on?: any;
|
|
16
|
+
};
|
|
17
|
+
z_$$bindings?: Bindings;
|
|
18
|
+
}
|
|
19
|
+
declare const TextShimmer: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
}, {}, {}, string>;
|
|
22
|
+
type TextShimmer = InstanceType<typeof TextShimmer>;
|
|
23
|
+
export default TextShimmer;
|