uisv 0.0.21 → 0.0.23
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 +22 -22
- package/dist/components/accordion.svelte.d.ts +10 -10
- package/dist/components/alert.svelte +22 -28
- package/dist/components/alert.svelte.d.ts +5 -5
- package/dist/components/app.svelte +63 -0
- package/dist/components/app.svelte.d.ts +8 -0
- package/dist/components/badge.svelte +18 -23
- package/dist/components/badge.svelte.d.ts +3 -3
- package/dist/components/banner.svelte +18 -24
- package/dist/components/banner.svelte.d.ts +5 -5
- package/dist/components/breadcrumb.svelte +7 -8
- package/dist/components/breadcrumb.svelte.d.ts +5 -26
- package/dist/components/button.svelte +36 -44
- package/dist/components/button.svelte.d.ts +12 -11
- package/dist/components/calendar.svelte +6 -7
- package/dist/components/calendar.svelte.d.ts +3 -3
- package/dist/components/card.svelte +11 -12
- package/dist/components/card.svelte.d.ts +5 -5
- package/dist/components/checkbox-group.svelte +12 -13
- package/dist/components/checkbox-group.svelte.d.ts +4 -4
- package/dist/components/checkbox.svelte +42 -40
- package/dist/components/checkbox.svelte.d.ts +6 -6
- package/dist/components/chip.svelte +7 -8
- package/dist/components/chip.svelte.d.ts +3 -3
- package/dist/components/collapsible.svelte +7 -6
- package/dist/components/collapsible.svelte.d.ts +4 -4
- package/dist/components/color-picker.svelte +1 -1
- package/dist/components/h1.svelte +8 -7
- package/dist/components/h2.svelte +12 -11
- package/dist/components/h3.svelte +9 -8
- package/dist/components/h4.svelte +12 -11
- package/dist/components/h5.svelte +12 -11
- package/dist/components/h6.svelte +12 -11
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.js +7 -0
- package/dist/components/input-number.svelte +8 -9
- package/dist/components/input-number.svelte.d.ts +5 -5
- package/dist/components/input-time.svelte +11 -12
- package/dist/components/input-time.svelte.d.ts +6 -6
- package/dist/components/input.svelte +19 -29
- package/dist/components/input.svelte.d.ts +6 -6
- package/dist/components/kbd.svelte +6 -7
- package/dist/components/kbd.svelte.d.ts +2 -2
- package/dist/components/modal.svelte +189 -0
- package/dist/components/modal.svelte.d.ts +33 -0
- package/dist/components/p.svelte +3 -1
- package/dist/components/pin-input.svelte +10 -11
- package/dist/components/pin-input.svelte.d.ts +3 -3
- package/dist/components/placeholder.svelte +4 -4
- package/dist/components/popover.svelte +33 -61
- package/dist/components/popover.svelte.d.ts +8 -30
- package/dist/components/progress.svelte +62 -26
- package/dist/components/progress.svelte.d.ts +8 -7
- package/dist/components/select.svelte +49 -53
- package/dist/components/select.svelte.d.ts +22 -29
- package/dist/components/seperator.svelte +7 -8
- package/dist/components/seperator.svelte.d.ts +6 -6
- package/dist/components/slider.svelte +13 -14
- package/dist/components/slider.svelte.d.ts +4 -4
- package/dist/components/switch.svelte +19 -23
- package/dist/components/switch.svelte.d.ts +6 -6
- package/dist/components/tabs.svelte +19 -20
- package/dist/components/tabs.svelte.d.ts +7 -7
- package/dist/components/toast.svelte +173 -0
- package/dist/components/toast.svelte.d.ts +8 -0
- package/dist/components/toast.svelte.js +11 -0
- package/dist/components/tooltip.svelte +94 -0
- package/dist/components/tooltip.svelte.d.ts +24 -0
- package/dist/contexts.d.ts +54 -0
- package/dist/contexts.js +46 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mode.d.ts +89 -0
- package/dist/mode.js +1 -0
- package/dist/utilities/index.d.ts +5 -0
- package/dist/utilities/index.js +5 -0
- package/dist/utilities/isComponent.d.ts +7 -0
- package/dist/utilities/isComponent.js +10 -0
- package/dist/utilities/isSnippet.d.ts +7 -0
- package/dist/utilities/isSnippet.js +8 -0
- package/dist/utilities/useElementRects.svelte.d.ts +11 -0
- package/dist/{utilities.svelte.js → utilities/useElementRects.svelte.js} +0 -38
- package/dist/utilities/useRafFn.svelte.d.ts +43 -0
- package/dist/utilities/useRafFn.svelte.js +56 -0
- package/dist/utilities/useStyle.svelte.d.ts +8 -0
- package/dist/utilities/useStyle.svelte.js +21 -0
- package/dist/vite.js +30 -35
- package/package.json +39 -27
- package/dist/utilities.svelte.d.ts +0 -31
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { PropColor, PropVariant } from '../index.js';
|
|
2
2
|
import { Select } from 'bits-ui';
|
|
3
3
|
import type { Component, Snippet } from 'svelte';
|
|
4
|
-
import type
|
|
4
|
+
import { type ClassValue } from 'tailwind-variants';
|
|
5
5
|
export type SelectItem<T> = T | {
|
|
6
6
|
icon?: string | Component;
|
|
7
|
-
|
|
7
|
+
iconposition?: 'leading' | 'trailing';
|
|
8
|
+
label: string | Component | Snippet;
|
|
8
9
|
value: T;
|
|
9
10
|
};
|
|
10
11
|
export type SelectProps<T> = {
|
|
@@ -19,34 +20,26 @@ export type SelectProps<T> = {
|
|
|
19
20
|
highlight?: boolean;
|
|
20
21
|
placeholder?: string;
|
|
21
22
|
ui?: {
|
|
22
|
-
base?:
|
|
23
|
-
leading?:
|
|
24
|
-
|
|
25
|
-
leadingAvatar?:
|
|
26
|
-
leadingAvatarSize?:
|
|
27
|
-
trailing?:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
itemLeadingAvatar?: ClassNameValue;
|
|
41
|
-
itemLeadingAvatarSize?: ClassNameValue;
|
|
42
|
-
itemLeadingChip?: ClassNameValue;
|
|
43
|
-
itemLeadingChipSize?: ClassNameValue;
|
|
44
|
-
itemTrailing?: ClassNameValue;
|
|
45
|
-
itemTrailingIcon?: ClassNameValue;
|
|
46
|
-
itemWrapper?: ClassNameValue;
|
|
47
|
-
itemLabel?: ClassNameValue;
|
|
48
|
-
itemDescription?: ClassNameValue;
|
|
23
|
+
base?: ClassValue;
|
|
24
|
+
leading?: ClassValue;
|
|
25
|
+
icon?: ClassValue;
|
|
26
|
+
leadingAvatar?: ClassValue;
|
|
27
|
+
leadingAvatarSize?: ClassValue;
|
|
28
|
+
trailing?: ClassValue;
|
|
29
|
+
value?: ClassValue;
|
|
30
|
+
placeholder?: ClassValue;
|
|
31
|
+
arrow?: ClassValue;
|
|
32
|
+
content?: ClassValue;
|
|
33
|
+
viewport?: ClassValue;
|
|
34
|
+
group?: ClassValue;
|
|
35
|
+
empty?: ClassValue;
|
|
36
|
+
label?: ClassValue;
|
|
37
|
+
separator?: ClassValue;
|
|
38
|
+
item?: ClassValue;
|
|
39
|
+
itemicon?: ClassValue;
|
|
40
|
+
dropdownicon?: ClassValue;
|
|
49
41
|
};
|
|
42
|
+
dropdownicon?: string | Component;
|
|
50
43
|
} & ({
|
|
51
44
|
value?: T;
|
|
52
45
|
type?: 'single';
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import { Icon, type PropColor, isComponent, isSnippet } from '../index.js';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
|
-
import type
|
|
5
|
-
import { tv } from 'tailwind-variants';
|
|
4
|
+
import { tv, type ClassValue } from 'tailwind-variants';
|
|
6
5
|
import type { Component } from 'svelte';
|
|
7
6
|
|
|
8
7
|
export type SeperatorProps = {
|
|
9
|
-
label?: string | Snippet<[
|
|
8
|
+
label?: string | Snippet<[ClassValue]> | Component;
|
|
10
9
|
icon?: string | Component;
|
|
11
10
|
color?: PropColor;
|
|
12
11
|
type?: 'dashed' | 'solid' | 'dotted';
|
|
@@ -14,10 +13,10 @@
|
|
|
14
13
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
15
14
|
orientation?: 'horizontal' | 'vertical';
|
|
16
15
|
ui?: {
|
|
17
|
-
root?:
|
|
18
|
-
border?:
|
|
19
|
-
icon?:
|
|
20
|
-
label?:
|
|
16
|
+
root?: ClassValue;
|
|
17
|
+
border?: ClassValue;
|
|
18
|
+
icon?: ClassValue;
|
|
19
|
+
label?: ClassValue;
|
|
21
20
|
};
|
|
22
21
|
};
|
|
23
22
|
</script>
|
|
@@ -199,7 +198,7 @@
|
|
|
199
198
|
{:else if typeof label === 'string' && label.length > 0}
|
|
200
199
|
<span class={variants.label({ class: ui.label })}>{label}</span>
|
|
201
200
|
{:else if isSnippet(label)}
|
|
202
|
-
{@render label()}
|
|
201
|
+
{@render label(variants.label({ class: ui.label }))}
|
|
203
202
|
{:else if isComponent(label)}
|
|
204
203
|
{@const Label = label}
|
|
205
204
|
<Label class={variants.label({ class: ui.label })} />
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type PropColor } from '../index.js';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
import type
|
|
3
|
+
import { type ClassValue } from 'tailwind-variants';
|
|
4
4
|
import type { Component } from 'svelte';
|
|
5
5
|
export type SeperatorProps = {
|
|
6
|
-
label?: string | Snippet<[
|
|
6
|
+
label?: string | Snippet<[ClassValue]> | Component;
|
|
7
7
|
icon?: string | Component;
|
|
8
8
|
color?: PropColor;
|
|
9
9
|
type?: 'dashed' | 'solid' | 'dotted';
|
|
@@ -11,10 +11,10 @@ export type SeperatorProps = {
|
|
|
11
11
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
12
12
|
orientation?: 'horizontal' | 'vertical';
|
|
13
13
|
ui?: {
|
|
14
|
-
root?:
|
|
15
|
-
border?:
|
|
16
|
-
icon?:
|
|
17
|
-
label?:
|
|
14
|
+
root?: ClassValue;
|
|
15
|
+
border?: ClassValue;
|
|
16
|
+
icon?: ClassValue;
|
|
17
|
+
label?: ClassValue;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
declare const Seperator: Component<SeperatorProps, {}, "">;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import { Slider } from 'bits-ui';
|
|
3
3
|
import type { PropColor } from '../index.js';
|
|
4
|
-
import type
|
|
5
|
-
import { tv } from 'tailwind-variants';
|
|
4
|
+
import { tv, type ClassValue } from 'tailwind-variants';
|
|
6
5
|
|
|
7
6
|
export type SliderProps<T> = {
|
|
8
7
|
value?: T;
|
|
@@ -16,9 +15,9 @@
|
|
|
16
15
|
min?: number;
|
|
17
16
|
max?: number;
|
|
18
17
|
ui?: {
|
|
19
|
-
root?:
|
|
20
|
-
range?:
|
|
21
|
-
thumb?:
|
|
18
|
+
root?: ClassValue;
|
|
19
|
+
range?: ClassValue;
|
|
20
|
+
thumb?: ClassValue;
|
|
22
21
|
};
|
|
23
22
|
};
|
|
24
23
|
</script>
|
|
@@ -54,15 +53,15 @@
|
|
|
54
53
|
},
|
|
55
54
|
});
|
|
56
55
|
const thumbs = $derived(slider_value.get()?.length ?? 1);
|
|
57
|
-
const
|
|
56
|
+
const variants = $derived.by(() =>
|
|
58
57
|
tv({
|
|
59
58
|
slots: {
|
|
60
59
|
root: [
|
|
61
|
-
'relative w-full flex rounded-full bg-
|
|
60
|
+
'relative w-full flex rounded-full bg-label-dimmed',
|
|
62
61
|
orientation === 'horizontal' ? 'items-center' : 'justify-center mx-1',
|
|
63
62
|
],
|
|
64
63
|
range: [
|
|
65
|
-
'rounded-full bg-
|
|
64
|
+
'rounded-full bg-surface-accented p-0.5 relative transition',
|
|
66
65
|
orientation === 'horizontal' ? 'h-full' : 'w-full',
|
|
67
66
|
],
|
|
68
67
|
thumb: 'bg-white rounded-full border-2 outline-none transition',
|
|
@@ -76,8 +75,8 @@
|
|
|
76
75
|
thumb: 'border-primary-500',
|
|
77
76
|
},
|
|
78
77
|
surface: {
|
|
79
|
-
range: ['bg-
|
|
80
|
-
thumb: 'border-
|
|
78
|
+
range: ['bg-surface-inverted'],
|
|
79
|
+
thumb: 'border-surface-inverted',
|
|
81
80
|
},
|
|
82
81
|
info: {
|
|
83
82
|
range: ['bg-info-500'],
|
|
@@ -149,18 +148,18 @@
|
|
|
149
148
|
{step}
|
|
150
149
|
{orientation}
|
|
151
150
|
{disabled}
|
|
152
|
-
class={
|
|
151
|
+
class={variants.root({ class: [disabled ? 'opacity-75 cursor-not-allowed' : '', ui.root] })}
|
|
153
152
|
>
|
|
154
|
-
<Slider.Range class={
|
|
153
|
+
<Slider.Range class={variants.range({ class: [ui.range] })} />
|
|
155
154
|
|
|
156
155
|
{#each { length: thumbs }, index (index)}
|
|
157
|
-
<Slider.Thumb {index} class={
|
|
156
|
+
<Slider.Thumb {index} class={variants.thumb({ class: ['group', ui.thumb] })}>
|
|
158
157
|
{#if thumblabel}
|
|
159
158
|
<Slider.ThumbLabel
|
|
160
159
|
{index}
|
|
161
160
|
position="bottom"
|
|
162
161
|
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-
|
|
162
|
+
'opacity-0 transition pointer-events-none text-sm shadow-md px-2 h-6 flex items-center rounded-md mt-1 border border-surface-accented',
|
|
164
163
|
'data-[active=""]:opacity-100 group-hover:opacity-100',
|
|
165
164
|
]}
|
|
166
165
|
>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Slider } from 'bits-ui';
|
|
2
2
|
import type { PropColor } from '../index.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type ClassValue } from 'tailwind-variants';
|
|
4
4
|
export type SliderProps<T> = {
|
|
5
5
|
value?: T;
|
|
6
6
|
default?: number | number[];
|
|
@@ -13,9 +13,9 @@ export type SliderProps<T> = {
|
|
|
13
13
|
min?: number;
|
|
14
14
|
max?: number;
|
|
15
15
|
ui?: {
|
|
16
|
-
root?:
|
|
17
|
-
range?:
|
|
18
|
-
thumb?:
|
|
16
|
+
root?: ClassValue;
|
|
17
|
+
range?: ClassValue;
|
|
18
|
+
thumb?: ClassValue;
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
declare function $$render<T extends number | number[]>(): {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
+
import { getAppContext } from '../contexts.js';
|
|
2
3
|
import { type PropColor, Icon } from '../index.js';
|
|
3
4
|
import type { Snippet, Component } from 'svelte';
|
|
4
|
-
import type
|
|
5
|
-
import { tv } from 'tailwind-variants';
|
|
5
|
+
import { tv, type ClassValue } from 'tailwind-variants';
|
|
6
6
|
|
|
7
7
|
export type SwitchProps = {
|
|
8
8
|
value?: boolean;
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
description?: string | Snippet;
|
|
18
18
|
required?: boolean;
|
|
19
19
|
ui?: {
|
|
20
|
-
root?:
|
|
21
|
-
container?:
|
|
22
|
-
thumb?:
|
|
23
|
-
label?:
|
|
24
|
-
description?:
|
|
20
|
+
root?: ClassValue;
|
|
21
|
+
container?: ClassValue;
|
|
22
|
+
thumb?: ClassValue;
|
|
23
|
+
label?: ClassValue;
|
|
24
|
+
description?: ClassValue;
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
</script>
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
size = 'md',
|
|
34
34
|
disabled,
|
|
35
35
|
loading,
|
|
36
|
-
loadingicon =
|
|
36
|
+
loadingicon = getAppContext().icons.loading,
|
|
37
37
|
uncheckedicon,
|
|
38
38
|
checkedicon,
|
|
39
39
|
label,
|
|
@@ -42,18 +42,18 @@
|
|
|
42
42
|
ui = {},
|
|
43
43
|
}: SwitchProps = $props();
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const variants = $derived.by(() =>
|
|
46
46
|
tv({
|
|
47
47
|
slots: {
|
|
48
48
|
root: 'flex-inline gap-2',
|
|
49
|
-
container: 'rounded-full bg-
|
|
49
|
+
container: 'rounded-full bg-surface-accented p-0.5 relative transition',
|
|
50
50
|
thumb: [
|
|
51
51
|
'bg-white block rounded-full absolute top-0.5 transition grid place-items-center',
|
|
52
|
-
value ? 'translate-x-full' : 'text-
|
|
52
|
+
value ? 'translate-x-full' : 'text-label-muted',
|
|
53
53
|
],
|
|
54
54
|
icon: 'pi',
|
|
55
55
|
label: 'text-sm',
|
|
56
|
-
description: 'text-sm text-
|
|
56
|
+
description: 'text-sm text-label-muted',
|
|
57
57
|
},
|
|
58
58
|
variants: {
|
|
59
59
|
color: {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
container: ['', value && 'bg-primary-500 text-primary-500'],
|
|
62
62
|
},
|
|
63
63
|
surface: {
|
|
64
|
-
container: ['', value && 'bg-
|
|
64
|
+
container: ['', value && 'bg-surface-inverted text-surface-inverted'],
|
|
65
65
|
},
|
|
66
66
|
info: {
|
|
67
67
|
container: ['', value && 'bg-info-500 text-info-500'],
|
|
@@ -111,23 +111,23 @@
|
|
|
111
111
|
|
|
112
112
|
<div
|
|
113
113
|
data-state={value ? 'checked' : 'unchecked'}
|
|
114
|
-
class={
|
|
114
|
+
class={variants.root({
|
|
115
115
|
class: [(loading || disabled) && 'opacity-50', ui.thumb],
|
|
116
116
|
})}
|
|
117
117
|
>
|
|
118
118
|
<button
|
|
119
119
|
aria-label="switch"
|
|
120
120
|
data-state={value ? 'checked' : 'unchecked'}
|
|
121
|
-
class={
|
|
121
|
+
class={variants.container({ class: [loading && 'cursor-not-allowed', ui.thumb] })}
|
|
122
122
|
onclick={() => {
|
|
123
123
|
if (loading || disabled) return;
|
|
124
124
|
value = !value;
|
|
125
125
|
}}
|
|
126
126
|
>
|
|
127
|
-
<span data-state={value ? 'checked' : 'unchecked'} class={
|
|
127
|
+
<span data-state={value ? 'checked' : 'unchecked'} class={variants.thumb({ class: ui.thumb })}>
|
|
128
128
|
<Icon
|
|
129
129
|
name={loading ? loadingicon : value ? checkedicon : uncheckedicon}
|
|
130
|
-
class={
|
|
130
|
+
class={variants.icon({ class: [loading && 'animate-spin'] })}
|
|
131
131
|
/>
|
|
132
132
|
</span>
|
|
133
133
|
</button>
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
{#if label}
|
|
136
136
|
<span>
|
|
137
137
|
<div
|
|
138
|
-
class={
|
|
138
|
+
class={variants.label({
|
|
139
139
|
class: [required ? 'after:content-["*"] after:text-error-500' : '', ui.thumb],
|
|
140
140
|
})}
|
|
141
141
|
>
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
</div>
|
|
148
148
|
|
|
149
149
|
{#if description}
|
|
150
|
-
<div class={
|
|
150
|
+
<div class={variants.description({ class: ui.thumb })}>
|
|
151
151
|
{#if typeof description === 'string'}
|
|
152
152
|
{description}
|
|
153
153
|
{:else}
|
|
@@ -158,7 +158,3 @@
|
|
|
158
158
|
</span>
|
|
159
159
|
{/if}
|
|
160
160
|
</div>
|
|
161
|
-
|
|
162
|
-
{#snippet icon(ico?: SwitchProps['checkedicon'], icon_class?: ClassNameValue)}
|
|
163
|
-
<div class={['absolute', icon_class]}></div>
|
|
164
|
-
{/snippet}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PropColor } from '../index.js';
|
|
2
2
|
import type { Snippet, Component } from 'svelte';
|
|
3
|
-
import type
|
|
3
|
+
import { type ClassValue } from 'tailwind-variants';
|
|
4
4
|
export type SwitchProps = {
|
|
5
5
|
value?: boolean;
|
|
6
6
|
color?: PropColor;
|
|
@@ -14,11 +14,11 @@ export type SwitchProps = {
|
|
|
14
14
|
description?: string | Snippet;
|
|
15
15
|
required?: boolean;
|
|
16
16
|
ui?: {
|
|
17
|
-
root?:
|
|
18
|
-
container?:
|
|
19
|
-
thumb?:
|
|
20
|
-
label?:
|
|
21
|
-
description?:
|
|
17
|
+
root?: ClassValue;
|
|
18
|
+
container?: ClassValue;
|
|
19
|
+
thumb?: ClassValue;
|
|
20
|
+
label?: ClassValue;
|
|
21
|
+
description?: ClassValue;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
declare const Switch: Component<SwitchProps, {}, "value">;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import { Tabs } from 'bits-ui';
|
|
3
3
|
import { isComponent, isSnippet, useElementRects, type PropColor } from '../index.js';
|
|
4
|
-
import type
|
|
5
|
-
import { tv } from 'tailwind-variants';
|
|
4
|
+
import { tv, type ClassValue } from 'tailwind-variants';
|
|
6
5
|
import { type Component, type Snippet } from 'svelte';
|
|
7
6
|
import { ElementRect } from 'runed';
|
|
8
7
|
|
|
@@ -24,12 +23,12 @@
|
|
|
24
23
|
disabled?: boolean;
|
|
25
24
|
orientation?: 'vertical' | 'horizontal';
|
|
26
25
|
ui?: {
|
|
27
|
-
root?:
|
|
28
|
-
item?:
|
|
29
|
-
list?:
|
|
30
|
-
content?:
|
|
31
|
-
icon?:
|
|
32
|
-
indicator?:
|
|
26
|
+
root?: ClassValue;
|
|
27
|
+
item?: ClassValue;
|
|
28
|
+
list?: ClassValue;
|
|
29
|
+
content?: ClassValue;
|
|
30
|
+
icon?: ClassValue;
|
|
31
|
+
indicator?: ClassValue;
|
|
33
32
|
};
|
|
34
33
|
[k: `content_${string}`]: Snippet<[{ item: TabItem; value: number }]>;
|
|
35
34
|
};
|
|
@@ -65,12 +64,12 @@
|
|
|
65
64
|
return result;
|
|
66
65
|
});
|
|
67
66
|
|
|
68
|
-
const
|
|
67
|
+
const variants = $derived.by(() =>
|
|
69
68
|
tv({
|
|
70
69
|
slots: {
|
|
71
70
|
root: '',
|
|
72
71
|
list: 'flex relative p-1',
|
|
73
|
-
item: 'flex items-center justify-center text-muted data-[state="inactive"]:hover:text-highlighted font-medium z-1 transition-all',
|
|
72
|
+
item: 'flex items-center justify-center text-label-muted data-[state="inactive"]:hover:text-label-highlighted font-medium z-1 transition-all',
|
|
74
73
|
icon: '',
|
|
75
74
|
content: 'mt-2',
|
|
76
75
|
indicator: 'absolute z-0 transition-all duration-200 rounded-md w---width',
|
|
@@ -79,7 +78,7 @@
|
|
|
79
78
|
variant: {
|
|
80
79
|
pill: {
|
|
81
80
|
list: 'bg-surface-elevated rounded-lg',
|
|
82
|
-
item: 'flex-1 data-[state="active"]:text-inverted',
|
|
81
|
+
item: 'flex-1 data-[state="active"]:text-label-inverted',
|
|
83
82
|
trigger: 'flex-1',
|
|
84
83
|
indicator: 'rounded-md shadow-xs',
|
|
85
84
|
},
|
|
@@ -96,8 +95,8 @@
|
|
|
96
95
|
indicator: 'bg-primary-500',
|
|
97
96
|
},
|
|
98
97
|
surface: {
|
|
99
|
-
item: 'data-[variant="link"]:data-[state="active"]:text-
|
|
100
|
-
indicator: 'bg-surface-
|
|
98
|
+
item: 'data-[variant="link"]:data-[state="active"]:text-label-muted',
|
|
99
|
+
indicator: 'bg-surface-inverted',
|
|
101
100
|
},
|
|
102
101
|
info: {
|
|
103
102
|
item: 'data-[variant="link"]:data-[state="active"]:text-info-500',
|
|
@@ -183,10 +182,10 @@
|
|
|
183
182
|
<Tabs.Root
|
|
184
183
|
{disabled}
|
|
185
184
|
bind:value={() => value.toString(), (v) => (value = parseInt(v))}
|
|
186
|
-
class={
|
|
185
|
+
class={variants.root({ class: ui.root })}
|
|
187
186
|
{orientation}
|
|
188
187
|
>
|
|
189
|
-
<Tabs.List bind:ref={container_el} class={
|
|
188
|
+
<Tabs.List bind:ref={container_el} class={variants.list({ class: ui.list })}>
|
|
190
189
|
{#each items as item, idx (idx)}
|
|
191
190
|
{@const label = typeof item === 'string' ? item : item.label}
|
|
192
191
|
|
|
@@ -201,7 +200,7 @@
|
|
|
201
200
|
}
|
|
202
201
|
}
|
|
203
202
|
value={idx.toString()}
|
|
204
|
-
class={
|
|
203
|
+
class={variants.item({ class: ui.item })}
|
|
205
204
|
data-variant={variant}
|
|
206
205
|
>
|
|
207
206
|
{@render RenderIcon(typeof item === 'string' ? undefined : item.icon)}
|
|
@@ -211,7 +210,7 @@
|
|
|
211
210
|
{/each}
|
|
212
211
|
|
|
213
212
|
<span
|
|
214
|
-
class={
|
|
213
|
+
class={variants.indicator({ class: ui.indicator })}
|
|
215
214
|
style:--width="{rect.w}px"
|
|
216
215
|
style:--left="{rect.l}px"
|
|
217
216
|
style:--height="{rect.w}px"
|
|
@@ -221,7 +220,7 @@
|
|
|
221
220
|
{#each items as item, idx (idx)}
|
|
222
221
|
{#if typeof item === 'object' && item.content}
|
|
223
222
|
{@const Content = item.content}
|
|
224
|
-
<Tabs.Content value={idx.toString()} class={
|
|
223
|
+
<Tabs.Content value={idx.toString()} class={variants.content({ class: ui.content })}>
|
|
225
224
|
{#if `content_${idx}` in rest}
|
|
226
225
|
{@render rest[`content_${idx}`]({ item, value: idx })}
|
|
227
226
|
{:else if typeof Content === 'string'}
|
|
@@ -238,8 +237,8 @@
|
|
|
238
237
|
{#if isSnippet(IconProp)}
|
|
239
238
|
{@render IconProp()}
|
|
240
239
|
{:else if isComponent(IconProp)}
|
|
241
|
-
<IconProp class={
|
|
240
|
+
<IconProp class={variants.icon({ class: ui.icon })} />
|
|
242
241
|
{:else if typeof IconProp === 'string'}
|
|
243
|
-
<div class={
|
|
242
|
+
<div class={variants.icon({ class: [IconProp, ui.icon] })}></div>
|
|
244
243
|
{/if}
|
|
245
244
|
{/snippet}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tabs } from 'bits-ui';
|
|
2
2
|
import { type PropColor } from '../index.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type ClassValue } from 'tailwind-variants';
|
|
4
4
|
import { type Component, type Snippet } from 'svelte';
|
|
5
5
|
export type TabItem = string | {
|
|
6
6
|
label: string;
|
|
@@ -17,12 +17,12 @@ export type TabsProps = {
|
|
|
17
17
|
disabled?: boolean;
|
|
18
18
|
orientation?: 'vertical' | 'horizontal';
|
|
19
19
|
ui?: {
|
|
20
|
-
root?:
|
|
21
|
-
item?:
|
|
22
|
-
list?:
|
|
23
|
-
content?:
|
|
24
|
-
icon?:
|
|
25
|
-
indicator?:
|
|
20
|
+
root?: ClassValue;
|
|
21
|
+
item?: ClassValue;
|
|
22
|
+
list?: ClassValue;
|
|
23
|
+
content?: ClassValue;
|
|
24
|
+
icon?: ClassValue;
|
|
25
|
+
indicator?: ClassValue;
|
|
26
26
|
};
|
|
27
27
|
[k: `content_${string}`]: Snippet<[{
|
|
28
28
|
item: TabItem;
|