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,8 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
import type
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { type ButtonProps,Button } from '../index.js';
|
|
7
|
-
import type { PropColor } from '../index.js';
|
|
3
|
+
import { Popover, type PopoverArrowProps, type PopoverContentProps } from 'bits-ui';
|
|
4
|
+
import { tv, type ClassValue } from 'tailwind-variants';
|
|
5
|
+
import { type ButtonBaseProps, Button } from '../index.js';
|
|
8
6
|
|
|
9
7
|
export type PopoverContentSnippet = {
|
|
10
8
|
props: Record<string, unknown>;
|
|
@@ -12,7 +10,7 @@
|
|
|
12
10
|
wrapperProps: Record<string, unknown>;
|
|
13
11
|
};
|
|
14
12
|
|
|
15
|
-
export type PopoverProps = {
|
|
13
|
+
export type PopoverProps = ButtonBaseProps & {
|
|
16
14
|
/**
|
|
17
15
|
* The display mode of the popover.
|
|
18
16
|
*/
|
|
@@ -21,20 +19,15 @@
|
|
|
21
19
|
* The props for the content of popover.
|
|
22
20
|
*/
|
|
23
21
|
contentprops?: PopoverContentProps;
|
|
24
|
-
content?: Snippet<[PopoverContentSnippet]>;
|
|
25
22
|
children?: Snippet<[]>;
|
|
26
|
-
/**
|
|
27
|
-
* Snippet if you want to implement your own trigger button
|
|
28
|
-
*/
|
|
29
|
-
trigger?: Snippet<[Record<string, unknown>]>;
|
|
30
23
|
/**
|
|
31
24
|
* Display an arrow alongside the popover.
|
|
32
25
|
*/
|
|
33
|
-
arrow?: boolean;
|
|
26
|
+
arrow?: boolean | PopoverArrowProps;
|
|
34
27
|
/**
|
|
35
28
|
* Render the popover in a portal.
|
|
36
29
|
*/
|
|
37
|
-
portal?: string | false | true | HTMLElement;
|
|
30
|
+
// portal?: string | false | true | HTMLElement;
|
|
38
31
|
/**
|
|
39
32
|
* The reference (or anchor) element that is being referred to for positioning. If not provided will use the current component as anchor.
|
|
40
33
|
*/
|
|
@@ -49,10 +42,6 @@
|
|
|
49
42
|
* When `false`, the popover will not close when clicking outside or pressing escape.
|
|
50
43
|
*/
|
|
51
44
|
dismissible?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* The open state of the popover when it is initially rendered. Use when you do not need to control its open state.
|
|
54
|
-
*/
|
|
55
|
-
defaultopen?: boolean;
|
|
56
45
|
/**
|
|
57
46
|
* The controlled open state of the popover.
|
|
58
47
|
*/
|
|
@@ -73,21 +62,10 @@
|
|
|
73
62
|
*
|
|
74
63
|
*/
|
|
75
64
|
ui?: {
|
|
76
|
-
content?:
|
|
77
|
-
arrow?:
|
|
65
|
+
content?: ClassValue;
|
|
66
|
+
arrow?: ClassValue;
|
|
67
|
+
trigger?: ClassValue;
|
|
78
68
|
};
|
|
79
|
-
/**
|
|
80
|
-
* @default `outline`
|
|
81
|
-
*/
|
|
82
|
-
variant?: ButtonProps['variant'];
|
|
83
|
-
/**
|
|
84
|
-
* @default primary
|
|
85
|
-
*/
|
|
86
|
-
color?: PropColor;
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
*/
|
|
90
|
-
class?: ClassNameValue;
|
|
91
69
|
};
|
|
92
70
|
</script>
|
|
93
71
|
|
|
@@ -95,57 +73,51 @@
|
|
|
95
73
|
let {
|
|
96
74
|
mode = 'click',
|
|
97
75
|
contentprops = { side: 'bottom', sideOffset: 8, collisionPadding: 8 },
|
|
98
|
-
content,
|
|
99
76
|
children,
|
|
100
|
-
|
|
101
|
-
arrow = true,
|
|
102
|
-
portal = true,
|
|
103
|
-
reference,
|
|
77
|
+
arrow = false,
|
|
104
78
|
dismissible = true,
|
|
105
|
-
defaultopen,
|
|
106
79
|
open = $bindable(false),
|
|
107
|
-
modal = false,
|
|
108
80
|
opendelay = 0,
|
|
109
81
|
closedelay = 0,
|
|
110
82
|
ui = {},
|
|
111
|
-
|
|
112
|
-
color = 'primary',
|
|
113
|
-
class: klass,
|
|
83
|
+
...rest
|
|
114
84
|
}: PopoverProps = $props();
|
|
115
85
|
|
|
116
|
-
const
|
|
86
|
+
const variants = $derived(
|
|
117
87
|
tv({
|
|
118
88
|
slots: {
|
|
119
|
-
content:
|
|
120
|
-
'bg-
|
|
121
|
-
|
|
89
|
+
content: [
|
|
90
|
+
'bg-surface-base z-30 w-full shadow-lg rounded-md border border-surface-accented p-4',
|
|
91
|
+
'origin-(--bits-popover-content-transform-origin)',
|
|
92
|
+
'',
|
|
93
|
+
],
|
|
94
|
+
arrow: 'text-surface-accented',
|
|
122
95
|
},
|
|
123
96
|
})({}),
|
|
124
97
|
);
|
|
125
98
|
</script>
|
|
126
99
|
|
|
127
100
|
<Popover.Root bind:open>
|
|
128
|
-
<Popover.Trigger>
|
|
101
|
+
<Popover.Trigger openOnHover={mode === 'hover'} openDelay={opendelay} closeDelay={closedelay}>
|
|
129
102
|
{#snippet child({ props })}
|
|
130
|
-
{
|
|
131
|
-
{@render trigger(props)}
|
|
132
|
-
{:else}
|
|
133
|
-
<Button {...props} {variant} {color} ui={{ base: klass }} />
|
|
134
|
-
{/if}
|
|
103
|
+
<Button {...rest} {...props} ui={{ base: ui.trigger }} />
|
|
135
104
|
{/snippet}
|
|
136
105
|
</Popover.Trigger>
|
|
106
|
+
|
|
137
107
|
<Popover.Portal>
|
|
138
|
-
<Popover.
|
|
139
|
-
|
|
140
|
-
{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
{@render children?.()}
|
|
145
|
-
{/if}
|
|
146
|
-
{/snippet}
|
|
108
|
+
<Popover.Content
|
|
109
|
+
{...contentprops}
|
|
110
|
+
class={variants.content({ class: ui.content })}
|
|
111
|
+
interactOutsideBehavior={dismissible ? 'close' : 'ignore'}
|
|
112
|
+
>
|
|
113
|
+
{@render children?.()}
|
|
147
114
|
|
|
148
|
-
|
|
115
|
+
{#if arrow}
|
|
116
|
+
<Popover.Arrow
|
|
117
|
+
{...typeof arrow === 'object' ? arrow : {}}
|
|
118
|
+
class={variants.arrow({ class: ui.arrow })}
|
|
119
|
+
/>
|
|
120
|
+
{/if}
|
|
149
121
|
</Popover.Content>
|
|
150
122
|
</Popover.Portal>
|
|
151
123
|
</Popover.Root>
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type
|
|
3
|
-
import {
|
|
4
|
-
import { type
|
|
5
|
-
import type { PropColor } from '../index.js';
|
|
2
|
+
import { Popover, type PopoverArrowProps, type PopoverContentProps } from 'bits-ui';
|
|
3
|
+
import { type ClassValue } from 'tailwind-variants';
|
|
4
|
+
import { type ButtonBaseProps } from '../index.js';
|
|
6
5
|
export type PopoverContentSnippet = {
|
|
7
6
|
props: Record<string, unknown>;
|
|
8
7
|
open: boolean;
|
|
9
8
|
wrapperProps: Record<string, unknown>;
|
|
10
9
|
};
|
|
11
|
-
export type PopoverProps = {
|
|
10
|
+
export type PopoverProps = ButtonBaseProps & {
|
|
12
11
|
/**
|
|
13
12
|
* The display mode of the popover.
|
|
14
13
|
*/
|
|
@@ -17,20 +16,14 @@ export type PopoverProps = {
|
|
|
17
16
|
* The props for the content of popover.
|
|
18
17
|
*/
|
|
19
18
|
contentprops?: PopoverContentProps;
|
|
20
|
-
content?: Snippet<[PopoverContentSnippet]>;
|
|
21
19
|
children?: Snippet<[]>;
|
|
22
|
-
/**
|
|
23
|
-
* Snippet if you want to implement your own trigger button
|
|
24
|
-
*/
|
|
25
|
-
trigger?: Snippet<[Record<string, unknown>]>;
|
|
26
20
|
/**
|
|
27
21
|
* Display an arrow alongside the popover.
|
|
28
22
|
*/
|
|
29
|
-
arrow?: boolean;
|
|
23
|
+
arrow?: boolean | PopoverArrowProps;
|
|
30
24
|
/**
|
|
31
25
|
* Render the popover in a portal.
|
|
32
26
|
*/
|
|
33
|
-
portal?: string | false | true | HTMLElement;
|
|
34
27
|
/**
|
|
35
28
|
* The reference (or anchor) element that is being referred to for positioning. If not provided will use the current component as anchor.
|
|
36
29
|
*/
|
|
@@ -43,10 +36,6 @@ export type PopoverProps = {
|
|
|
43
36
|
* When `false`, the popover will not close when clicking outside or pressing escape.
|
|
44
37
|
*/
|
|
45
38
|
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
39
|
/**
|
|
51
40
|
* The controlled open state of the popover.
|
|
52
41
|
*/
|
|
@@ -67,21 +56,10 @@ export type PopoverProps = {
|
|
|
67
56
|
*
|
|
68
57
|
*/
|
|
69
58
|
ui?: {
|
|
70
|
-
content?:
|
|
71
|
-
arrow?:
|
|
59
|
+
content?: ClassValue;
|
|
60
|
+
arrow?: ClassValue;
|
|
61
|
+
trigger?: ClassValue;
|
|
72
62
|
};
|
|
73
|
-
/**
|
|
74
|
-
* @default `outline`
|
|
75
|
-
*/
|
|
76
|
-
variant?: ButtonProps['variant'];
|
|
77
|
-
/**
|
|
78
|
-
* @default primary
|
|
79
|
-
*/
|
|
80
|
-
color?: PropColor;
|
|
81
|
-
/**
|
|
82
|
-
*
|
|
83
|
-
*/
|
|
84
|
-
class?: ClassNameValue;
|
|
85
63
|
};
|
|
86
64
|
declare const Popover: import("svelte").Component<PopoverProps, {}, "open">;
|
|
87
65
|
type Popover = ReturnType<typeof Popover>;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import type { PropColor } from '../index.js';
|
|
3
|
-
import type
|
|
4
|
-
import { tv } from 'tailwind-variants';
|
|
3
|
+
import { tv, type ClassValue } from 'tailwind-variants';
|
|
5
4
|
|
|
6
5
|
export type ProgressProps = {
|
|
7
6
|
value?: number;
|
|
8
7
|
max?: number | string[];
|
|
9
8
|
animation?: 'swing' | 'carousel' | 'carousel-inverse' | 'elastic';
|
|
10
|
-
orientation?: 'horizontal' | '
|
|
9
|
+
orientation?: 'horizontal' | 'vertical';
|
|
11
10
|
color?: PropColor;
|
|
12
|
-
|
|
11
|
+
size?: '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
13
12
|
inverted?: boolean;
|
|
14
13
|
status?: boolean;
|
|
15
14
|
ui?: {
|
|
16
|
-
base?:
|
|
17
|
-
header?:
|
|
18
|
-
content?:
|
|
19
|
-
footer?:
|
|
15
|
+
base?: ClassValue;
|
|
16
|
+
header?: ClassValue;
|
|
17
|
+
content?: ClassValue;
|
|
18
|
+
footer?: ClassValue;
|
|
19
|
+
indicator?: ClassValue;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
</script>
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
animation,
|
|
28
28
|
inverted,
|
|
29
29
|
status,
|
|
30
|
-
value,
|
|
30
|
+
value = 0,
|
|
31
31
|
orientation = 'horizontal',
|
|
32
32
|
color = 'primary',
|
|
33
|
-
|
|
33
|
+
size = 'md',
|
|
34
34
|
ui = {},
|
|
35
35
|
}: ProgressProps = $props();
|
|
36
36
|
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
|
|
48
48
|
return false;
|
|
49
49
|
});
|
|
50
|
-
const
|
|
50
|
+
const variants = $derived.by(() =>
|
|
51
51
|
tv({
|
|
52
52
|
slots: {
|
|
53
|
-
root: 'relative w-full rounded-full overflow-hidden bg-surface-
|
|
53
|
+
root: 'relative w-full rounded-full overflow-hidden bg-surface-accented',
|
|
54
54
|
status: '',
|
|
55
55
|
indicator: 'absolute transition-all rounded-full',
|
|
56
56
|
steps: '',
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
indicator: 'bg-primary-500',
|
|
62
62
|
},
|
|
63
63
|
surface: {
|
|
64
|
-
indicator: 'bg-
|
|
64
|
+
indicator: 'bg-label-muted',
|
|
65
65
|
},
|
|
66
66
|
info: {
|
|
67
67
|
indicator: 'bg-info-500',
|
|
@@ -76,6 +76,19 @@
|
|
|
76
76
|
indicator: 'bg-error-500',
|
|
77
77
|
},
|
|
78
78
|
},
|
|
79
|
+
size: {
|
|
80
|
+
'2xs': '',
|
|
81
|
+
xs: '',
|
|
82
|
+
sm: '',
|
|
83
|
+
md: '',
|
|
84
|
+
lg: '',
|
|
85
|
+
xl: '',
|
|
86
|
+
'2xl': '',
|
|
87
|
+
},
|
|
88
|
+
orientation: {
|
|
89
|
+
vertical: { indicator: 'w-full top-0 h-(--ui-progress-percentage)' },
|
|
90
|
+
horizontal: { indicator: 'h-full left-0 w-(--ui-progress-percentage)' },
|
|
91
|
+
},
|
|
79
92
|
animation: {
|
|
80
93
|
swing: [indeterminate ? 'animate-[swing_2s_ease-in-out_infinite' : ''],
|
|
81
94
|
carousel: [indeterminate ? '' : ''],
|
|
@@ -83,17 +96,38 @@
|
|
|
83
96
|
elastic: [indeterminate ? '' : ''],
|
|
84
97
|
},
|
|
85
98
|
},
|
|
86
|
-
compoundVariants: [
|
|
99
|
+
compoundVariants: [
|
|
100
|
+
{ orientation: 'horizontal', size: '2xs', class: { root: 'h-px' } },
|
|
101
|
+
{ orientation: 'horizontal', size: 'xs', class: { root: 'h-0.5' } },
|
|
102
|
+
{ orientation: 'horizontal', size: 'sm', class: { root: 'h-1' } },
|
|
103
|
+
{ orientation: 'horizontal', size: 'md', class: { root: 'h-2' } },
|
|
104
|
+
{ orientation: 'horizontal', size: 'lg', class: { root: 'h-3' } },
|
|
105
|
+
{ orientation: 'horizontal', size: 'xl', class: { root: 'h-4' } },
|
|
106
|
+
{ orientation: 'horizontal', size: '2xl', class: { root: 'h-5' } },
|
|
107
|
+
|
|
108
|
+
{ orientation: 'vertical', size: '2xs', class: { root: 'w-px' } },
|
|
109
|
+
{ orientation: 'vertical', size: 'xs', class: { root: 'w-0.5' } },
|
|
110
|
+
{ orientation: 'vertical', size: 'sm', class: { root: 'w-1' } },
|
|
111
|
+
{ orientation: 'vertical', size: 'md', class: { root: 'w-2' } },
|
|
112
|
+
{ orientation: 'vertical', size: 'lg', class: { root: 'w-3' } },
|
|
113
|
+
{ orientation: 'vertical', size: 'xl', class: { root: 'w-4' } },
|
|
114
|
+
{ orientation: 'vertical', size: '2xl', class: { root: 'w-5' } },
|
|
115
|
+
],
|
|
87
116
|
})({
|
|
88
117
|
color,
|
|
89
118
|
animation: animation ?? 'swing',
|
|
119
|
+
size,
|
|
120
|
+
orientation,
|
|
90
121
|
}),
|
|
91
122
|
);
|
|
92
123
|
</script>
|
|
93
124
|
|
|
94
125
|
<div data-state-indeterminate={indeterminate}>
|
|
95
|
-
<div class={
|
|
96
|
-
<span
|
|
126
|
+
<div class={variants.root({ class: [ui.base] })}>
|
|
127
|
+
<span
|
|
128
|
+
class={variants.indicator({ class: ui.indicator })}
|
|
129
|
+
style:--ui-progress-percentage={`${percentage}%`}
|
|
130
|
+
>
|
|
97
131
|
</span>
|
|
98
132
|
</div>
|
|
99
133
|
|
|
@@ -101,7 +135,7 @@
|
|
|
101
135
|
<p
|
|
102
136
|
class={[
|
|
103
137
|
'text-right transition',
|
|
104
|
-
value && value > 0 && max[value] ? 'text-primary-500' : 'text-
|
|
138
|
+
value && value > 0 && max[value] ? 'text-primary-500' : 'text-label-muted',
|
|
105
139
|
]}
|
|
106
140
|
>
|
|
107
141
|
{(value && max[value]) || max[0]}
|
|
@@ -110,15 +144,17 @@
|
|
|
110
144
|
</div>
|
|
111
145
|
|
|
112
146
|
<style>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
147
|
+
:global {
|
|
148
|
+
@keyframes swing {
|
|
149
|
+
0% {
|
|
150
|
+
width: 0%;
|
|
151
|
+
}
|
|
152
|
+
50% {
|
|
153
|
+
width: 100%;
|
|
154
|
+
}
|
|
155
|
+
100% {
|
|
156
|
+
width: 0%;
|
|
157
|
+
}
|
|
122
158
|
}
|
|
123
159
|
}
|
|
124
160
|
</style>
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import type { PropColor } from '../index.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type ClassValue } from 'tailwind-variants';
|
|
3
3
|
export type ProgressProps = {
|
|
4
4
|
value?: number;
|
|
5
5
|
max?: number | string[];
|
|
6
6
|
animation?: 'swing' | 'carousel' | 'carousel-inverse' | 'elastic';
|
|
7
|
-
orientation?: 'horizontal' | '
|
|
7
|
+
orientation?: 'horizontal' | 'vertical';
|
|
8
8
|
color?: PropColor;
|
|
9
|
-
|
|
9
|
+
size?: '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
10
10
|
inverted?: boolean;
|
|
11
11
|
status?: boolean;
|
|
12
12
|
ui?: {
|
|
13
|
-
base?:
|
|
14
|
-
header?:
|
|
15
|
-
content?:
|
|
16
|
-
footer?:
|
|
13
|
+
base?: ClassValue;
|
|
14
|
+
header?: ClassValue;
|
|
15
|
+
content?: ClassValue;
|
|
16
|
+
footer?: ClassValue;
|
|
17
|
+
indicator?: ClassValue;
|
|
17
18
|
};
|
|
18
19
|
};
|
|
19
20
|
declare const Progress: import("svelte").Component<ProgressProps, {}, "">;
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
import type { PropColor, PropVariant } from '../index.js';
|
|
3
3
|
import { Select } from 'bits-ui';
|
|
4
4
|
import type { Component, Snippet } from 'svelte';
|
|
5
|
-
import type
|
|
6
|
-
import
|
|
5
|
+
import { tv, type ClassValue } from 'tailwind-variants';
|
|
6
|
+
import Icon from './icon.svelte';
|
|
7
|
+
import { getAppContext } from '../contexts.js';
|
|
7
8
|
|
|
8
9
|
export type SelectItem<T> =
|
|
9
10
|
| T
|
|
10
11
|
| {
|
|
11
12
|
icon?: string | Component;
|
|
12
|
-
|
|
13
|
+
iconposition?: 'leading' | 'trailing';
|
|
14
|
+
label: string | Component | Snippet;
|
|
13
15
|
value: T;
|
|
14
16
|
};
|
|
15
17
|
|
|
@@ -23,34 +25,26 @@
|
|
|
23
25
|
highlight?: boolean;
|
|
24
26
|
placeholder?: string;
|
|
25
27
|
ui?: {
|
|
26
|
-
base?:
|
|
27
|
-
leading?:
|
|
28
|
-
|
|
29
|
-
leadingAvatar?:
|
|
30
|
-
leadingAvatarSize?:
|
|
31
|
-
trailing?:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
itemLeadingAvatar?: ClassNameValue;
|
|
45
|
-
itemLeadingAvatarSize?: ClassNameValue;
|
|
46
|
-
itemLeadingChip?: ClassNameValue;
|
|
47
|
-
itemLeadingChipSize?: ClassNameValue;
|
|
48
|
-
itemTrailing?: ClassNameValue;
|
|
49
|
-
itemTrailingIcon?: ClassNameValue;
|
|
50
|
-
itemWrapper?: ClassNameValue;
|
|
51
|
-
itemLabel?: ClassNameValue;
|
|
52
|
-
itemDescription?: ClassNameValue;
|
|
28
|
+
base?: ClassValue;
|
|
29
|
+
leading?: ClassValue;
|
|
30
|
+
icon?: ClassValue;
|
|
31
|
+
leadingAvatar?: ClassValue;
|
|
32
|
+
leadingAvatarSize?: ClassValue;
|
|
33
|
+
trailing?: ClassValue;
|
|
34
|
+
value?: ClassValue;
|
|
35
|
+
placeholder?: ClassValue;
|
|
36
|
+
arrow?: ClassValue;
|
|
37
|
+
content?: ClassValue;
|
|
38
|
+
viewport?: ClassValue;
|
|
39
|
+
group?: ClassValue;
|
|
40
|
+
empty?: ClassValue;
|
|
41
|
+
label?: ClassValue;
|
|
42
|
+
separator?: ClassValue;
|
|
43
|
+
item?: ClassValue;
|
|
44
|
+
itemicon?: ClassValue;
|
|
45
|
+
dropdownicon?: ClassValue;
|
|
53
46
|
};
|
|
47
|
+
dropdownicon?: string | Component;
|
|
54
48
|
} & (
|
|
55
49
|
| {
|
|
56
50
|
value?: T;
|
|
@@ -76,37 +70,39 @@
|
|
|
76
70
|
highlight,
|
|
77
71
|
placeholder,
|
|
78
72
|
ui = {},
|
|
73
|
+
dropdownicon = getAppContext().icons.chevrondown,
|
|
79
74
|
}: SelectProps<T> = $props();
|
|
80
75
|
|
|
81
|
-
const
|
|
76
|
+
const variants = $derived(
|
|
82
77
|
tv({
|
|
83
78
|
slots: {
|
|
84
79
|
base: [
|
|
85
|
-
'relative group rounded-md inline-flex items-center focus:outline-none disabled:cursor-not-allowed disabled:opacity-75',
|
|
80
|
+
'relative group rounded-md inline-flex items-center justify-between focus:outline-none disabled:cursor-not-allowed disabled:opacity-75',
|
|
86
81
|
'transition-colors',
|
|
87
82
|
],
|
|
88
83
|
leading: 'absolute inset-y-0 start-0 flex items-center',
|
|
89
|
-
leadingIcon: 'shrink-0 text-dimmed',
|
|
84
|
+
leadingIcon: 'shrink-0 text-label-dimmed',
|
|
90
85
|
leadingAvatar: 'shrink-0',
|
|
91
86
|
leadingAvatarSize: '',
|
|
92
87
|
trailing: 'absolute inset-y-0 end-0 flex items-center',
|
|
93
|
-
trailingIcon: 'shrink-0 text-dimmed',
|
|
88
|
+
trailingIcon: 'shrink-0 text-label-dimmed',
|
|
94
89
|
value: 'truncate pointer-events-none',
|
|
95
|
-
placeholder: 'truncate text-dimmed',
|
|
90
|
+
placeholder: 'truncate text-label-dimmed',
|
|
96
91
|
arrow: 'fill-bg stroke-default',
|
|
97
92
|
content:
|
|
98
|
-
'max-h-60 w-(--bits-select-anchor-width) bg-inverted shadow-lg rounded-md ring ring-surface-accented overflow-hidden data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--bits-select-content-transform-origin) pointer-events-auto flex flex-col',
|
|
93
|
+
'max-h-60 w-(--bits-select-anchor-width) bg-label-inverted shadow-lg rounded-md ring p-1 ring-surface-accented overflow-hidden data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--bits-select-content-transform-origin) pointer-events-auto flex flex-col',
|
|
99
94
|
viewport: 'relative divide-y divide-base scroll-py-1 overflow-y-auto flex-1',
|
|
100
95
|
group: 'p-1 isolate',
|
|
101
|
-
empty: 'text-center text-muted',
|
|
102
|
-
label: 'font-semibold text-highlighted',
|
|
96
|
+
empty: 'text-center text-label-muted',
|
|
97
|
+
label: 'font-semibold text-label-highlighted',
|
|
103
98
|
separator: '-mx-1 my-1 h-px bg-border',
|
|
104
99
|
item: [
|
|
105
|
-
'group relative w-full flex items-start select-none outline-none
|
|
106
|
-
'
|
|
100
|
+
'group relative w-full flex items-start select-none outline-none whitespace-nowrap text-default rounded transition',
|
|
101
|
+
'data-disabled:cursor-not-allowed data-disabled:opacity-75',
|
|
102
|
+
'not-[data-disabled]:hover:text-label-highlighted not-[data-disabled]:hover:bg-surface-elevated/50',
|
|
107
103
|
],
|
|
108
104
|
itemLeadingIcon: [
|
|
109
|
-
'shrink-0 text-dimmed group-data-highlighted:not-group-data-disabled:text-default',
|
|
105
|
+
'shrink-0 text-label-dimmed group-data-highlighted:not-group-data-disabled:text-default',
|
|
110
106
|
'transition-colors',
|
|
111
107
|
],
|
|
112
108
|
itemLeadingAvatar: 'shrink-0',
|
|
@@ -117,7 +113,7 @@
|
|
|
117
113
|
itemTrailingIcon: 'shrink-0',
|
|
118
114
|
itemWrapper: 'flex-1 flex flex-col min-w-0',
|
|
119
115
|
itemLabel: 'truncate',
|
|
120
|
-
itemDescription: 'truncate text-muted',
|
|
116
|
+
itemDescription: 'truncate text-label-muted',
|
|
121
117
|
},
|
|
122
118
|
variants: {
|
|
123
119
|
fieldGroup: {
|
|
@@ -210,13 +206,13 @@
|
|
|
210
206
|
},
|
|
211
207
|
variant: {
|
|
212
208
|
outline:
|
|
213
|
-
'text-highlighted bg-default ring ring-inset ring-surface-accented hover:bg-surface-elevated disabled:bg-surface-default',
|
|
214
|
-
soft: 'text-highlighted bg-surface-elevated/50 hover:bg-surface-elevated focus:bg-surface-elevated disabled:bg-surface-elevated/50',
|
|
209
|
+
'text-label-highlighted bg-default ring ring-inset ring-surface-accented hover:bg-surface-elevated disabled:bg-surface-default',
|
|
210
|
+
soft: 'text-label-highlighted bg-surface-elevated/50 hover:bg-surface-elevated focus:bg-surface-elevated disabled:bg-surface-elevated/50',
|
|
215
211
|
subtle:
|
|
216
|
-
'text-highlighted bg-surface-elevated ring ring-inset ring-accented hover:bg-surface-accented/75 disabled:bg-surface-elevated',
|
|
212
|
+
'text-label-highlighted bg-surface-elevated ring ring-inset ring-accented hover:bg-surface-accented/75 disabled:bg-surface-elevated',
|
|
217
213
|
ghost:
|
|
218
|
-
'text-highlighted bg-transparent hover:bg-surface-elevated focus:bg-surface-elevated disabled:bg-transparent dark:disabled:bg-transparent',
|
|
219
|
-
none: 'text-highlighted bg-transparent',
|
|
214
|
+
'text-label-highlighted bg-transparent hover:bg-surface-elevated focus:bg-surface-elevated disabled:bg-transparent dark:disabled:bg-transparent',
|
|
215
|
+
none: 'text-label-highlighted bg-transparent',
|
|
220
216
|
},
|
|
221
217
|
color: {
|
|
222
218
|
primary: '',
|
|
@@ -242,7 +238,7 @@
|
|
|
242
238
|
false: '',
|
|
243
239
|
},
|
|
244
240
|
type: {
|
|
245
|
-
file: 'file:me-1.5 file:font-medium file:text-muted file:outline-none',
|
|
241
|
+
file: 'file:me-1.5 file:font-medium file:text-label-muted file:outline-none',
|
|
246
242
|
},
|
|
247
243
|
},
|
|
248
244
|
compoundVariants: [
|
|
@@ -407,13 +403,13 @@
|
|
|
407
403
|
(v) => (value = v as T | T[] | undefined)
|
|
408
404
|
}
|
|
409
405
|
>
|
|
410
|
-
<Select.Trigger class={
|
|
406
|
+
<Select.Trigger class={variants.base({ class: ui.base })}>
|
|
411
407
|
{value || placeholder}
|
|
412
|
-
<
|
|
408
|
+
<Icon name={dropdownicon} class="size-4" />
|
|
413
409
|
</Select.Trigger>
|
|
414
410
|
<Select.Portal>
|
|
415
411
|
<Select.Content
|
|
416
|
-
class={
|
|
412
|
+
class={variants.content({ class: ui.content })}
|
|
417
413
|
preventScroll={true}
|
|
418
414
|
sideOffset={8}
|
|
419
415
|
>
|
|
@@ -425,13 +421,13 @@
|
|
|
425
421
|
<Select.GroupHeading />
|
|
426
422
|
|
|
427
423
|
{#each item as group_item, gidx (gidx)}
|
|
428
|
-
<Select.Item class={
|
|
424
|
+
<Select.Item class={variants.item({ class: ui.item })} value=""></Select.Item>
|
|
429
425
|
{/each}
|
|
430
426
|
</Select.Group>
|
|
431
427
|
{:else}
|
|
432
428
|
{@const is_object = typeof item === 'object' && item !== null && 'value' in item}
|
|
433
429
|
<Select.Item
|
|
434
|
-
class={
|
|
430
|
+
class={variants.item({ class: ui.item })}
|
|
435
431
|
value={(is_object ? item.value : item) as string}
|
|
436
432
|
>
|
|
437
433
|
{item}
|