uisv 0.0.12 → 0.0.13
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/components/accordion.svelte +108 -0
- package/dist/components/accordion.svelte.d.ts +58 -0
- package/dist/components/alert.svelte +271 -0
- package/dist/components/alert.svelte.d.ts +23 -0
- package/dist/components/badge.svelte +225 -0
- package/dist/components/badge.svelte.d.ts +19 -0
- package/dist/components/banner.svelte +254 -0
- package/dist/components/banner.svelte.d.ts +23 -0
- package/dist/components/button/button.svelte +105 -0
- package/dist/components/button/button.svelte.d.ts +4 -0
- package/dist/components/button/index.d.ts +48 -0
- package/dist/components/button/index.js +4 -0
- package/dist/components/button/style.d.ts +148 -0
- package/dist/components/button/style.js +248 -0
- package/dist/components/card.svelte +70 -0
- package/dist/components/card.svelte.d.ts +17 -0
- package/dist/components/checkbox-group.svelte +258 -0
- package/dist/components/checkbox-group.svelte.d.ts +26 -0
- package/dist/components/checkbox.svelte +175 -0
- package/dist/components/checkbox.svelte.d.ts +27 -0
- package/dist/components/chip.svelte +82 -0
- package/dist/components/chip.svelte.d.ts +17 -0
- package/dist/components/color-picker.svelte +48 -0
- package/dist/components/color-picker.svelte.d.ts +10 -0
- package/dist/components/h1.svelte +15 -0
- package/dist/components/h1.svelte.d.ts +3 -0
- package/dist/components/h2.svelte +19 -0
- package/dist/components/h2.svelte.d.ts +3 -0
- package/dist/components/h3.svelte +16 -0
- package/dist/components/h3.svelte.d.ts +3 -0
- package/dist/components/h4.svelte +19 -0
- package/dist/components/h4.svelte.d.ts +3 -0
- package/dist/components/h5.svelte +19 -0
- package/dist/components/h5.svelte.d.ts +3 -0
- package/dist/components/h6.svelte +19 -0
- package/dist/components/h6.svelte.d.ts +3 -0
- package/dist/components/index.d.ts +42 -0
- package/dist/components/index.js +42 -0
- package/dist/components/input/index.d.ts +54 -0
- package/dist/components/input/index.js +2 -0
- package/dist/components/input/input.svelte +103 -0
- package/dist/components/input/input.svelte.d.ts +4 -0
- package/dist/components/input/style.d.ts +316 -0
- package/dist/components/input/style.js +128 -0
- package/dist/components/input-time/index.d.ts +375 -0
- package/dist/components/input-time/index.js +144 -0
- package/dist/components/input-time/input-time.svelte +39 -0
- package/dist/components/input-time/input-time.svelte.d.ts +4 -0
- package/dist/components/kbd.svelte +239 -0
- package/dist/components/kbd.svelte.d.ts +40 -0
- package/dist/components/p.svelte +9 -0
- package/dist/components/p.svelte.d.ts +3 -0
- package/dist/components/pin-input.svelte +162 -0
- package/dist/components/pin-input.svelte.d.ts +25 -0
- package/dist/components/placeholder.svelte +34 -0
- package/dist/components/placeholder.svelte.d.ts +3 -0
- package/dist/components/popover.svelte +151 -0
- package/dist/components/popover.svelte.d.ts +88 -0
- package/dist/components/progress.svelte +124 -0
- package/dist/components/progress.svelte.d.ts +21 -0
- package/dist/components/select.svelte +171 -0
- package/dist/components/select.svelte.d.ts +50 -0
- package/dist/components/slider.svelte +172 -0
- package/dist/components/slider.svelte.d.ts +44 -0
- package/dist/components/switch.svelte +180 -0
- package/dist/components/switch.svelte.d.ts +27 -0
- package/dist/components/tabs.svelte +246 -0
- package/dist/components/tabs.svelte.d.ts +34 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/utilities.svelte.d.ts +24 -0
- package/dist/utilities.svelte.js +47 -0
- package/dist/vite.d.ts +51 -0
- package/dist/vite.js +157 -0
- package/package.json +2 -2
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
|
+
import { Popover, type PopoverContentProps } from 'bits-ui';
|
|
4
|
+
import { type ButtonProps } from '../index.js';
|
|
5
|
+
import type { PropColor } from '../index.js';
|
|
6
|
+
export type PopoverContentSnippet = {
|
|
7
|
+
props: Record<string, unknown>;
|
|
8
|
+
open: boolean;
|
|
9
|
+
wrapperProps: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
export type PopoverProps = {
|
|
12
|
+
/**
|
|
13
|
+
* The display mode of the popover.
|
|
14
|
+
*/
|
|
15
|
+
mode?: 'hover' | 'click';
|
|
16
|
+
/**
|
|
17
|
+
* The props for the content of popover.
|
|
18
|
+
*/
|
|
19
|
+
contentprops?: PopoverContentProps;
|
|
20
|
+
content?: Snippet<[PopoverContentSnippet]>;
|
|
21
|
+
children?: Snippet<[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Snippet if you want to implement your own trigger button
|
|
24
|
+
*/
|
|
25
|
+
trigger?: Snippet<[Record<string, unknown>]>;
|
|
26
|
+
/**
|
|
27
|
+
* Display an arrow alongside the popover.
|
|
28
|
+
*/
|
|
29
|
+
arrow?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Render the popover in a portal.
|
|
32
|
+
*/
|
|
33
|
+
portal?: string | false | true | HTMLElement;
|
|
34
|
+
/**
|
|
35
|
+
* The reference (or anchor) element that is being referred to for positioning. If not provided will use the current component as anchor.
|
|
36
|
+
*/
|
|
37
|
+
reference?: Element | {
|
|
38
|
+
getBoundingClientRect: () => DOMRect;
|
|
39
|
+
getClientRects: () => DOMRect[];
|
|
40
|
+
contextElement?: Element;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* When `false`, the popover will not close when clicking outside or pressing escape.
|
|
44
|
+
*/
|
|
45
|
+
dismissible?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The open state of the popover when it is initially rendered. Use when you do not need to control its open state.
|
|
48
|
+
*/
|
|
49
|
+
defaultopen?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The controlled open state of the popover.
|
|
52
|
+
*/
|
|
53
|
+
open?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The modality of the popover. When set to `true`, interaction with outside elements will be disabled and only popover content will be visible to screen readers.
|
|
56
|
+
*/
|
|
57
|
+
modal?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The duration from when the mouse enters the trigger until the hover card opens.
|
|
60
|
+
*/
|
|
61
|
+
opendelay?: number;
|
|
62
|
+
/**
|
|
63
|
+
* The duration from when the mouse leaves the trigger or content until the hover card closes.
|
|
64
|
+
*/
|
|
65
|
+
closedelay?: number;
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
ui?: {
|
|
70
|
+
content?: ClassNameValue;
|
|
71
|
+
arrow?: ClassNameValue;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* @default `outline`
|
|
75
|
+
*/
|
|
76
|
+
variant?: ButtonProps['variant'];
|
|
77
|
+
/**
|
|
78
|
+
* @default primary
|
|
79
|
+
*/
|
|
80
|
+
color?: PropColor;
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
class?: ClassNameValue;
|
|
85
|
+
};
|
|
86
|
+
declare const Popover: import("svelte").Component<PopoverProps, {}, "open">;
|
|
87
|
+
type Popover = ReturnType<typeof Popover>;
|
|
88
|
+
export default Popover;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { PropColor } from '../index.js';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
import { tv } from 'tailwind-variants';
|
|
5
|
+
|
|
6
|
+
export type ProgressProps = {
|
|
7
|
+
value?: number;
|
|
8
|
+
max?: number | string[];
|
|
9
|
+
animation?: 'swing' | 'carousel' | 'carousel-inverse' | 'elastic';
|
|
10
|
+
orientation?: 'horizontal' | 'veritcal';
|
|
11
|
+
color?: PropColor;
|
|
12
|
+
height?: number;
|
|
13
|
+
inverted?: boolean;
|
|
14
|
+
status?: boolean;
|
|
15
|
+
ui?: {
|
|
16
|
+
base?: ClassNameValue;
|
|
17
|
+
header?: ClassNameValue;
|
|
18
|
+
content?: ClassNameValue;
|
|
19
|
+
footer?: ClassNameValue;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
let {
|
|
26
|
+
max,
|
|
27
|
+
animation,
|
|
28
|
+
inverted,
|
|
29
|
+
status,
|
|
30
|
+
value,
|
|
31
|
+
orientation = 'horizontal',
|
|
32
|
+
color = 'primary',
|
|
33
|
+
height = '',
|
|
34
|
+
ui = {}
|
|
35
|
+
}: ProgressProps = $props();
|
|
36
|
+
|
|
37
|
+
const percentage = $derived.by(() => {
|
|
38
|
+
if (value === undefined) return null;
|
|
39
|
+
if (Array.isArray(max)) return (value / (max.length - 1)) * 100;
|
|
40
|
+
|
|
41
|
+
return (value / (max || 100)) * 100;
|
|
42
|
+
});
|
|
43
|
+
const indeterminate = $derived.by(() => {
|
|
44
|
+
if (value === undefined || percentage === null) return true;
|
|
45
|
+
if (value < 0) return true;
|
|
46
|
+
if (percentage > 100) return true;
|
|
47
|
+
|
|
48
|
+
return false;
|
|
49
|
+
});
|
|
50
|
+
const classes = $derived.by(() =>
|
|
51
|
+
tv({
|
|
52
|
+
slots: {
|
|
53
|
+
root: 'relative w-full rounded-full overflow-hidden bg-surface-300',
|
|
54
|
+
status: '',
|
|
55
|
+
indicator: 'absolute transition-all rounded-full',
|
|
56
|
+
steps: ''
|
|
57
|
+
},
|
|
58
|
+
variants: {
|
|
59
|
+
color: {
|
|
60
|
+
primary: {
|
|
61
|
+
indicator: 'bg-primary-500'
|
|
62
|
+
},
|
|
63
|
+
surface: {
|
|
64
|
+
indicator: 'bg-surface-500'
|
|
65
|
+
},
|
|
66
|
+
info: {
|
|
67
|
+
indicator: 'bg-info-500'
|
|
68
|
+
},
|
|
69
|
+
success: {
|
|
70
|
+
indicator: 'bg-success-500'
|
|
71
|
+
},
|
|
72
|
+
warning: {
|
|
73
|
+
indicator: 'bg-warning-500'
|
|
74
|
+
},
|
|
75
|
+
error: {
|
|
76
|
+
indicator: 'bg-error-500'
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
animation: {
|
|
80
|
+
swing: [indeterminate ? 'animate-[swing_2s_ease-in-out_infinite' : ''],
|
|
81
|
+
carousel: [indeterminate ? '' : ''],
|
|
82
|
+
'carousel-inverse': [indeterminate ? '' : ''],
|
|
83
|
+
elastic: [indeterminate ? '' : '']
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
compoundVariants: []
|
|
87
|
+
})({
|
|
88
|
+
color,
|
|
89
|
+
animation: animation ?? 'swing'
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<div data-state-indeterminate={indeterminate}>
|
|
95
|
+
<div class={classes.root({ class: [ui.base] })} style:height={`${height || 8}px`}>
|
|
96
|
+
<span class={classes.indicator({ class: ['h-full left-0'] })} style:width={`${percentage}%`}>
|
|
97
|
+
</span>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
{#if Array.isArray(max)}
|
|
101
|
+
<p
|
|
102
|
+
class={[
|
|
103
|
+
'text-right transition',
|
|
104
|
+
value && value > 0 && max[value] ? 'text-primary-500' : 'text-surface-500'
|
|
105
|
+
]}
|
|
106
|
+
>
|
|
107
|
+
{(value && max[value]) || max[0]}
|
|
108
|
+
</p>
|
|
109
|
+
{/if}
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
<style>
|
|
113
|
+
@keyframe swing {
|
|
114
|
+
0% {
|
|
115
|
+
width: 0%;
|
|
116
|
+
}
|
|
117
|
+
50% {
|
|
118
|
+
width: 100%;
|
|
119
|
+
}
|
|
120
|
+
100% {
|
|
121
|
+
width: 0%;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PropColor } from '../index.js';
|
|
2
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
|
+
export type ProgressProps = {
|
|
4
|
+
value?: number;
|
|
5
|
+
max?: number | string[];
|
|
6
|
+
animation?: 'swing' | 'carousel' | 'carousel-inverse' | 'elastic';
|
|
7
|
+
orientation?: 'horizontal' | 'veritcal';
|
|
8
|
+
color?: PropColor;
|
|
9
|
+
height?: number;
|
|
10
|
+
inverted?: boolean;
|
|
11
|
+
status?: boolean;
|
|
12
|
+
ui?: {
|
|
13
|
+
base?: ClassNameValue;
|
|
14
|
+
header?: ClassNameValue;
|
|
15
|
+
content?: ClassNameValue;
|
|
16
|
+
footer?: ClassNameValue;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
declare const Progress: import("svelte").Component<ProgressProps, {}, "">;
|
|
20
|
+
type Progress = ReturnType<typeof Progress>;
|
|
21
|
+
export default Progress;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { PropColor } from '../index.js';
|
|
3
|
+
import { Select } from 'bits-ui';
|
|
4
|
+
import type { Component, Snippet } from 'svelte';
|
|
5
|
+
import { tv } from 'tailwind-variants';
|
|
6
|
+
|
|
7
|
+
export type SelectItem<T> =
|
|
8
|
+
| T
|
|
9
|
+
| {
|
|
10
|
+
icon?: string | Component;
|
|
11
|
+
label: string | Component;
|
|
12
|
+
value: T;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type SelectProps<T> = {
|
|
16
|
+
items: (SelectItem<T> | SelectItem<T>[])[];
|
|
17
|
+
defaultvalue?: T;
|
|
18
|
+
item?: Snippet<[{ item: SelectItem<T> }]>;
|
|
19
|
+
color?: PropColor;
|
|
20
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
21
|
+
variant?: 'outline' | 'soft' | 'subtle' | 'ghost' | 'none';
|
|
22
|
+
highlight?: boolean;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
} & (
|
|
25
|
+
| {
|
|
26
|
+
value?: T;
|
|
27
|
+
type?: 'single';
|
|
28
|
+
}
|
|
29
|
+
| {
|
|
30
|
+
value?: T[];
|
|
31
|
+
type?: 'multiple';
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<script lang="ts" generics="T extends unknown">
|
|
37
|
+
let {
|
|
38
|
+
value = $bindable(),
|
|
39
|
+
items,
|
|
40
|
+
type = 'single',
|
|
41
|
+
defaultvalue,
|
|
42
|
+
item,
|
|
43
|
+
color = 'primary',
|
|
44
|
+
size = 'md',
|
|
45
|
+
variant = 'outline',
|
|
46
|
+
highlight,
|
|
47
|
+
placeholder,
|
|
48
|
+
}: SelectProps<T> = $props();
|
|
49
|
+
|
|
50
|
+
const classes = $derived(
|
|
51
|
+
tv({
|
|
52
|
+
slots: {
|
|
53
|
+
trigger: 'transition-all rounded w-48 flex items-center justify-between',
|
|
54
|
+
},
|
|
55
|
+
variants: {
|
|
56
|
+
color: {
|
|
57
|
+
primary: {
|
|
58
|
+
trigger: 'outline-primary focus:(border-primary)',
|
|
59
|
+
},
|
|
60
|
+
surface: {
|
|
61
|
+
trigger: 'outline-surface focus:(border-surface)',
|
|
62
|
+
},
|
|
63
|
+
info: {
|
|
64
|
+
trigger: 'outline-info focus:(border-info)',
|
|
65
|
+
},
|
|
66
|
+
success: {
|
|
67
|
+
trigger: 'outline-success focus:(border-success)',
|
|
68
|
+
},
|
|
69
|
+
warning: {
|
|
70
|
+
trigger: 'outline-warning focus:(border-warning)',
|
|
71
|
+
},
|
|
72
|
+
error: {
|
|
73
|
+
trigger: 'outline-error focus:(border-error)',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
size: {
|
|
77
|
+
xs: {
|
|
78
|
+
trigger: 'h-6 px-1 text-xs gap-1',
|
|
79
|
+
},
|
|
80
|
+
sm: {
|
|
81
|
+
trigger: 'h-7 px-2 text-xs gap-1',
|
|
82
|
+
},
|
|
83
|
+
md: {
|
|
84
|
+
trigger: 'h-8 px-2 text-sm gap-2 ',
|
|
85
|
+
},
|
|
86
|
+
lg: {
|
|
87
|
+
trigger: 'h-9 px-3 text-sm gap-3',
|
|
88
|
+
},
|
|
89
|
+
xl: {
|
|
90
|
+
trigger: 'h-10 px-3 gap-4',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
variant: {
|
|
94
|
+
outline: {
|
|
95
|
+
trigger: 'border border-surface-accented focus:(outline)',
|
|
96
|
+
},
|
|
97
|
+
soft: {
|
|
98
|
+
trigger: 'bg-surface-elevated',
|
|
99
|
+
},
|
|
100
|
+
subtle: {
|
|
101
|
+
trigger: 'bg-surface-elevated border border-surface-accented focus:(outline)',
|
|
102
|
+
},
|
|
103
|
+
ghost: {
|
|
104
|
+
trigger: 'hover:bg-surface-elevated',
|
|
105
|
+
},
|
|
106
|
+
none: {},
|
|
107
|
+
},
|
|
108
|
+
placeholder: {
|
|
109
|
+
true: { trigger: 'text-muted' },
|
|
110
|
+
false: {},
|
|
111
|
+
},
|
|
112
|
+
highlight: {
|
|
113
|
+
true: {
|
|
114
|
+
trigger: 'border',
|
|
115
|
+
},
|
|
116
|
+
false: {},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
compoundVariants: [
|
|
120
|
+
{ color: 'primary', highlight: true, class: { trigger: 'border-primary-500' } },
|
|
121
|
+
{ color: 'surface', highlight: true, class: { trigger: 'border-surface-500' } },
|
|
122
|
+
{ color: 'info', highlight: true, class: { trigger: 'border-info-500' } },
|
|
123
|
+
{ color: 'success', highlight: true, class: { trigger: 'border-success-500' } },
|
|
124
|
+
{ color: 'warning', highlight: true, class: { trigger: 'border-warning-500' } },
|
|
125
|
+
{ color: 'error', highlight: true, class: { trigger: 'border-error-500' } },
|
|
126
|
+
],
|
|
127
|
+
})({ size, color, variant, placeholder: !!placeholder, highlight }),
|
|
128
|
+
);
|
|
129
|
+
</script>
|
|
130
|
+
|
|
131
|
+
{/* @ts-expect-error idek */ null}
|
|
132
|
+
<Select.Root
|
|
133
|
+
{type}
|
|
134
|
+
bind:value={
|
|
135
|
+
() => {
|
|
136
|
+
if (type === 'single') return value as string | string[];
|
|
137
|
+
return value as string | string[];
|
|
138
|
+
},
|
|
139
|
+
(v) => (value = v as T | T[] | undefined)
|
|
140
|
+
}
|
|
141
|
+
>
|
|
142
|
+
<Select.Trigger class={classes.trigger()}>
|
|
143
|
+
{value || placeholder}
|
|
144
|
+
<div class="i-lucide-chevron-down size-4"></div>
|
|
145
|
+
</Select.Trigger>
|
|
146
|
+
<Select.Portal>
|
|
147
|
+
<Select.Content class="bg-red">
|
|
148
|
+
<Select.ScrollUpButton />
|
|
149
|
+
<Select.Viewport>
|
|
150
|
+
{#each items as item, idx (idx)}
|
|
151
|
+
{#if Array.isArray(item)}
|
|
152
|
+
<Select.Group>
|
|
153
|
+
<Select.GroupHeading />
|
|
154
|
+
|
|
155
|
+
{#each item as group_item, gidx (gidx)}
|
|
156
|
+
<Select.Item value=""></Select.Item>
|
|
157
|
+
{/each}
|
|
158
|
+
</Select.Group>
|
|
159
|
+
{:else}
|
|
160
|
+
{@const is_object = typeof item === 'object' && item !== null && 'value' in item}
|
|
161
|
+
<Select.Item value={(is_object ? item.value : item) as string}>
|
|
162
|
+
{item}
|
|
163
|
+
</Select.Item>
|
|
164
|
+
{/if}
|
|
165
|
+
{/each}
|
|
166
|
+
|
|
167
|
+
<Select.ScrollDownButton />
|
|
168
|
+
</Select.Viewport>
|
|
169
|
+
</Select.Content>
|
|
170
|
+
</Select.Portal>
|
|
171
|
+
</Select.Root>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { PropColor } from '../index.js';
|
|
2
|
+
import { Select } from 'bits-ui';
|
|
3
|
+
import type { Component, Snippet } from 'svelte';
|
|
4
|
+
export type SelectItem<T> = T | {
|
|
5
|
+
icon?: string | Component;
|
|
6
|
+
label: string | Component;
|
|
7
|
+
value: T;
|
|
8
|
+
};
|
|
9
|
+
export type SelectProps<T> = {
|
|
10
|
+
items: (SelectItem<T> | SelectItem<T>[])[];
|
|
11
|
+
defaultvalue?: T;
|
|
12
|
+
item?: Snippet<[{
|
|
13
|
+
item: SelectItem<T>;
|
|
14
|
+
}]>;
|
|
15
|
+
color?: PropColor;
|
|
16
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
17
|
+
variant?: 'outline' | 'soft' | 'subtle' | 'ghost' | 'none';
|
|
18
|
+
highlight?: boolean;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
} & ({
|
|
21
|
+
value?: T;
|
|
22
|
+
type?: 'single';
|
|
23
|
+
} | {
|
|
24
|
+
value?: T[];
|
|
25
|
+
type?: 'multiple';
|
|
26
|
+
});
|
|
27
|
+
declare function $$render<T extends unknown>(): {
|
|
28
|
+
props: SelectProps<T>;
|
|
29
|
+
exports: {};
|
|
30
|
+
bindings: "value";
|
|
31
|
+
slots: {};
|
|
32
|
+
events: {};
|
|
33
|
+
};
|
|
34
|
+
declare class __sveltets_Render<T extends unknown> {
|
|
35
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
36
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
37
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
38
|
+
bindings(): "value";
|
|
39
|
+
exports(): {};
|
|
40
|
+
}
|
|
41
|
+
interface $$IsomorphicComponent {
|
|
42
|
+
new <T extends unknown>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
43
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
44
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
45
|
+
<T extends unknown>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
46
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
47
|
+
}
|
|
48
|
+
declare const Select: $$IsomorphicComponent;
|
|
49
|
+
type Select<T extends unknown> = InstanceType<typeof Select<T>>;
|
|
50
|
+
export default Select;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { Slider } from 'bits-ui';
|
|
3
|
+
import type { PropColor } from '../index.js';
|
|
4
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
5
|
+
import { tv } from 'tailwind-variants';
|
|
6
|
+
|
|
7
|
+
export type SliderProps<T> = {
|
|
8
|
+
value?: T;
|
|
9
|
+
default?: number | number[];
|
|
10
|
+
color?: PropColor;
|
|
11
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
thumblabel?: boolean;
|
|
14
|
+
orientation?: 'vertical' | 'horizontal';
|
|
15
|
+
step?: number;
|
|
16
|
+
min?: number;
|
|
17
|
+
max?: number;
|
|
18
|
+
ui?: {
|
|
19
|
+
root?: ClassNameValue;
|
|
20
|
+
range?: ClassNameValue;
|
|
21
|
+
thumb?: ClassNameValue;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<script lang="ts" generics="T extends number | number[]">
|
|
27
|
+
let {
|
|
28
|
+
value = $bindable(),
|
|
29
|
+
default: def_value = 0,
|
|
30
|
+
color = 'primary',
|
|
31
|
+
size = 'md',
|
|
32
|
+
disabled,
|
|
33
|
+
thumblabel,
|
|
34
|
+
orientation = 'horizontal',
|
|
35
|
+
step,
|
|
36
|
+
min,
|
|
37
|
+
max,
|
|
38
|
+
ui = {}
|
|
39
|
+
}: SliderProps<T> = $props();
|
|
40
|
+
|
|
41
|
+
const default_value = $derived.by(() => {
|
|
42
|
+
if (typeof def_value === 'number') return [def_value];
|
|
43
|
+
|
|
44
|
+
return def_value;
|
|
45
|
+
});
|
|
46
|
+
let slider_value = $derived({
|
|
47
|
+
get() {
|
|
48
|
+
if (typeof value === 'number') return [value];
|
|
49
|
+
|
|
50
|
+
return (value as number[]) ?? default_value;
|
|
51
|
+
},
|
|
52
|
+
set(v: number[]) {
|
|
53
|
+
value = (v?.length !== 1 ? v : v[0]) as T;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
const thumbs = $derived(slider_value.get()?.length ?? 1);
|
|
57
|
+
const classes = $derived.by(() =>
|
|
58
|
+
tv({
|
|
59
|
+
slots: {
|
|
60
|
+
root: [
|
|
61
|
+
'relative w-full flex rounded-full bg-neutral-300',
|
|
62
|
+
orientation === 'horizontal' ? 'items-center' : 'justify-center mx-1'
|
|
63
|
+
],
|
|
64
|
+
range: [
|
|
65
|
+
'rounded-full bg-neutral-200 p-0.5 relative transition',
|
|
66
|
+
orientation === 'horizontal' ? 'h-full' : 'w-full'
|
|
67
|
+
],
|
|
68
|
+
thumb: 'bg-white rounded-full border-2 outline-none transition',
|
|
69
|
+
tick: ''
|
|
70
|
+
},
|
|
71
|
+
variants: {
|
|
72
|
+
color: {
|
|
73
|
+
primary: {
|
|
74
|
+
root: '',
|
|
75
|
+
range: 'bg-primary-500',
|
|
76
|
+
thumb: 'border-primary-500'
|
|
77
|
+
},
|
|
78
|
+
surface: {
|
|
79
|
+
range: ['bg-neutral-900'],
|
|
80
|
+
thumb: 'border-neutral-900'
|
|
81
|
+
},
|
|
82
|
+
info: {
|
|
83
|
+
range: ['bg-info-500'],
|
|
84
|
+
thumb: 'border-info-500'
|
|
85
|
+
},
|
|
86
|
+
success: {
|
|
87
|
+
range: ['bg-success-500'],
|
|
88
|
+
thumb: 'border-success-500'
|
|
89
|
+
},
|
|
90
|
+
warning: {
|
|
91
|
+
range: ['bg-warning-500'],
|
|
92
|
+
thumb: 'border-warning-500'
|
|
93
|
+
},
|
|
94
|
+
error: {
|
|
95
|
+
range: ['bg-error-500'],
|
|
96
|
+
thumb: 'border-error-500'
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
size: {
|
|
100
|
+
xs: {
|
|
101
|
+
root: [orientation === 'horizontal' ? 'h-1.5' : ''],
|
|
102
|
+
thumb: 'size-4',
|
|
103
|
+
tick: 'size-2.5'
|
|
104
|
+
},
|
|
105
|
+
sm: {
|
|
106
|
+
root: [orientation === 'horizontal' ? 'h-1.75' : ''],
|
|
107
|
+
thumb: 'size-4.5',
|
|
108
|
+
tick: 'size-3'
|
|
109
|
+
},
|
|
110
|
+
md: {
|
|
111
|
+
root: [orientation === 'horizontal' ? 'h-2' : 'w-2 h-48'],
|
|
112
|
+
thumb: 'size-5',
|
|
113
|
+
tick: 'size-3.5'
|
|
114
|
+
},
|
|
115
|
+
lg: {
|
|
116
|
+
root: [orientation === 'horizontal' ? 'h-2.5' : ''],
|
|
117
|
+
thumb: 'size-5.5',
|
|
118
|
+
tick: 'size-4'
|
|
119
|
+
},
|
|
120
|
+
xl: {
|
|
121
|
+
root: [orientation === 'horizontal' ? 'h-3' : 'w-3'],
|
|
122
|
+
thumb: 'size-6',
|
|
123
|
+
tick: 'size-4.5'
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
orientation: {
|
|
127
|
+
horizontal: {
|
|
128
|
+
root: '',
|
|
129
|
+
thumb: '',
|
|
130
|
+
tick: ''
|
|
131
|
+
},
|
|
132
|
+
vertical: {
|
|
133
|
+
root: '',
|
|
134
|
+
thumb: '',
|
|
135
|
+
tick: ''
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
compoundVariants: []
|
|
140
|
+
})({ color, size, orientation })
|
|
141
|
+
);
|
|
142
|
+
</script>
|
|
143
|
+
|
|
144
|
+
<Slider.Root
|
|
145
|
+
type="multiple"
|
|
146
|
+
bind:value={slider_value.get, slider_value.set}
|
|
147
|
+
{min}
|
|
148
|
+
{max}
|
|
149
|
+
{step}
|
|
150
|
+
{orientation}
|
|
151
|
+
{disabled}
|
|
152
|
+
class={classes.root({ class: [disabled ? 'opacity-75 cursor-not-allowed' : '', ui.root] })}
|
|
153
|
+
>
|
|
154
|
+
<Slider.Range class={classes.range({ class: [ui.range] })} />
|
|
155
|
+
|
|
156
|
+
{#each { length: thumbs }, index (index)}
|
|
157
|
+
<Slider.Thumb {index} class={classes.thumb({ class: ['group', ui.thumb] })}>
|
|
158
|
+
{#if thumblabel}
|
|
159
|
+
<Slider.ThumbLabel
|
|
160
|
+
{index}
|
|
161
|
+
position="bottom"
|
|
162
|
+
class={[
|
|
163
|
+
'opacity-0 transition pointer-events-none text-sm shadow-md px-2 h-6 flex items-center rounded-md mt-1 border border-surface-200',
|
|
164
|
+
'data-[active=""]:(opacity-100) group-hover:(opacity-100)'
|
|
165
|
+
]}
|
|
166
|
+
>
|
|
167
|
+
{slider_value.get()[index]}
|
|
168
|
+
</Slider.ThumbLabel>
|
|
169
|
+
{/if}
|
|
170
|
+
</Slider.Thumb>
|
|
171
|
+
{/each}
|
|
172
|
+
</Slider.Root>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Slider } from 'bits-ui';
|
|
2
|
+
import type { PropColor } from '../index.js';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
export type SliderProps<T> = {
|
|
5
|
+
value?: T;
|
|
6
|
+
default?: number | number[];
|
|
7
|
+
color?: PropColor;
|
|
8
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
thumblabel?: boolean;
|
|
11
|
+
orientation?: 'vertical' | 'horizontal';
|
|
12
|
+
step?: number;
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
15
|
+
ui?: {
|
|
16
|
+
root?: ClassNameValue;
|
|
17
|
+
range?: ClassNameValue;
|
|
18
|
+
thumb?: ClassNameValue;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
declare function $$render<T extends number | number[]>(): {
|
|
22
|
+
props: SliderProps<T>;
|
|
23
|
+
exports: {};
|
|
24
|
+
bindings: "value";
|
|
25
|
+
slots: {};
|
|
26
|
+
events: {};
|
|
27
|
+
};
|
|
28
|
+
declare class __sveltets_Render<T extends number | number[]> {
|
|
29
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
30
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
31
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
32
|
+
bindings(): "value";
|
|
33
|
+
exports(): {};
|
|
34
|
+
}
|
|
35
|
+
interface $$IsomorphicComponent {
|
|
36
|
+
new <T extends number | number[]>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
37
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
38
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
39
|
+
<T extends number | number[]>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
40
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
41
|
+
}
|
|
42
|
+
declare const Slider: $$IsomorphicComponent;
|
|
43
|
+
type Slider<T extends number | number[]> = InstanceType<typeof Slider<T>>;
|
|
44
|
+
export default Slider;
|