sv5ui 1.1.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/Alert/Alert.svelte +33 -22
- package/dist/Alert/Alert.svelte.d.ts +1 -1
- package/dist/Alert/alert.types.d.ts +4 -0
- package/dist/Avatar/Avatar.svelte +72 -46
- package/dist/Avatar/avatar.types.d.ts +36 -3
- package/dist/Avatar/avatar.variants.d.ts +138 -0
- package/dist/Avatar/avatar.variants.js +23 -12
- package/dist/Avatar/index.d.ts +1 -1
- package/dist/AvatarGroup/AvatarGroup.svelte +11 -6
- package/dist/AvatarGroup/AvatarGroup.svelte.d.ts +1 -1
- package/dist/AvatarGroup/avatar-group.types.d.ts +18 -3
- package/dist/AvatarGroup/avatar-group.variants.d.ts +85 -0
- package/dist/AvatarGroup/avatar-group.variants.js +19 -29
- package/dist/Badge/Badge.svelte +4 -3
- package/dist/Badge/Badge.svelte.d.ts +1 -1
- package/dist/Badge/badge.types.d.ts +9 -0
- package/dist/Breadcrumb/Breadcrumb.svelte +20 -7
- package/dist/Breadcrumb/Breadcrumb.svelte.d.ts +1 -1
- package/dist/Breadcrumb/breadcrumb.types.d.ts +5 -1
- package/dist/Breadcrumb/breadcrumb.variants.d.ts +15 -5
- package/dist/Breadcrumb/breadcrumb.variants.js +7 -3
- package/dist/Button/Button.svelte +71 -16
- package/dist/Button/Button.svelte.d.ts +0 -1
- package/dist/Button/button.types.d.ts +61 -2
- package/dist/Calendar/Calendar.svelte +4 -0
- package/dist/Calendar/Calendar.svelte.d.ts +1 -1
- package/dist/Calendar/calendar.types.d.ts +4 -0
- package/dist/Card/Card.svelte +5 -4
- package/dist/Card/Card.svelte.d.ts +1 -1
- package/dist/Card/card.types.d.ts +5 -1
- package/dist/Checkbox/Checkbox.svelte +37 -11
- package/dist/Checkbox/Checkbox.svelte.d.ts +1 -1
- package/dist/Checkbox/checkbox.types.d.ts +16 -1
- package/dist/Checkbox/checkbox.variants.d.ts +90 -0
- package/dist/Checkbox/checkbox.variants.js +73 -4
- package/dist/CheckboxGroup/CheckboxGroup.svelte +215 -0
- package/dist/CheckboxGroup/CheckboxGroup.svelte.d.ts +5 -0
- package/dist/CheckboxGroup/checkbox-group.types.d.ts +130 -0
- package/dist/CheckboxGroup/checkbox-group.types.js +1 -0
- package/dist/CheckboxGroup/checkbox-group.variants.d.ts +553 -0
- package/dist/CheckboxGroup/checkbox-group.variants.js +231 -0
- package/dist/CheckboxGroup/index.d.ts +2 -0
- package/dist/CheckboxGroup/index.js +1 -0
- package/dist/Chip/Chip.svelte +3 -2
- package/dist/Chip/Chip.svelte.d.ts +1 -1
- package/dist/Chip/chip.types.d.ts +5 -1
- package/dist/Chip/chip.variants.d.ts +135 -45
- package/dist/Chip/chip.variants.js +9 -9
- package/dist/ContextMenu/ContextMenu.svelte +87 -77
- package/dist/ContextMenu/ContextMenu.svelte.d.ts +1 -1
- package/dist/ContextMenu/context-menu.types.d.ts +9 -3
- package/dist/ContextMenu/context-menu.types.js +1 -1
- package/dist/ContextMenu/context-menu.variants.d.ts +74 -160
- package/dist/ContextMenu/context-menu.variants.js +63 -95
- package/dist/DropdownMenu/DropdownMenu.svelte +37 -43
- package/dist/DropdownMenu/DropdownMenu.svelte.d.ts +1 -1
- package/dist/DropdownMenu/dropdown-menu.types.d.ts +9 -3
- package/dist/DropdownMenu/dropdown-menu.types.js +1 -1
- package/dist/DropdownMenu/dropdown-menu.variants.d.ts +79 -230
- package/dist/DropdownMenu/dropdown-menu.variants.js +68 -111
- package/dist/DropdownMenu/index.d.ts +1 -1
- package/dist/Empty/Empty.svelte +68 -33
- package/dist/Empty/Empty.svelte.d.ts +1 -1
- package/dist/Empty/empty.types.d.ts +26 -9
- package/dist/Empty/empty.variants.d.ts +150 -130
- package/dist/Empty/empty.variants.js +33 -324
- package/dist/FieldGroup/FieldGroup.svelte +11 -6
- package/dist/FieldGroup/FieldGroup.svelte.d.ts +1 -1
- package/dist/FieldGroup/field-group.types.d.ts +4 -0
- package/dist/FileUpload/FileUpload.svelte +561 -0
- package/dist/FileUpload/FileUpload.svelte.d.ts +8 -0
- package/dist/FileUpload/file-upload.types.d.ts +164 -0
- package/dist/FileUpload/file-upload.types.js +1 -0
- package/dist/FileUpload/file-upload.variants.d.ts +397 -0
- package/dist/FileUpload/file-upload.variants.js +224 -0
- package/dist/FileUpload/index.d.ts +2 -0
- package/dist/FileUpload/index.js +1 -0
- package/dist/FormField/FormField.svelte +17 -18
- package/dist/FormField/FormField.svelte.d.ts +1 -1
- package/dist/FormField/form-field.types.d.ts +4 -0
- package/dist/Icon/Icon.svelte +13 -7
- package/dist/Icon/icon.types.d.ts +18 -9
- package/dist/Input/Input.svelte +30 -29
- package/dist/Kbd/Kbd.svelte +13 -3
- package/dist/Kbd/Kbd.svelte.d.ts +1 -1
- package/dist/Kbd/index.d.ts +1 -1
- package/dist/Kbd/kbd.types.d.ts +15 -1
- package/dist/Kbd/kbd.variants.d.ts +92 -30
- package/dist/Kbd/kbd.variants.js +55 -35
- package/dist/Kbd/useKbd.svelte.d.ts +2 -2
- package/dist/Kbd/useKbd.svelte.js +34 -41
- package/dist/Link/Link.svelte +69 -24
- package/dist/Link/Link.svelte.d.ts +1 -1
- package/dist/Link/link.types.d.ts +26 -8
- package/dist/Link/link.variants.d.ts +35 -60
- package/dist/Link/link.variants.js +8 -110
- package/dist/Modal/Modal.svelte +9 -1
- package/dist/Modal/modal.types.d.ts +5 -0
- package/dist/Modal/modal.variants.d.ts +5 -0
- package/dist/Modal/modal.variants.js +1 -0
- package/dist/Pagination/Pagination.svelte +143 -94
- package/dist/Pagination/Pagination.svelte.d.ts +1 -1
- package/dist/Pagination/index.d.ts +1 -1
- package/dist/Pagination/pagination.types.d.ts +21 -2
- package/dist/Pagination/pagination.variants.d.ts +21 -387
- package/dist/Pagination/pagination.variants.js +63 -59
- package/dist/PinInput/PinInput.svelte +150 -0
- package/dist/PinInput/PinInput.svelte.d.ts +6 -0
- package/dist/PinInput/index.d.ts +2 -0
- package/dist/PinInput/index.js +1 -0
- package/dist/PinInput/pin-input.types.d.ts +99 -0
- package/dist/PinInput/pin-input.types.js +1 -0
- package/dist/PinInput/pin-input.variants.d.ts +303 -0
- package/dist/PinInput/pin-input.variants.js +196 -0
- package/dist/Popover/Popover.svelte +9 -12
- package/dist/Popover/Popover.svelte.d.ts +1 -1
- package/dist/Popover/popover.types.d.ts +4 -0
- package/dist/Popover/popover.variants.d.ts +5 -75
- package/dist/Popover/popover.variants.js +6 -16
- package/dist/Progress/Progress.svelte +58 -30
- package/dist/Progress/progress.types.d.ts +9 -1
- package/dist/Progress/progress.variants.d.ts +55 -25
- package/dist/Progress/progress.variants.js +34 -28
- package/dist/RadioGroup/RadioGroup.svelte +105 -61
- package/dist/RadioGroup/RadioGroup.svelte.d.ts +1 -1
- package/dist/RadioGroup/radio-group.types.d.ts +16 -1
- package/dist/RadioGroup/radio-group.variants.d.ts +90 -0
- package/dist/RadioGroup/radio-group.variants.js +73 -4
- package/dist/Select/Select.svelte +9 -6
- package/dist/Select/Select.svelte.d.ts +1 -1
- package/dist/Select/select.types.d.ts +4 -0
- package/dist/SelectMenu/SelectMenu.svelte +436 -0
- package/dist/SelectMenu/SelectMenu.svelte.d.ts +5 -0
- package/dist/SelectMenu/index.d.ts +2 -0
- package/dist/SelectMenu/index.js +1 -0
- package/dist/SelectMenu/select-menu.types.d.ts +262 -0
- package/dist/SelectMenu/select-menu.types.js +1 -0
- package/dist/SelectMenu/select-menu.variants.d.ts +759 -0
- package/dist/SelectMenu/select-menu.variants.js +33 -0
- package/dist/Separator/Separator.svelte +1 -2
- package/dist/Separator/separator.variants.d.ts +1 -5
- package/dist/Separator/separator.variants.js +2 -2
- package/dist/Skeleton/Skeleton.svelte +18 -2
- package/dist/Skeleton/Skeleton.svelte.d.ts +1 -1
- package/dist/Skeleton/skeleton.types.d.ts +10 -1
- package/dist/Slideover/Slideover.svelte +9 -1
- package/dist/Slideover/slideover.types.d.ts +5 -0
- package/dist/Slideover/slideover.variants.d.ts +20 -5
- package/dist/Slideover/slideover.variants.js +4 -29
- package/dist/Slider/Slider.svelte +135 -0
- package/dist/Slider/Slider.svelte.d.ts +6 -0
- package/dist/Slider/index.d.ts +2 -0
- package/dist/Slider/index.js +1 -0
- package/dist/Slider/slider.types.d.ts +55 -0
- package/dist/Slider/slider.types.js +1 -0
- package/dist/Slider/slider.variants.d.ts +383 -0
- package/dist/Slider/slider.variants.js +102 -0
- package/dist/Switch/Switch.svelte +32 -31
- package/dist/Switch/Switch.svelte.d.ts +1 -1
- package/dist/Switch/switch.types.d.ts +6 -1
- package/dist/Switch/switch.variants.js +6 -6
- package/dist/Tabs/Tabs.svelte +6 -9
- package/dist/Tabs/Tabs.svelte.d.ts +1 -1
- package/dist/Tabs/tabs.types.d.ts +4 -0
- package/dist/Tabs/tabs.variants.js +2 -0
- package/dist/Textarea/Textarea.svelte +26 -25
- package/dist/ThemeModeButton/theme-mode-button.types.d.ts +7 -2
- package/dist/Timeline/Timeline.svelte +62 -19
- package/dist/Timeline/Timeline.svelte.d.ts +1 -1
- package/dist/Timeline/index.d.ts +1 -1
- package/dist/Timeline/timeline.types.d.ts +8 -0
- package/dist/Tooltip/Tooltip.svelte +12 -10
- package/dist/Tooltip/Tooltip.svelte.d.ts +1 -1
- package/dist/Tooltip/tooltip.types.d.ts +8 -4
- package/dist/Tooltip/tooltip.variants.d.ts +10 -75
- package/dist/Tooltip/tooltip.variants.js +8 -17
- package/dist/User/User.svelte +13 -9
- package/dist/User/User.svelte.d.ts +1 -1
- package/dist/User/user.types.d.ts +4 -0
- package/dist/User/user.variants.d.ts +60 -0
- package/dist/User/user.variants.js +13 -1
- package/dist/config.d.ts +8 -0
- package/dist/config.js +9 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/package.json +2 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
import { selectVariants } from '../Select/select.variants.js';
|
|
3
|
+
export const selectMenuVariants = tv({
|
|
4
|
+
extend: selectVariants,
|
|
5
|
+
slots: {
|
|
6
|
+
content: [
|
|
7
|
+
'z-50 max-h-60 w-(--bits-floating-anchor-width)',
|
|
8
|
+
'bg-surface-container-low text-on-surface',
|
|
9
|
+
'rounded-md',
|
|
10
|
+
'ring ring-outline-variant/50',
|
|
11
|
+
'shadow-lg',
|
|
12
|
+
'focus:outline-none',
|
|
13
|
+
'overflow-hidden',
|
|
14
|
+
'flex flex-col'
|
|
15
|
+
],
|
|
16
|
+
input: 'border-b border-outline-variant',
|
|
17
|
+
viewport: 'p-1 flex-1 overflow-y-auto',
|
|
18
|
+
empty: 'text-center text-on-surface-variant'
|
|
19
|
+
},
|
|
20
|
+
variants: {
|
|
21
|
+
size: {
|
|
22
|
+
xs: { empty: 'p-2 text-xs' },
|
|
23
|
+
sm: { empty: 'p-2.5 text-xs' },
|
|
24
|
+
md: { empty: 'p-2.5 text-sm' },
|
|
25
|
+
lg: { empty: 'p-3 text-sm' },
|
|
26
|
+
xl: { empty: 'p-3 text-base' }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export const selectMenuDefaults = {
|
|
31
|
+
defaultVariants: selectMenuVariants.defaultVariants,
|
|
32
|
+
slots: {}
|
|
33
|
+
};
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
container: slots.container({ class: [config.slots.container, ui?.container] }),
|
|
41
41
|
icon: slots.icon({ class: [config.slots.icon, ui?.icon] }),
|
|
42
42
|
avatar: slots.avatar({ class: [config.slots.avatar, ui?.avatar] }),
|
|
43
|
-
avatarSize: slots.avatarSize() as AvatarSize,
|
|
44
43
|
label: slots.label({ class: [config.slots.label, ui?.label] })
|
|
45
44
|
}
|
|
46
45
|
})
|
|
@@ -56,7 +55,7 @@
|
|
|
56
55
|
{:else if avatar}
|
|
57
56
|
<Avatar
|
|
58
57
|
{...avatar}
|
|
59
|
-
size={avatar.size ??
|
|
58
|
+
size={avatar.size ?? (config.avatarSize as AvatarSize)}
|
|
60
59
|
class={classes.avatar}
|
|
61
60
|
/>
|
|
62
61
|
{:else if icon}
|
|
@@ -93,7 +93,6 @@ export declare const separatorVariants: import("tailwind-variants").TVReturnType
|
|
|
93
93
|
container: string;
|
|
94
94
|
icon: string;
|
|
95
95
|
avatar: string;
|
|
96
|
-
avatarSize: string;
|
|
97
96
|
label: string;
|
|
98
97
|
}, undefined, {
|
|
99
98
|
color: {
|
|
@@ -189,7 +188,6 @@ export declare const separatorVariants: import("tailwind-variants").TVReturnType
|
|
|
189
188
|
container: string;
|
|
190
189
|
icon: string;
|
|
191
190
|
avatar: string;
|
|
192
|
-
avatarSize: string;
|
|
193
191
|
label: string;
|
|
194
192
|
}, import("tailwind-variants").TVReturnType<{
|
|
195
193
|
color: {
|
|
@@ -285,7 +283,6 @@ export declare const separatorVariants: import("tailwind-variants").TVReturnType
|
|
|
285
283
|
container: string;
|
|
286
284
|
icon: string;
|
|
287
285
|
avatar: string;
|
|
288
|
-
avatarSize: string;
|
|
289
286
|
label: string;
|
|
290
287
|
}, undefined, unknown, unknown, undefined>>;
|
|
291
288
|
export type SeparatorVariantProps = VariantProps<typeof separatorVariants>;
|
|
@@ -385,7 +382,6 @@ export declare const separatorDefaults: {
|
|
|
385
382
|
container: string;
|
|
386
383
|
icon: string;
|
|
387
384
|
avatar: string;
|
|
388
|
-
avatarSize: string;
|
|
389
385
|
label: string;
|
|
390
386
|
}, {
|
|
391
387
|
color: {
|
|
@@ -481,8 +477,8 @@ export declare const separatorDefaults: {
|
|
|
481
477
|
container: string;
|
|
482
478
|
icon: string;
|
|
483
479
|
avatar: string;
|
|
484
|
-
avatarSize: string;
|
|
485
480
|
label: string;
|
|
486
481
|
}>;
|
|
487
482
|
slots: Partial<Record<SeparatorSlots, string>>;
|
|
483
|
+
avatarSize: string;
|
|
488
484
|
};
|
|
@@ -6,7 +6,6 @@ export const separatorVariants = tv({
|
|
|
6
6
|
container: 'font-medium flex',
|
|
7
7
|
icon: 'shrink-0',
|
|
8
8
|
avatar: 'shrink-0',
|
|
9
|
-
avatarSize: '2xs',
|
|
10
9
|
label: ''
|
|
11
10
|
},
|
|
12
11
|
variants: {
|
|
@@ -100,5 +99,6 @@ export const separatorVariants = tv({
|
|
|
100
99
|
});
|
|
101
100
|
export const separatorDefaults = {
|
|
102
101
|
defaultVariants: separatorVariants.defaultVariants,
|
|
103
|
-
slots: {}
|
|
102
|
+
slots: {},
|
|
103
|
+
avatarSize: '2xs'
|
|
104
104
|
};
|
|
@@ -10,7 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
const config = getComponentConfig('skeleton', skeletonDefaults)
|
|
12
12
|
|
|
13
|
-
let {
|
|
13
|
+
let {
|
|
14
|
+
ref = $bindable(null),
|
|
15
|
+
as = 'div',
|
|
16
|
+
ui,
|
|
17
|
+
class: className,
|
|
18
|
+
children,
|
|
19
|
+
...restProps
|
|
20
|
+
}: Props = $props()
|
|
14
21
|
|
|
15
22
|
const classes = $derived.by(() => {
|
|
16
23
|
const slots = skeletonVariants()
|
|
@@ -20,6 +27,15 @@
|
|
|
20
27
|
})
|
|
21
28
|
</script>
|
|
22
29
|
|
|
23
|
-
<svelte:element
|
|
30
|
+
<svelte:element
|
|
31
|
+
this={as}
|
|
32
|
+
bind:this={ref}
|
|
33
|
+
class={classes.root}
|
|
34
|
+
role="alert"
|
|
35
|
+
aria-busy="true"
|
|
36
|
+
aria-label="loading"
|
|
37
|
+
aria-live="polite"
|
|
38
|
+
{...restProps}
|
|
39
|
+
>
|
|
24
40
|
{@render children?.()}
|
|
25
41
|
</svelte:element>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SkeletonProps } from './skeleton.types.js';
|
|
2
2
|
export type Props = SkeletonProps;
|
|
3
|
-
declare const Skeleton: import("svelte").Component<SkeletonProps, {}, "">;
|
|
3
|
+
declare const Skeleton: import("svelte").Component<SkeletonProps, {}, "ref">;
|
|
4
4
|
type Skeleton = ReturnType<typeof Skeleton>;
|
|
5
5
|
export default Skeleton;
|
|
@@ -1,18 +1,27 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
1
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
3
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
4
|
import type { SkeletonSlots } from './skeleton.variants.js';
|
|
4
5
|
export type SkeletonProps = Omit<HTMLAttributes<HTMLElement>, 'class'> & {
|
|
6
|
+
/**
|
|
7
|
+
* Bindable reference to the root DOM element.
|
|
8
|
+
*/
|
|
9
|
+
ref?: HTMLElement | null;
|
|
5
10
|
/**
|
|
6
11
|
* Renders the skeleton as a different HTML element.
|
|
7
12
|
* @default 'div'
|
|
8
13
|
*/
|
|
9
14
|
as?: keyof HTMLElementTagNameMap;
|
|
10
15
|
/**
|
|
11
|
-
* Override styles for specific skeleton slots
|
|
16
|
+
* Override styles for specific skeleton slots.
|
|
12
17
|
*/
|
|
13
18
|
ui?: Partial<Record<SkeletonSlots, ClassNameValue>>;
|
|
14
19
|
/**
|
|
15
20
|
* Additional CSS classes for the root element.
|
|
16
21
|
*/
|
|
17
22
|
class?: ClassNameValue;
|
|
23
|
+
/**
|
|
24
|
+
* Default slot content.
|
|
25
|
+
*/
|
|
26
|
+
children?: Snippet;
|
|
18
27
|
};
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
header: headerSlot,
|
|
41
41
|
titleSlot,
|
|
42
42
|
descriptionSlot,
|
|
43
|
+
actions: actionsSlot,
|
|
43
44
|
body: bodySlot,
|
|
44
45
|
footer: footerSlot,
|
|
45
46
|
closeSlot
|
|
@@ -51,7 +52,9 @@
|
|
|
51
52
|
const hasTitle = $derived(!!title || !!titleSlot)
|
|
52
53
|
const hasDescription = $derived(!!description || !!descriptionSlot)
|
|
53
54
|
const hasHeading = $derived(hasTitle || hasDescription)
|
|
54
|
-
const hasHeader = $derived(
|
|
55
|
+
const hasHeader = $derived(
|
|
56
|
+
!!headerSlot || hasHeading || !!actionsSlot || showClose || !!closeSlot
|
|
57
|
+
)
|
|
55
58
|
|
|
56
59
|
const variantSlots = $derived(
|
|
57
60
|
slideoverVariants({ transition, side, inset, overlay: showOverlay })
|
|
@@ -66,6 +69,7 @@
|
|
|
66
69
|
description: variantSlots.description({
|
|
67
70
|
class: [config.slots.description, ui?.description]
|
|
68
71
|
}),
|
|
72
|
+
actions: variantSlots.actions({ class: [config.slots.actions, ui?.actions] }),
|
|
69
73
|
body: variantSlots.body({ class: [config.slots.body, ui?.body] }),
|
|
70
74
|
footer: variantSlots.footer({ class: [config.slots.footer, ui?.footer] }),
|
|
71
75
|
close: variantSlots.close({ class: [config.slots.close, ui?.close] })
|
|
@@ -132,6 +136,10 @@
|
|
|
132
136
|
{/if}
|
|
133
137
|
</div>
|
|
134
138
|
|
|
139
|
+
{#if actionsSlot}
|
|
140
|
+
<div class={classes.actions}>{@render actionsSlot()}</div>
|
|
141
|
+
{/if}
|
|
142
|
+
|
|
135
143
|
{#if showClose || closeSlot}
|
|
136
144
|
<Dialog.Close>
|
|
137
145
|
{#snippet child({ props })}
|
|
@@ -112,6 +112,11 @@ export interface SlideoverProps extends RootProps, ContentProps {
|
|
|
112
112
|
* Custom description slot. Overrides the `description` prop when provided.
|
|
113
113
|
*/
|
|
114
114
|
descriptionSlot?: Snippet;
|
|
115
|
+
/**
|
|
116
|
+
* Actions slot rendered between the title/description wrapper
|
|
117
|
+
* and the close button inside the header.
|
|
118
|
+
*/
|
|
119
|
+
actions?: Snippet;
|
|
115
120
|
/**
|
|
116
121
|
* Body content rendered between the header and footer.
|
|
117
122
|
*/
|
|
@@ -21,7 +21,9 @@ export declare const slideoverVariants: import("tailwind-variants").TVReturnType
|
|
|
21
21
|
};
|
|
22
22
|
inset: {
|
|
23
23
|
true: {};
|
|
24
|
-
false: {
|
|
24
|
+
false: {
|
|
25
|
+
content: string;
|
|
26
|
+
};
|
|
25
27
|
};
|
|
26
28
|
overlay: {
|
|
27
29
|
true: {
|
|
@@ -37,6 +39,7 @@ export declare const slideoverVariants: import("tailwind-variants").TVReturnType
|
|
|
37
39
|
footer: string;
|
|
38
40
|
title: string;
|
|
39
41
|
description: string;
|
|
42
|
+
actions: string;
|
|
40
43
|
close: string;
|
|
41
44
|
}, undefined, {
|
|
42
45
|
transition: {
|
|
@@ -60,7 +63,9 @@ export declare const slideoverVariants: import("tailwind-variants").TVReturnType
|
|
|
60
63
|
};
|
|
61
64
|
inset: {
|
|
62
65
|
true: {};
|
|
63
|
-
false: {
|
|
66
|
+
false: {
|
|
67
|
+
content: string;
|
|
68
|
+
};
|
|
64
69
|
};
|
|
65
70
|
overlay: {
|
|
66
71
|
true: {
|
|
@@ -76,6 +81,7 @@ export declare const slideoverVariants: import("tailwind-variants").TVReturnType
|
|
|
76
81
|
footer: string;
|
|
77
82
|
title: string;
|
|
78
83
|
description: string;
|
|
84
|
+
actions: string;
|
|
79
85
|
close: string;
|
|
80
86
|
}, import("tailwind-variants").TVReturnType<{
|
|
81
87
|
transition: {
|
|
@@ -99,7 +105,9 @@ export declare const slideoverVariants: import("tailwind-variants").TVReturnType
|
|
|
99
105
|
};
|
|
100
106
|
inset: {
|
|
101
107
|
true: {};
|
|
102
|
-
false: {
|
|
108
|
+
false: {
|
|
109
|
+
content: string;
|
|
110
|
+
};
|
|
103
111
|
};
|
|
104
112
|
overlay: {
|
|
105
113
|
true: {
|
|
@@ -115,6 +123,7 @@ export declare const slideoverVariants: import("tailwind-variants").TVReturnType
|
|
|
115
123
|
footer: string;
|
|
116
124
|
title: string;
|
|
117
125
|
description: string;
|
|
126
|
+
actions: string;
|
|
118
127
|
close: string;
|
|
119
128
|
}, undefined, unknown, unknown, undefined>>;
|
|
120
129
|
export type SlideoverVariantProps = VariantProps<typeof slideoverVariants>;
|
|
@@ -142,7 +151,9 @@ export declare const slideoverDefaults: {
|
|
|
142
151
|
};
|
|
143
152
|
inset: {
|
|
144
153
|
true: {};
|
|
145
|
-
false: {
|
|
154
|
+
false: {
|
|
155
|
+
content: string;
|
|
156
|
+
};
|
|
146
157
|
};
|
|
147
158
|
overlay: {
|
|
148
159
|
true: {
|
|
@@ -158,6 +169,7 @@ export declare const slideoverDefaults: {
|
|
|
158
169
|
footer: string;
|
|
159
170
|
title: string;
|
|
160
171
|
description: string;
|
|
172
|
+
actions: string;
|
|
161
173
|
close: string;
|
|
162
174
|
}, {
|
|
163
175
|
transition: {
|
|
@@ -181,7 +193,9 @@ export declare const slideoverDefaults: {
|
|
|
181
193
|
};
|
|
182
194
|
inset: {
|
|
183
195
|
true: {};
|
|
184
|
-
false: {
|
|
196
|
+
false: {
|
|
197
|
+
content: string;
|
|
198
|
+
};
|
|
185
199
|
};
|
|
186
200
|
overlay: {
|
|
187
201
|
true: {
|
|
@@ -197,6 +211,7 @@ export declare const slideoverDefaults: {
|
|
|
197
211
|
footer: string;
|
|
198
212
|
title: string;
|
|
199
213
|
description: string;
|
|
214
|
+
actions: string;
|
|
200
215
|
close: string;
|
|
201
216
|
}>;
|
|
202
217
|
slots: Partial<Record<SlideoverSlots, string>>;
|
|
@@ -9,6 +9,7 @@ export const slideoverVariants = tv({
|
|
|
9
9
|
footer: 'flex items-center gap-1.5 p-4 sm:px-6',
|
|
10
10
|
title: 'text-on-surface font-semibold',
|
|
11
11
|
description: 'mt-1 text-on-surface-variant text-sm',
|
|
12
|
+
actions: 'flex items-center gap-1.5 shrink-0',
|
|
12
13
|
close: 'absolute top-4 end-4'
|
|
13
14
|
},
|
|
14
15
|
variants: {
|
|
@@ -33,7 +34,9 @@ export const slideoverVariants = tv({
|
|
|
33
34
|
},
|
|
34
35
|
inset: {
|
|
35
36
|
true: {},
|
|
36
|
-
false: {
|
|
37
|
+
false: {
|
|
38
|
+
content: 'shadow-lg'
|
|
39
|
+
}
|
|
37
40
|
},
|
|
38
41
|
overlay: {
|
|
39
42
|
true: {
|
|
@@ -97,34 +100,6 @@ export const slideoverVariants = tv({
|
|
|
97
100
|
class: {
|
|
98
101
|
content: 'left-4 inset-y-4 rounded-xl shadow-lg ring ring-outline-variant'
|
|
99
102
|
}
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
inset: false,
|
|
103
|
-
side: 'top',
|
|
104
|
-
class: {
|
|
105
|
-
content: 'shadow-lg'
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
inset: false,
|
|
110
|
-
side: 'right',
|
|
111
|
-
class: {
|
|
112
|
-
content: 'shadow-lg'
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
inset: false,
|
|
117
|
-
side: 'bottom',
|
|
118
|
-
class: {
|
|
119
|
-
content: 'shadow-lg'
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
inset: false,
|
|
124
|
-
side: 'left',
|
|
125
|
-
class: {
|
|
126
|
-
content: 'shadow-lg'
|
|
127
|
-
}
|
|
128
103
|
}
|
|
129
104
|
],
|
|
130
105
|
defaultVariants: {
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { SliderProps } from './slider.types.js'
|
|
3
|
+
|
|
4
|
+
export type Props = SliderProps
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { Slider, useId } from 'bits-ui'
|
|
9
|
+
import { getContext } from 'svelte'
|
|
10
|
+
import { sliderVariants, sliderDefaults } from './slider.variants.js'
|
|
11
|
+
import { getComponentConfig } from '../config.js'
|
|
12
|
+
import type { FormFieldProps } from '../FormField/form-field.types.js'
|
|
13
|
+
|
|
14
|
+
const config = getComponentConfig('slider', sliderDefaults)
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
ref = $bindable(null),
|
|
18
|
+
id,
|
|
19
|
+
value = $bindable(0),
|
|
20
|
+
onValueChange,
|
|
21
|
+
onValueCommit,
|
|
22
|
+
min = 0,
|
|
23
|
+
max = 100,
|
|
24
|
+
step = 1,
|
|
25
|
+
orientation = config.defaultVariants.orientation,
|
|
26
|
+
disabled = false,
|
|
27
|
+
autoSort = true,
|
|
28
|
+
dir,
|
|
29
|
+
thumbPositioning,
|
|
30
|
+
trackPadding,
|
|
31
|
+
color = config.defaultVariants.color,
|
|
32
|
+
size,
|
|
33
|
+
tooltip = false,
|
|
34
|
+
name,
|
|
35
|
+
class: className,
|
|
36
|
+
ui,
|
|
37
|
+
...restProps
|
|
38
|
+
}: Props = $props()
|
|
39
|
+
|
|
40
|
+
const formFieldContext = getContext<
|
|
41
|
+
| {
|
|
42
|
+
name?: string
|
|
43
|
+
size: NonNullable<FormFieldProps['size']>
|
|
44
|
+
error?: string | boolean
|
|
45
|
+
ariaId: string
|
|
46
|
+
}
|
|
47
|
+
| undefined
|
|
48
|
+
>('formField')
|
|
49
|
+
|
|
50
|
+
const autoId = useId()
|
|
51
|
+
const hasError = $derived(
|
|
52
|
+
formFieldContext?.error !== undefined && formFieldContext?.error !== false
|
|
53
|
+
)
|
|
54
|
+
const resolvedId = $derived(id ?? formFieldContext?.ariaId ?? autoId)
|
|
55
|
+
const resolvedName = $derived(name ?? formFieldContext?.name)
|
|
56
|
+
const resolvedSize = $derived(size ?? formFieldContext?.size ?? config.defaultVariants.size)
|
|
57
|
+
const resolvedColor = $derived(hasError ? 'error' : color)
|
|
58
|
+
const ariaDescribedBy = $derived(
|
|
59
|
+
!formFieldContext
|
|
60
|
+
? undefined
|
|
61
|
+
: hasError
|
|
62
|
+
? `${formFieldContext.ariaId}-error`
|
|
63
|
+
: `${formFieldContext.ariaId}-description ${formFieldContext.ariaId}-help`
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
const asArray = $derived(Array.isArray(value) ? value : [value ?? min])
|
|
67
|
+
const isMultiple = $derived(Array.isArray(value))
|
|
68
|
+
|
|
69
|
+
function handleValueChange(v: number[]) {
|
|
70
|
+
value = isMultiple ? v : (v[0] ?? min)
|
|
71
|
+
onValueChange?.(value)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function handleValueCommit(v: number[]) {
|
|
75
|
+
onValueCommit?.(isMultiple ? v : (v[0] ?? min))
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const slots = $derived(
|
|
79
|
+
sliderVariants({ color: resolvedColor, size: resolvedSize, orientation, disabled })
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
const classes = $derived.by(() => {
|
|
83
|
+
const u = ui ?? {}
|
|
84
|
+
return {
|
|
85
|
+
root: slots.root({ class: [config.slots.root, className, u.root] }),
|
|
86
|
+
base: slots.base({ class: [config.slots.base, u.base] }),
|
|
87
|
+
track: slots.track({ class: [config.slots.track, u.track] }),
|
|
88
|
+
range: slots.range({ class: [config.slots.range, u.range] }),
|
|
89
|
+
thumb: slots.thumb({ class: [config.slots.thumb, u.thumb] }),
|
|
90
|
+
tooltip: slots.tooltip({ class: [config.slots.tooltip, u.tooltip] })
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<div bind:this={ref} class={classes.root} {...restProps}>
|
|
96
|
+
{#if resolvedName}
|
|
97
|
+
{#each asArray as v, i (i)}
|
|
98
|
+
<input type="hidden" name={resolvedName} value={v} />
|
|
99
|
+
{/each}
|
|
100
|
+
{/if}
|
|
101
|
+
|
|
102
|
+
<Slider.Root
|
|
103
|
+
type="multiple"
|
|
104
|
+
id={resolvedId}
|
|
105
|
+
value={asArray}
|
|
106
|
+
{min}
|
|
107
|
+
{max}
|
|
108
|
+
{step}
|
|
109
|
+
{disabled}
|
|
110
|
+
{orientation}
|
|
111
|
+
{autoSort}
|
|
112
|
+
{dir}
|
|
113
|
+
{thumbPositioning}
|
|
114
|
+
{trackPadding}
|
|
115
|
+
aria-describedby={ariaDescribedBy}
|
|
116
|
+
onValueChange={handleValueChange}
|
|
117
|
+
onValueCommit={handleValueCommit}
|
|
118
|
+
class={classes.base}
|
|
119
|
+
>
|
|
120
|
+
{#snippet children({ thumbItems })}
|
|
121
|
+
<span data-slider-track class={classes.track}>
|
|
122
|
+
<Slider.Range class={classes.range} />
|
|
123
|
+
</span>
|
|
124
|
+
|
|
125
|
+
{#each thumbItems as item (item.index)}
|
|
126
|
+
<Slider.Thumb index={item.index} class={classes.thumb} />
|
|
127
|
+
{#if tooltip}
|
|
128
|
+
<Slider.ThumbLabel index={item.index} class={classes.tooltip}>
|
|
129
|
+
{item.value}
|
|
130
|
+
</Slider.ThumbLabel>
|
|
131
|
+
{/if}
|
|
132
|
+
{/each}
|
|
133
|
+
{/snippet}
|
|
134
|
+
</Slider.Root>
|
|
135
|
+
</div>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SliderProps } from './slider.types.js';
|
|
2
|
+
export type Props = SliderProps;
|
|
3
|
+
import { Slider } from 'bits-ui';
|
|
4
|
+
declare const Slider: import("svelte").Component<SliderProps, {}, "ref" | "value">;
|
|
5
|
+
type Slider = ReturnType<typeof Slider>;
|
|
6
|
+
export default Slider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Slider } from './Slider.svelte';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Slider as SliderPrimitive } from 'bits-ui';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
import type { SliderVariantProps, SliderSlots } from './slider.variants.js';
|
|
5
|
+
export type SliderProps = Pick<SliderPrimitive.RootProps, 'dir' | 'orientation' | 'disabled' | 'min' | 'max' | 'step' | 'autoSort' | 'thumbPositioning' | 'trackPadding'> & Omit<HTMLAttributes<HTMLElement>, 'class' | 'children' | 'dir'> & {
|
|
6
|
+
/**
|
|
7
|
+
* Bindable reference to the root DOM element.
|
|
8
|
+
*/
|
|
9
|
+
ref?: HTMLElement | null;
|
|
10
|
+
/**
|
|
11
|
+
* The HTML id attribute forwarded to the slider root element.
|
|
12
|
+
*/
|
|
13
|
+
id?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The current value. Use `number` for a single thumb, `number[]` for a range slider.
|
|
16
|
+
* Supports two-way binding with `bind:value`.
|
|
17
|
+
* @default 0
|
|
18
|
+
*/
|
|
19
|
+
value?: number | number[];
|
|
20
|
+
/**
|
|
21
|
+
* Callback fired continuously while the user drags a thumb.
|
|
22
|
+
*/
|
|
23
|
+
onValueChange?: (value: number | number[]) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Callback fired once when the user releases the thumb.
|
|
26
|
+
*/
|
|
27
|
+
onValueCommit?: (value: number | number[]) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Color scheme of the slider.
|
|
30
|
+
* @default 'primary'
|
|
31
|
+
*/
|
|
32
|
+
color?: NonNullable<SliderVariantProps['color']>;
|
|
33
|
+
/**
|
|
34
|
+
* Size of the slider track and thumbs.
|
|
35
|
+
* @default 'md'
|
|
36
|
+
*/
|
|
37
|
+
size?: NonNullable<SliderVariantProps['size']>;
|
|
38
|
+
/**
|
|
39
|
+
* Show a floating value label above each thumb.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
tooltip?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The name attribute for hidden inputs used in form submission.
|
|
45
|
+
*/
|
|
46
|
+
name?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Additional CSS classes for the root element.
|
|
49
|
+
*/
|
|
50
|
+
class?: ClassNameValue;
|
|
51
|
+
/**
|
|
52
|
+
* Override styles for specific slider slots.
|
|
53
|
+
*/
|
|
54
|
+
ui?: Partial<Record<SliderSlots, ClassNameValue>>;
|
|
55
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|