uisv 0.0.11 → 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.
Files changed (75) hide show
  1. package/dist/components/accordion.svelte +108 -0
  2. package/dist/components/accordion.svelte.d.ts +58 -0
  3. package/dist/components/alert.svelte +271 -0
  4. package/dist/components/alert.svelte.d.ts +23 -0
  5. package/dist/components/badge.svelte +225 -0
  6. package/dist/components/badge.svelte.d.ts +19 -0
  7. package/dist/components/banner.svelte +254 -0
  8. package/dist/components/banner.svelte.d.ts +23 -0
  9. package/dist/components/button/button.svelte +105 -0
  10. package/dist/components/button/button.svelte.d.ts +4 -0
  11. package/dist/components/button/index.d.ts +48 -0
  12. package/dist/components/button/index.js +4 -0
  13. package/dist/components/button/style.d.ts +148 -0
  14. package/dist/components/button/style.js +248 -0
  15. package/dist/components/card.svelte +70 -0
  16. package/dist/components/card.svelte.d.ts +17 -0
  17. package/dist/components/checkbox-group.svelte +258 -0
  18. package/dist/components/checkbox-group.svelte.d.ts +26 -0
  19. package/dist/components/checkbox.svelte +175 -0
  20. package/dist/components/checkbox.svelte.d.ts +27 -0
  21. package/dist/components/chip.svelte +82 -0
  22. package/dist/components/chip.svelte.d.ts +17 -0
  23. package/dist/components/color-picker.svelte +48 -0
  24. package/dist/components/color-picker.svelte.d.ts +10 -0
  25. package/dist/components/h1.svelte +15 -0
  26. package/dist/components/h1.svelte.d.ts +3 -0
  27. package/dist/components/h2.svelte +19 -0
  28. package/dist/components/h2.svelte.d.ts +3 -0
  29. package/dist/components/h3.svelte +16 -0
  30. package/dist/components/h3.svelte.d.ts +3 -0
  31. package/dist/components/h4.svelte +19 -0
  32. package/dist/components/h4.svelte.d.ts +3 -0
  33. package/dist/components/h5.svelte +19 -0
  34. package/dist/components/h5.svelte.d.ts +3 -0
  35. package/dist/components/h6.svelte +19 -0
  36. package/dist/components/h6.svelte.d.ts +3 -0
  37. package/dist/components/index.d.ts +42 -0
  38. package/dist/components/index.js +42 -0
  39. package/dist/components/input/index.d.ts +54 -0
  40. package/dist/components/input/index.js +2 -0
  41. package/dist/components/input/input.svelte +103 -0
  42. package/dist/components/input/input.svelte.d.ts +4 -0
  43. package/dist/components/input/style.d.ts +316 -0
  44. package/dist/components/input/style.js +128 -0
  45. package/dist/components/input-time/index.d.ts +375 -0
  46. package/dist/components/input-time/index.js +144 -0
  47. package/dist/components/input-time/input-time.svelte +39 -0
  48. package/dist/components/input-time/input-time.svelte.d.ts +4 -0
  49. package/dist/components/kbd.svelte +239 -0
  50. package/dist/components/kbd.svelte.d.ts +40 -0
  51. package/dist/components/p.svelte +9 -0
  52. package/dist/components/p.svelte.d.ts +3 -0
  53. package/dist/components/pin-input.svelte +162 -0
  54. package/dist/components/pin-input.svelte.d.ts +25 -0
  55. package/dist/components/placeholder.svelte +34 -0
  56. package/dist/components/placeholder.svelte.d.ts +3 -0
  57. package/dist/components/popover.svelte +151 -0
  58. package/dist/components/popover.svelte.d.ts +88 -0
  59. package/dist/components/progress.svelte +124 -0
  60. package/dist/components/progress.svelte.d.ts +21 -0
  61. package/dist/components/select.svelte +171 -0
  62. package/dist/components/select.svelte.d.ts +50 -0
  63. package/dist/components/slider.svelte +172 -0
  64. package/dist/components/slider.svelte.d.ts +44 -0
  65. package/dist/components/switch.svelte +180 -0
  66. package/dist/components/switch.svelte.d.ts +27 -0
  67. package/dist/components/tabs.svelte +246 -0
  68. package/dist/components/tabs.svelte.d.ts +34 -0
  69. package/dist/index.d.ts +4 -0
  70. package/dist/index.js +3 -0
  71. package/dist/utilities.svelte.d.ts +24 -0
  72. package/dist/utilities.svelte.js +47 -0
  73. package/dist/vite.d.ts +51 -0
  74. package/dist/vite.js +157 -0
  75. package/package.json +2 -2
@@ -0,0 +1,239 @@
1
+ <script module lang="ts">
2
+ import type { PropColor } from '../index.js';
3
+ import type { Snippet } from 'svelte';
4
+ import type { ClassNameValue } from 'tailwind-merge';
5
+ import { tv } from 'tailwind-variants';
6
+
7
+ export type KbdProps = {
8
+ children?: Snippet;
9
+ value?: string;
10
+ color?: PropColor;
11
+ variant?: 'solid' | 'outline' | 'soft' | 'subtle';
12
+ size?: 'sm' | 'md' | 'lg';
13
+ class?: ClassNameValue;
14
+ };
15
+
16
+ export const KBD_KEYS = {
17
+ meta: '',
18
+ ctrl: '',
19
+ alt: '',
20
+ win: '⊞',
21
+ command: '⌘',
22
+ shift: '⇧',
23
+ control: '⌃',
24
+ option: '⌥',
25
+ enter: '↵',
26
+ delete: '⌦',
27
+ backspace: '⌫',
28
+ escape: 'Esc',
29
+ tab: '⇥',
30
+ capslock: '⇪',
31
+ arrowup: '↑',
32
+ arrowright: '→',
33
+ arrowdown: '↓',
34
+ arrowleft: '←',
35
+ pageup: '⇞',
36
+ pagedown: '⇟',
37
+ home: '↖',
38
+ end: '↘'
39
+ };
40
+
41
+ export type KbdKey = keyof typeof KBD_KEYS;
42
+ export type KbdSpecificKey = 'meta' | 'alt' | 'ctrl';
43
+ </script>
44
+
45
+ <script lang="ts">
46
+ const {
47
+ children,
48
+ value,
49
+ color = 'primary',
50
+ variant = 'outline',
51
+ size = 'md',
52
+ class: klass
53
+ }: KbdProps = $props();
54
+
55
+ const macOS = $derived.by(() => {
56
+ if (typeof navigator === 'undefined') return null;
57
+ if (!navigator.userAgent) return null;
58
+ return navigator.userAgent.match(/Macintosh;/);
59
+ });
60
+
61
+ const kbdKeysSpecificMap = $derived({
62
+ meta: macOS ? KBD_KEYS.command : 'Ctrl',
63
+ alt: macOS ? KBD_KEYS.command : 'Ctrl',
64
+ ctrl: macOS ? KBD_KEYS.option : 'Alt'
65
+ });
66
+
67
+ function getKey(value?: KbdKey | string) {
68
+ if (!value) {
69
+ return;
70
+ }
71
+
72
+ if (['meta', 'alt', 'ctrl'].includes(value)) {
73
+ return kbdKeysSpecificMap[value as KbdSpecificKey];
74
+ }
75
+
76
+ return KBD_KEYS[value as KbdKey] || value.toUpperCase();
77
+ }
78
+ </script>
79
+
80
+ <kbd
81
+ class={tv({
82
+ base: 'inline-flex items-center justify-center px-1 rounded-sm font-medium font-sans text-xs',
83
+ variants: {
84
+ color: {
85
+ primary: '',
86
+ surface: '',
87
+ info: '',
88
+ success: '',
89
+ warning: '',
90
+ error: ''
91
+ },
92
+ variant: {
93
+ solid: 'text-white border border-b-3 border-r-2',
94
+ outline: 'border border-b-3 border-r-2',
95
+ soft: '',
96
+ subtle: 'border border-b-3 border-r-2'
97
+ },
98
+ size: {
99
+ sm: 'h-4 min-w-4',
100
+ md: 'h-5 min-w-5',
101
+ lg: 'h-6 min-w-6'
102
+ }
103
+ },
104
+ compoundVariants: [
105
+ {
106
+ color: 'primary',
107
+ variant: 'outline',
108
+ class: 'border-primary text-primary'
109
+ },
110
+ {
111
+ color: 'surface',
112
+ variant: 'outline',
113
+ class: 'border-surface-600'
114
+ },
115
+ {
116
+ color: 'info',
117
+ variant: 'outline',
118
+ class: 'border-info text-info'
119
+ },
120
+ {
121
+ color: 'success',
122
+ variant: 'outline',
123
+ class: 'border-success text-success'
124
+ },
125
+ {
126
+ color: 'warning',
127
+ variant: 'outline',
128
+ class: 'border-warning text-warning'
129
+ },
130
+ {
131
+ color: 'error',
132
+ variant: 'outline',
133
+ class: 'border-error text-error'
134
+ },
135
+
136
+ // SOLID
137
+ {
138
+ color: 'primary',
139
+ variant: 'solid',
140
+ class: 'bg-primary border-primary-600'
141
+ },
142
+ {
143
+ color: 'surface',
144
+ variant: 'solid',
145
+ class: 'bg-surface-600 border-surface-700'
146
+ },
147
+ {
148
+ color: 'info',
149
+ variant: 'solid',
150
+ class: 'bg-info border-info-600'
151
+ },
152
+ {
153
+ color: 'success',
154
+ variant: 'solid',
155
+ class: 'bg-success border-success-600'
156
+ },
157
+ {
158
+ color: 'warning',
159
+ variant: 'solid',
160
+ class: 'bg-warning border-warning-600'
161
+ },
162
+ {
163
+ color: 'error',
164
+ variant: 'solid',
165
+ class: 'bg-error border-error-600'
166
+ },
167
+
168
+ // SOFT
169
+ {
170
+ color: 'primary',
171
+ variant: 'soft',
172
+ class: 'bg-primary-100 text-primary'
173
+ },
174
+ {
175
+ color: 'surface',
176
+ variant: 'soft',
177
+ class: 'bg-surface-100 text-surface-700'
178
+ },
179
+ {
180
+ color: 'info',
181
+ variant: 'soft',
182
+ class: 'bg-info-100 text-info'
183
+ },
184
+ {
185
+ color: 'success',
186
+ variant: 'soft',
187
+ class: 'bg-success-100 text-success'
188
+ },
189
+ {
190
+ color: 'warning',
191
+ variant: 'soft',
192
+ class: 'bg-warning-100 text-warning'
193
+ },
194
+ {
195
+ color: 'error',
196
+ variant: 'soft',
197
+ class: 'bg-error-100 text-error'
198
+ },
199
+
200
+ // SUBTLE
201
+ {
202
+ color: 'primary',
203
+ variant: 'subtle',
204
+ class: 'bg-primary-100 border-primary-200 text-primary'
205
+ },
206
+ {
207
+ color: 'surface',
208
+ variant: 'subtle',
209
+ class: 'bg-surface-100 border-surface-200 text-surface-700'
210
+ },
211
+ {
212
+ color: 'info',
213
+ variant: 'subtle',
214
+ class: 'bg-info-100 border-info-200 text-info'
215
+ },
216
+ {
217
+ color: 'success',
218
+ variant: 'subtle',
219
+ class: 'bg-success-100 border-success-200 text-success'
220
+ },
221
+ {
222
+ color: 'warning',
223
+ variant: 'subtle',
224
+ class: 'bg-warning-100 border-warning-200 text-warning'
225
+ },
226
+ {
227
+ color: 'error',
228
+ variant: 'subtle',
229
+ class: 'bg-error-100 border-error-200 text-error'
230
+ }
231
+ ]
232
+ })({ color, variant, size, class: [klass] })}
233
+ >
234
+ {#if value}
235
+ {getKey(value)}
236
+ {:else}
237
+ {@render children?.()}
238
+ {/if}
239
+ </kbd>
@@ -0,0 +1,40 @@
1
+ import type { PropColor } from '../index.js';
2
+ import type { Snippet } from 'svelte';
3
+ import type { ClassNameValue } from 'tailwind-merge';
4
+ export type KbdProps = {
5
+ children?: Snippet;
6
+ value?: string;
7
+ color?: PropColor;
8
+ variant?: 'solid' | 'outline' | 'soft' | 'subtle';
9
+ size?: 'sm' | 'md' | 'lg';
10
+ class?: ClassNameValue;
11
+ };
12
+ export declare const KBD_KEYS: {
13
+ meta: string;
14
+ ctrl: string;
15
+ alt: string;
16
+ win: string;
17
+ command: string;
18
+ shift: string;
19
+ control: string;
20
+ option: string;
21
+ enter: string;
22
+ delete: string;
23
+ backspace: string;
24
+ escape: string;
25
+ tab: string;
26
+ capslock: string;
27
+ arrowup: string;
28
+ arrowright: string;
29
+ arrowdown: string;
30
+ arrowleft: string;
31
+ pageup: string;
32
+ pagedown: string;
33
+ home: string;
34
+ end: string;
35
+ };
36
+ export type KbdKey = keyof typeof KBD_KEYS;
37
+ export type KbdSpecificKey = 'meta' | 'alt' | 'ctrl';
38
+ declare const Kbd: import("svelte").Component<KbdProps, {}, "">;
39
+ type Kbd = ReturnType<typeof Kbd>;
40
+ export default Kbd;
@@ -0,0 +1,9 @@
1
+ <script lang="ts">
2
+ import type { SvelteHTMLElements } from 'svelte/elements';
3
+ import { cn } from 'tailwind-variants';
4
+ const { children, class: classes }: SvelteHTMLElements['p'] = $props();
5
+ </script>
6
+
7
+ <p class={cn('my-5 leading-7 text-pretty', classes)}>
8
+ {@render children?.()}
9
+ </p>
@@ -0,0 +1,3 @@
1
+ declare const P: import("svelte").Component<import("svelte/elements").HTMLAttributes<HTMLParagraphElement>, {}, "">;
2
+ type P = ReturnType<typeof P>;
3
+ export default P;
@@ -0,0 +1,162 @@
1
+ <script module lang="ts">
2
+ import type { PropColor } from '../index.js';
3
+ import { onMount } from 'svelte';
4
+ import type { ClassNameValue } from 'tailwind-merge';
5
+ import { tv } from 'tailwind-variants';
6
+
7
+ export type PinInputProps = {
8
+ value?: number[] | string[];
9
+ color?: PropColor;
10
+ variant?: 'outline' | 'soft' | 'subtle' | 'ghost' | 'none';
11
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
12
+ length?: number;
13
+ autofocus?: boolean | number;
14
+ id?: string;
15
+ mask?: boolean;
16
+ name?: string;
17
+ disabled?: boolean;
18
+ otp?: boolean;
19
+ placeholder?: string;
20
+ required?: boolean;
21
+ type?: 'text' | 'number';
22
+ ui?: { root?: ClassNameValue; cell?: ClassNameValue };
23
+ };
24
+ </script>
25
+
26
+ <script lang="ts">
27
+ const KEYS_TO_IGNORE = [
28
+ 'ArrowLeft',
29
+ 'ArrowRight',
30
+ 'ArrowUp',
31
+ 'ArrowDown',
32
+ 'Home',
33
+ 'End',
34
+ 'Escape',
35
+ 'Enter',
36
+ 'Tab',
37
+ 'Shift',
38
+ 'Control',
39
+ 'Meta'
40
+ ];
41
+
42
+ let {
43
+ value = $bindable([]),
44
+ color = 'primary',
45
+ variant = 'outline',
46
+ size = 'md',
47
+ length = 5,
48
+ autofocus,
49
+ id,
50
+ mask,
51
+ name,
52
+ disabled,
53
+ otp,
54
+ placeholder,
55
+ required,
56
+ type = 'text',
57
+ ui = {}
58
+ }: PinInputProps = $props();
59
+ const internal_id = $props.id();
60
+ let input_els = $state<HTMLInputElement[]>([]);
61
+
62
+ const classes = $derived(
63
+ tv({
64
+ slots: { root: 'flex gap-2', cell: 'rounded text-center outline-none transition relative' },
65
+ variants: {
66
+ color: {
67
+ primary: '',
68
+ surface: '',
69
+ info: '',
70
+ success: '',
71
+ warning: '',
72
+ error: ''
73
+ },
74
+ size: {
75
+ xs: { root: '', cell: 'size-6' },
76
+ sm: { root: '', cell: 'size-7' },
77
+ md: { root: '', cell: 'size-8' },
78
+ lg: { root: '', cell: 'size-9' },
79
+ xl: { root: '', cell: 'size-10' }
80
+ },
81
+ variant: {
82
+ outline: {
83
+ cell: 'border border-surface-300 focus:(border-2)'
84
+ },
85
+ soft: {
86
+ cell: 'bg-surface-50 hover:(bg-surface-100) focus:(bg-surface-100)'
87
+ },
88
+ subtle: { cell: 'border border-surface-300 bg-surface-100 focus:(border-2)' },
89
+ ghost: { cell: 'hover:(bg-surface-100) focus:(bg-surface-100)' },
90
+ none: { cell: '' }
91
+ }
92
+ },
93
+ compoundVariants: [
94
+ {
95
+ variant: ['outline', 'subtle'],
96
+ color: 'primary',
97
+ class: { cell: 'focus:(border-primary-500)' }
98
+ },
99
+ {
100
+ variant: ['outline', 'subtle'],
101
+ color: 'surface',
102
+ class: { cell: 'focus:(border-surface-900)' }
103
+ },
104
+ {
105
+ variant: ['outline', 'subtle'],
106
+ color: 'info',
107
+ class: { cell: 'focus:(border-info-500)' }
108
+ },
109
+ {
110
+ variant: ['outline', 'subtle'],
111
+ color: 'success',
112
+ class: { cell: 'focus:(border-success-500)' }
113
+ },
114
+ {
115
+ variant: ['outline', 'subtle'],
116
+ color: 'warning',
117
+ class: { cell: 'focus:(border-warning-500)' }
118
+ },
119
+ {
120
+ variant: ['outline', 'subtle'],
121
+ color: 'error',
122
+ class: { cell: 'focus:(border-error-500)' }
123
+ }
124
+ ]
125
+ })({ size, color, variant, class: ui.root })
126
+ );
127
+
128
+ onMount(() => {
129
+ if (!autofocus || input_els.length === 0) return;
130
+
131
+ input_els[0].focus();
132
+ });
133
+ </script>
134
+
135
+ <div id={id || internal_id} class={classes.root({ class: ui.root })}>
136
+ {#each { length }, i (i)}
137
+ <input
138
+ bind:this={input_els[i]}
139
+ bind:value={
140
+ () => (mask ? '•' : value[i]?.toString()?.slice(-1)),
141
+ (v: string) => {
142
+ try {
143
+ value[i] = type === 'text' ? v.slice(-1) : parseInt(v.slice(-1));
144
+
145
+ if (value[i] && input_els[i + 1]) input_els[i + 1].focus();
146
+ } catch {
147
+ return;
148
+ }
149
+ }
150
+ }
151
+ class={classes.cell({ class: ui.cell })}
152
+ onkeydown={(e) => {
153
+ if (KEYS_TO_IGNORE.includes(e.key)) e.preventDefault();
154
+ if (type === 'number' && isNaN(parseInt(e.key))) e.preventDefault();
155
+ const DIR: Record<string, number> = { ArrowLeft: -1, ArrowRight: 1 };
156
+ if (!DIR[e.key] || !input_els[i + DIR[e.key]]) return;
157
+ input_els[i + DIR[e.key]].focus();
158
+ }}
159
+ {placeholder}
160
+ />
161
+ {/each}
162
+ </div>
@@ -0,0 +1,25 @@
1
+ import type { PropColor } from '../index.js';
2
+ import type { ClassNameValue } from 'tailwind-merge';
3
+ export type PinInputProps = {
4
+ value?: number[] | string[];
5
+ color?: PropColor;
6
+ variant?: 'outline' | 'soft' | 'subtle' | 'ghost' | 'none';
7
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
8
+ length?: number;
9
+ autofocus?: boolean | number;
10
+ id?: string;
11
+ mask?: boolean;
12
+ name?: string;
13
+ disabled?: boolean;
14
+ otp?: boolean;
15
+ placeholder?: string;
16
+ required?: boolean;
17
+ type?: 'text' | 'number';
18
+ ui?: {
19
+ root?: ClassNameValue;
20
+ cell?: ClassNameValue;
21
+ };
22
+ };
23
+ declare const PinInput: import("svelte").Component<PinInputProps, {}, "value">;
24
+ type PinInput = ReturnType<typeof PinInput>;
25
+ export default PinInput;
@@ -0,0 +1,34 @@
1
+ <script lang="ts">
2
+ import type { SvelteHTMLElements } from 'svelte/elements';
3
+ import { cx } from 'tailwind-variants';
4
+
5
+ let { class: klass, ...rest }: SvelteHTMLElements['svg'] = $props();
6
+ </script>
7
+
8
+ <svg
9
+ {...rest}
10
+ class={cx(
11
+ 'inset-0 w-full stroke-surface/10 border border-dashed border-surface rounded-md',
12
+ klass,
13
+ )}
14
+ fill="none"
15
+ >
16
+ <defs>
17
+ <pattern
18
+ id="pattern-5c1e4f0e-62d5-498b-8ff0-cf77bb448c8e"
19
+ x="0"
20
+ y="0"
21
+ width="10"
22
+ height="10"
23
+ patternUnits="userSpaceOnUse"
24
+ >
25
+ <path d="M-3 13 15-5M-5 5l18-18M-1 21 17 3"> </path>
26
+ </pattern>
27
+ </defs>
28
+ <rect
29
+ stroke="none"
30
+ fill="url(#pattern-5c1e4f0e-62d5-498b-8ff0-cf77bb448c8e)"
31
+ width="100%"
32
+ height="100%"
33
+ ></rect>
34
+ </svg>
@@ -0,0 +1,3 @@
1
+ declare const Placeholder: import("svelte").Component<import("svelte/elements").SVGAttributes<SVGSVGElement>, {}, "">;
2
+ type Placeholder = ReturnType<typeof Placeholder>;
3
+ export default Placeholder;
@@ -0,0 +1,151 @@
1
+ <script module lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { ClassNameValue } from 'tailwind-merge';
4
+ import { Popover, type PopoverContentProps } from 'bits-ui';
5
+ import { cn, tv } from 'tailwind-variants';
6
+ import { type ButtonProps,Button } from '../index.js';
7
+ import type { PropColor } from '../index.js';
8
+
9
+ export type PopoverContentSnippet = {
10
+ props: Record<string, unknown>;
11
+ open: boolean;
12
+ wrapperProps: Record<string, unknown>;
13
+ };
14
+
15
+ export type PopoverProps = {
16
+ /**
17
+ * The display mode of the popover.
18
+ */
19
+ mode?: 'hover' | 'click';
20
+ /**
21
+ * The props for the content of popover.
22
+ */
23
+ contentprops?: PopoverContentProps;
24
+ content?: Snippet<[PopoverContentSnippet]>;
25
+ children?: Snippet<[]>;
26
+ /**
27
+ * Snippet if you want to implement your own trigger button
28
+ */
29
+ trigger?: Snippet<[Record<string, unknown>]>;
30
+ /**
31
+ * Display an arrow alongside the popover.
32
+ */
33
+ arrow?: boolean;
34
+ /**
35
+ * Render the popover in a portal.
36
+ */
37
+ portal?: string | false | true | HTMLElement;
38
+ /**
39
+ * The reference (or anchor) element that is being referred to for positioning. If not provided will use the current component as anchor.
40
+ */
41
+ reference?:
42
+ | Element
43
+ | {
44
+ getBoundingClientRect: () => DOMRect;
45
+ getClientRects: () => DOMRect[];
46
+ contextElement?: Element;
47
+ };
48
+ /**
49
+ * When `false`, the popover will not close when clicking outside or pressing escape.
50
+ */
51
+ 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
+ /**
57
+ * The controlled open state of the popover.
58
+ */
59
+ open?: boolean;
60
+ /**
61
+ * 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.
62
+ */
63
+ modal?: boolean;
64
+ /**
65
+ * The duration from when the mouse enters the trigger until the hover card opens.
66
+ */
67
+ opendelay?: number;
68
+ /**
69
+ * The duration from when the mouse leaves the trigger or content until the hover card closes.
70
+ */
71
+ closedelay?: number;
72
+ /**
73
+ *
74
+ */
75
+ ui?: {
76
+ content?: ClassNameValue;
77
+ arrow?: ClassNameValue;
78
+ };
79
+ /**
80
+ * @default `outline`
81
+ */
82
+ variant?: ButtonProps['variant'];
83
+ /**
84
+ * @default primary
85
+ */
86
+ color?: PropColor;
87
+ /**
88
+ *
89
+ */
90
+ class?: ClassNameValue;
91
+ };
92
+ </script>
93
+
94
+ <script lang="ts">
95
+ let {
96
+ mode = 'click',
97
+ contentprops = { side: 'bottom', sideOffset: 8, collisionPadding: 8 },
98
+ content,
99
+ children,
100
+ trigger,
101
+ arrow = true,
102
+ portal = true,
103
+ reference,
104
+ dismissible = true,
105
+ defaultopen,
106
+ open = $bindable(false),
107
+ modal = false,
108
+ opendelay = 0,
109
+ closedelay = 0,
110
+ ui = {},
111
+ variant = 'outline',
112
+ color = 'primary',
113
+ class: klass,
114
+ }: PopoverProps = $props();
115
+
116
+ const classes = $derived(
117
+ tv({
118
+ slots: {
119
+ content:
120
+ 'bg-default shadow-lg rounded-md ring ring-default data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--reka-popover-content-transform-origin) focus:outline-none pointer-events-auto',
121
+ arrow: 'fill-default',
122
+ },
123
+ })({}),
124
+ );
125
+ </script>
126
+
127
+ <Popover.Root bind:open>
128
+ <Popover.Trigger>
129
+ {#snippet child({ props })}
130
+ {#if trigger}
131
+ {@render trigger(props)}
132
+ {:else}
133
+ <Button {...props} {variant} {color} ui={{ base: klass }} />
134
+ {/if}
135
+ {/snippet}
136
+ </Popover.Trigger>
137
+ <Popover.Portal>
138
+ <Popover.Overlay />
139
+ <Popover.Content {...contentprops} class={classes.content({ class: ui.content })}>
140
+ {#snippet child(props)}
141
+ {#if content}
142
+ {@render content(props)}
143
+ {:else}
144
+ {@render children?.()}
145
+ {/if}
146
+ {/snippet}
147
+
148
+ <Popover.Arrow />
149
+ </Popover.Content>
150
+ </Popover.Portal>
151
+ </Popover.Root>