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
|
@@ -10,17 +10,29 @@ export declare const kbdVariants: import("tailwind-variants").TVReturnType<{
|
|
|
10
10
|
surface: string;
|
|
11
11
|
};
|
|
12
12
|
size: {
|
|
13
|
-
sm:
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
sm: {
|
|
14
|
+
base: string;
|
|
15
|
+
};
|
|
16
|
+
md: {
|
|
17
|
+
base: string;
|
|
18
|
+
};
|
|
19
|
+
lg: {
|
|
20
|
+
base: string;
|
|
21
|
+
};
|
|
16
22
|
};
|
|
17
23
|
variant: {
|
|
18
24
|
solid: string;
|
|
19
|
-
outline:
|
|
25
|
+
outline: {
|
|
26
|
+
base: string;
|
|
27
|
+
};
|
|
20
28
|
soft: string;
|
|
21
|
-
subtle:
|
|
29
|
+
subtle: {
|
|
30
|
+
base: string;
|
|
31
|
+
};
|
|
22
32
|
};
|
|
23
|
-
},
|
|
33
|
+
}, {
|
|
34
|
+
base: string;
|
|
35
|
+
}, undefined, {
|
|
24
36
|
color: {
|
|
25
37
|
primary: string;
|
|
26
38
|
secondary: string;
|
|
@@ -31,17 +43,29 @@ export declare const kbdVariants: import("tailwind-variants").TVReturnType<{
|
|
|
31
43
|
surface: string;
|
|
32
44
|
};
|
|
33
45
|
size: {
|
|
34
|
-
sm:
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
sm: {
|
|
47
|
+
base: string;
|
|
48
|
+
};
|
|
49
|
+
md: {
|
|
50
|
+
base: string;
|
|
51
|
+
};
|
|
52
|
+
lg: {
|
|
53
|
+
base: string;
|
|
54
|
+
};
|
|
37
55
|
};
|
|
38
56
|
variant: {
|
|
39
57
|
solid: string;
|
|
40
|
-
outline:
|
|
58
|
+
outline: {
|
|
59
|
+
base: string;
|
|
60
|
+
};
|
|
41
61
|
soft: string;
|
|
42
|
-
subtle:
|
|
62
|
+
subtle: {
|
|
63
|
+
base: string;
|
|
64
|
+
};
|
|
43
65
|
};
|
|
44
|
-
},
|
|
66
|
+
}, {
|
|
67
|
+
base: string;
|
|
68
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
45
69
|
color: {
|
|
46
70
|
primary: string;
|
|
47
71
|
secondary: string;
|
|
@@ -52,17 +76,29 @@ export declare const kbdVariants: import("tailwind-variants").TVReturnType<{
|
|
|
52
76
|
surface: string;
|
|
53
77
|
};
|
|
54
78
|
size: {
|
|
55
|
-
sm:
|
|
56
|
-
|
|
57
|
-
|
|
79
|
+
sm: {
|
|
80
|
+
base: string;
|
|
81
|
+
};
|
|
82
|
+
md: {
|
|
83
|
+
base: string;
|
|
84
|
+
};
|
|
85
|
+
lg: {
|
|
86
|
+
base: string;
|
|
87
|
+
};
|
|
58
88
|
};
|
|
59
89
|
variant: {
|
|
60
90
|
solid: string;
|
|
61
|
-
outline:
|
|
91
|
+
outline: {
|
|
92
|
+
base: string;
|
|
93
|
+
};
|
|
62
94
|
soft: string;
|
|
63
|
-
subtle:
|
|
95
|
+
subtle: {
|
|
96
|
+
base: string;
|
|
97
|
+
};
|
|
64
98
|
};
|
|
65
|
-
},
|
|
99
|
+
}, {
|
|
100
|
+
base: string;
|
|
101
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
66
102
|
/** Static key symbols (same across all platforms) */
|
|
67
103
|
export declare const kbdKeysMap: Record<string, string>;
|
|
68
104
|
/** Platform-specific key mappings */
|
|
@@ -71,6 +107,7 @@ export declare const kbdKeysPlatformMap: Record<string, {
|
|
|
71
107
|
other: string;
|
|
72
108
|
}>;
|
|
73
109
|
export type KbdVariantProps = VariantProps<typeof kbdVariants>;
|
|
110
|
+
export type KbdSlots = keyof ReturnType<typeof kbdVariants>;
|
|
74
111
|
export declare const kbdDefaults: {
|
|
75
112
|
defaultVariants: import("tailwind-variants").TVDefaultVariants<{
|
|
76
113
|
color: {
|
|
@@ -83,17 +120,29 @@ export declare const kbdDefaults: {
|
|
|
83
120
|
surface: string;
|
|
84
121
|
};
|
|
85
122
|
size: {
|
|
86
|
-
sm:
|
|
87
|
-
|
|
88
|
-
|
|
123
|
+
sm: {
|
|
124
|
+
base: string;
|
|
125
|
+
};
|
|
126
|
+
md: {
|
|
127
|
+
base: string;
|
|
128
|
+
};
|
|
129
|
+
lg: {
|
|
130
|
+
base: string;
|
|
131
|
+
};
|
|
89
132
|
};
|
|
90
133
|
variant: {
|
|
91
134
|
solid: string;
|
|
92
|
-
outline:
|
|
135
|
+
outline: {
|
|
136
|
+
base: string;
|
|
137
|
+
};
|
|
93
138
|
soft: string;
|
|
94
|
-
subtle:
|
|
139
|
+
subtle: {
|
|
140
|
+
base: string;
|
|
141
|
+
};
|
|
95
142
|
};
|
|
96
|
-
},
|
|
143
|
+
}, {
|
|
144
|
+
base: string;
|
|
145
|
+
}, {
|
|
97
146
|
color: {
|
|
98
147
|
primary: string;
|
|
99
148
|
secondary: string;
|
|
@@ -104,15 +153,28 @@ export declare const kbdDefaults: {
|
|
|
104
153
|
surface: string;
|
|
105
154
|
};
|
|
106
155
|
size: {
|
|
107
|
-
sm:
|
|
108
|
-
|
|
109
|
-
|
|
156
|
+
sm: {
|
|
157
|
+
base: string;
|
|
158
|
+
};
|
|
159
|
+
md: {
|
|
160
|
+
base: string;
|
|
161
|
+
};
|
|
162
|
+
lg: {
|
|
163
|
+
base: string;
|
|
164
|
+
};
|
|
110
165
|
};
|
|
111
166
|
variant: {
|
|
112
167
|
solid: string;
|
|
113
|
-
outline:
|
|
168
|
+
outline: {
|
|
169
|
+
base: string;
|
|
170
|
+
};
|
|
114
171
|
soft: string;
|
|
115
|
-
subtle:
|
|
172
|
+
subtle: {
|
|
173
|
+
base: string;
|
|
174
|
+
};
|
|
116
175
|
};
|
|
117
|
-
},
|
|
176
|
+
}, {
|
|
177
|
+
base: string;
|
|
178
|
+
}>;
|
|
179
|
+
slots: Partial<Record<KbdSlots, string>>;
|
|
118
180
|
};
|
package/dist/Kbd/kbd.variants.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { tv } from 'tailwind-variants';
|
|
2
2
|
export const kbdVariants = tv({
|
|
3
|
-
|
|
3
|
+
slots: {
|
|
4
|
+
base: 'inline-flex items-center justify-center px-1 rounded-sm font-medium font-sans uppercase'
|
|
5
|
+
},
|
|
4
6
|
variants: {
|
|
5
7
|
color: {
|
|
6
8
|
primary: '',
|
|
@@ -12,101 +14,117 @@ export const kbdVariants = tv({
|
|
|
12
14
|
surface: ''
|
|
13
15
|
},
|
|
14
16
|
size: {
|
|
15
|
-
sm: 'h-4 min-w-4 text-[10px]',
|
|
16
|
-
md: 'h-5 min-w-5 text-[11px]',
|
|
17
|
-
lg: 'h-6 min-w-6 text-[12px]'
|
|
17
|
+
sm: { base: 'h-4 min-w-4 text-[10px]' },
|
|
18
|
+
md: { base: 'h-5 min-w-5 text-[11px]' },
|
|
19
|
+
lg: { base: 'h-6 min-w-6 text-[12px]' }
|
|
18
20
|
},
|
|
19
21
|
variant: {
|
|
20
22
|
solid: '',
|
|
21
|
-
outline: 'ring ring-inset',
|
|
23
|
+
outline: { base: 'ring ring-inset' },
|
|
22
24
|
soft: '',
|
|
23
|
-
subtle: 'ring ring-inset'
|
|
25
|
+
subtle: { base: 'ring ring-inset' }
|
|
24
26
|
}
|
|
25
27
|
},
|
|
26
28
|
compoundVariants: [
|
|
27
29
|
// Solid variants
|
|
28
|
-
{ color: 'primary', variant: 'solid', class: 'bg-primary text-on-primary' },
|
|
29
|
-
{ color: 'secondary', variant: 'solid', class: 'bg-secondary text-on-secondary' },
|
|
30
|
-
{ color: 'success', variant: 'solid', class: 'bg-success text-on-success' },
|
|
31
|
-
{ color: 'warning', variant: 'solid', class: 'bg-warning text-on-warning' },
|
|
32
|
-
{ color: 'error', variant: 'solid', class: 'bg-error text-on-error' },
|
|
33
|
-
{ color: 'info', variant: 'solid', class: 'bg-info text-on-info' },
|
|
34
|
-
{
|
|
30
|
+
{ color: 'primary', variant: 'solid', class: { base: 'bg-primary text-on-primary' } },
|
|
31
|
+
{ color: 'secondary', variant: 'solid', class: { base: 'bg-secondary text-on-secondary' } },
|
|
32
|
+
{ color: 'success', variant: 'solid', class: { base: 'bg-success text-on-success' } },
|
|
33
|
+
{ color: 'warning', variant: 'solid', class: { base: 'bg-warning text-on-warning' } },
|
|
34
|
+
{ color: 'error', variant: 'solid', class: { base: 'bg-error text-on-error' } },
|
|
35
|
+
{ color: 'info', variant: 'solid', class: { base: 'bg-info text-on-info' } },
|
|
36
|
+
{
|
|
37
|
+
color: 'surface',
|
|
38
|
+
variant: 'solid',
|
|
39
|
+
class: { base: 'bg-inverse-surface text-inverse-on-surface' }
|
|
40
|
+
},
|
|
35
41
|
// Outline variants
|
|
36
|
-
{ color: 'primary', variant: 'outline', class: 'ring-primary/50 text-primary' },
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
{ color: 'primary', variant: 'outline', class: { base: 'ring-primary/50 text-primary' } },
|
|
43
|
+
{
|
|
44
|
+
color: 'secondary',
|
|
45
|
+
variant: 'outline',
|
|
46
|
+
class: { base: 'ring-secondary/50 text-secondary' }
|
|
47
|
+
},
|
|
48
|
+
{ color: 'success', variant: 'outline', class: { base: 'ring-success/50 text-success' } },
|
|
49
|
+
{ color: 'warning', variant: 'outline', class: { base: 'ring-warning/50 text-warning' } },
|
|
50
|
+
{ color: 'error', variant: 'outline', class: { base: 'ring-error/50 text-error' } },
|
|
51
|
+
{ color: 'info', variant: 'outline', class: { base: 'ring-info/50 text-info' } },
|
|
42
52
|
{
|
|
43
53
|
color: 'surface',
|
|
44
54
|
variant: 'outline',
|
|
45
|
-
class: 'ring-outline-variant text-on-surface-variant'
|
|
55
|
+
class: { base: 'ring-outline-variant text-on-surface-variant' }
|
|
46
56
|
},
|
|
47
57
|
// Soft variants
|
|
48
58
|
{
|
|
49
59
|
color: 'primary',
|
|
50
60
|
variant: 'soft',
|
|
51
|
-
class: 'bg-primary-container text-on-primary-container'
|
|
61
|
+
class: { base: 'bg-primary-container text-on-primary-container' }
|
|
52
62
|
},
|
|
53
63
|
{
|
|
54
64
|
color: 'secondary',
|
|
55
65
|
variant: 'soft',
|
|
56
|
-
class: 'bg-secondary-container text-on-secondary-container'
|
|
66
|
+
class: { base: 'bg-secondary-container text-on-secondary-container' }
|
|
57
67
|
},
|
|
58
68
|
{
|
|
59
69
|
color: 'success',
|
|
60
70
|
variant: 'soft',
|
|
61
|
-
class: 'bg-success-container text-on-success-container'
|
|
71
|
+
class: { base: 'bg-success-container text-on-success-container' }
|
|
62
72
|
},
|
|
63
73
|
{
|
|
64
74
|
color: 'warning',
|
|
65
75
|
variant: 'soft',
|
|
66
|
-
class: 'bg-warning-container text-on-warning-container'
|
|
76
|
+
class: { base: 'bg-warning-container text-on-warning-container' }
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
color: 'error',
|
|
80
|
+
variant: 'soft',
|
|
81
|
+
class: { base: 'bg-error-container text-on-error-container' }
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
color: 'info',
|
|
85
|
+
variant: 'soft',
|
|
86
|
+
class: { base: 'bg-info-container text-on-info-container' }
|
|
67
87
|
},
|
|
68
|
-
{ color: 'error', variant: 'soft', class: 'bg-error-container text-on-error-container' },
|
|
69
|
-
{ color: 'info', variant: 'soft', class: 'bg-info-container text-on-info-container' },
|
|
70
88
|
{
|
|
71
89
|
color: 'surface',
|
|
72
90
|
variant: 'soft',
|
|
73
|
-
class: 'bg-surface-container-highest text-on-surface'
|
|
91
|
+
class: { base: 'bg-surface-container-highest text-on-surface' }
|
|
74
92
|
},
|
|
75
93
|
// Subtle variants
|
|
76
94
|
{
|
|
77
95
|
color: 'primary',
|
|
78
96
|
variant: 'subtle',
|
|
79
|
-
class: 'ring-primary/25 bg-primary-container text-on-primary-container'
|
|
97
|
+
class: { base: 'ring-primary/25 bg-primary-container text-on-primary-container' }
|
|
80
98
|
},
|
|
81
99
|
{
|
|
82
100
|
color: 'secondary',
|
|
83
101
|
variant: 'subtle',
|
|
84
|
-
class: 'ring-secondary/25 bg-secondary-container text-on-secondary-container'
|
|
102
|
+
class: { base: 'ring-secondary/25 bg-secondary-container text-on-secondary-container' }
|
|
85
103
|
},
|
|
86
104
|
{
|
|
87
105
|
color: 'success',
|
|
88
106
|
variant: 'subtle',
|
|
89
|
-
class: 'ring-success/25 bg-success-container text-on-success-container'
|
|
107
|
+
class: { base: 'ring-success/25 bg-success-container text-on-success-container' }
|
|
90
108
|
},
|
|
91
109
|
{
|
|
92
110
|
color: 'warning',
|
|
93
111
|
variant: 'subtle',
|
|
94
|
-
class: 'ring-warning/25 bg-warning-container text-on-warning-container'
|
|
112
|
+
class: { base: 'ring-warning/25 bg-warning-container text-on-warning-container' }
|
|
95
113
|
},
|
|
96
114
|
{
|
|
97
115
|
color: 'error',
|
|
98
116
|
variant: 'subtle',
|
|
99
|
-
class: 'ring-error/25 bg-error-container text-on-error-container'
|
|
117
|
+
class: { base: 'ring-error/25 bg-error-container text-on-error-container' }
|
|
100
118
|
},
|
|
101
119
|
{
|
|
102
120
|
color: 'info',
|
|
103
121
|
variant: 'subtle',
|
|
104
|
-
class: 'ring-info/25 bg-info-container text-on-info-container'
|
|
122
|
+
class: { base: 'ring-info/25 bg-info-container text-on-info-container' }
|
|
105
123
|
},
|
|
106
124
|
{
|
|
107
125
|
color: 'surface',
|
|
108
126
|
variant: 'subtle',
|
|
109
|
-
class: 'ring-outline-variant bg-surface-container-highest text-on-surface'
|
|
127
|
+
class: { base: 'ring-outline-variant bg-surface-container-highest text-on-surface' }
|
|
110
128
|
}
|
|
111
129
|
],
|
|
112
130
|
defaultVariants: {
|
|
@@ -121,6 +139,7 @@ export const kbdKeysMap = {
|
|
|
121
139
|
shift: '⇧',
|
|
122
140
|
control: '⌃',
|
|
123
141
|
option: '⌥',
|
|
142
|
+
win: '⊞',
|
|
124
143
|
enter: '↵',
|
|
125
144
|
delete: '⌦',
|
|
126
145
|
backspace: '⌫',
|
|
@@ -144,5 +163,6 @@ export const kbdKeysPlatformMap = {
|
|
|
144
163
|
alt: { mac: '⌥', other: 'Alt' }
|
|
145
164
|
};
|
|
146
165
|
export const kbdDefaults = {
|
|
147
|
-
defaultVariants: kbdVariants.defaultVariants
|
|
166
|
+
defaultVariants: kbdVariants.defaultVariants,
|
|
167
|
+
slots: {}
|
|
148
168
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { kbdKeysMap, kbdKeysPlatformMap } from './kbd.variants.js';
|
|
2
2
|
import type { UseKbdOptions, UseKbdReturn } from './kbd.types.js';
|
|
3
|
+
export declare function isMac(): boolean;
|
|
3
4
|
/** @internal */
|
|
4
5
|
export declare const __resetPlatformCache: () => void;
|
|
5
|
-
export declare
|
|
6
|
-
export declare function resolveKey(value: string | undefined): string | null;
|
|
6
|
+
export declare function resolveKey(value: string | undefined, platformReady?: boolean): string | null;
|
|
7
7
|
export declare function resolveShortcut(shortcut: string | undefined): string[];
|
|
8
8
|
export declare function formatShortcut(shortcut: string | undefined, separator?: string): string;
|
|
9
9
|
export declare function normalizeKey(eventKey: string): string;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { SvelteSet } from 'svelte/reactivity';
|
|
2
2
|
import { kbdKeysMap, kbdKeysPlatformMap } from './kbd.variants.js';
|
|
3
3
|
let cachedIsMac;
|
|
4
|
-
|
|
4
|
+
export function isMac() {
|
|
5
5
|
if (cachedIsMac === undefined) {
|
|
6
6
|
cachedIsMac =
|
|
7
7
|
typeof navigator !== 'undefined' &&
|
|
8
8
|
/Macintosh|Mac OS|iPhone|iPad|iPod/i.test(navigator.userAgent);
|
|
9
9
|
}
|
|
10
10
|
return cachedIsMac;
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
12
|
/** @internal */
|
|
13
13
|
export const __resetPlatformCache = () => {
|
|
14
14
|
cachedIsMac = undefined;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
17
|
-
export function resolveKey(value) {
|
|
16
|
+
export function resolveKey(value, platformReady = true) {
|
|
18
17
|
if (!value)
|
|
19
18
|
return null;
|
|
20
19
|
const key = value.toLowerCase();
|
|
21
20
|
if (key in kbdKeysPlatformMap) {
|
|
22
|
-
|
|
21
|
+
if (!platformReady)
|
|
22
|
+
return null;
|
|
23
|
+
return isMac() ? kbdKeysPlatformMap[key].mac : kbdKeysPlatformMap[key].other;
|
|
23
24
|
}
|
|
24
25
|
return kbdKeysMap[key] ?? value;
|
|
25
26
|
}
|
|
@@ -42,7 +43,7 @@ export function normalizeKey(eventKey) {
|
|
|
42
43
|
const lower = eventKey.toLowerCase();
|
|
43
44
|
return KEY_NORMALIZE[lower] ?? lower;
|
|
44
45
|
}
|
|
45
|
-
const CAPTURABLE_MODIFIERS =
|
|
46
|
+
const CAPTURABLE_MODIFIERS = new Set(['alt', 'meta']);
|
|
46
47
|
const MODIFIER_PROPS = [
|
|
47
48
|
['ctrl', 'ctrlKey'],
|
|
48
49
|
['shift', 'shiftKey'],
|
|
@@ -142,6 +143,7 @@ function parseShortcuts(shortcuts) {
|
|
|
142
143
|
}
|
|
143
144
|
export function useKbd(options = {}) {
|
|
144
145
|
const _pressedKeys = new SvelteSet();
|
|
146
|
+
const { captureModifiers = false, repeat: allowRepeat = false, preventDefault: shouldPrevent = true } = options;
|
|
145
147
|
let _shortcutsRef;
|
|
146
148
|
let _parsedShortcuts = [];
|
|
147
149
|
if (typeof options.shortcuts !== 'function' && options.shortcuts) {
|
|
@@ -165,7 +167,6 @@ export function useKbd(options = {}) {
|
|
|
165
167
|
const t = typeof options.target === 'function' ? options.target() : options.target;
|
|
166
168
|
return t ?? (typeof window !== 'undefined' ? window : null);
|
|
167
169
|
}
|
|
168
|
-
/** Sync modifier state from event booleans to fix missed keyup (e.g. Alt+Tab) */
|
|
169
170
|
function reconcileModifiers(event) {
|
|
170
171
|
for (const [key, prop] of MODIFIER_PROPS) {
|
|
171
172
|
if (event[prop])
|
|
@@ -180,17 +181,15 @@ export function useKbd(options = {}) {
|
|
|
180
181
|
reconcileModifiers(event);
|
|
181
182
|
const key = normalizeKey(event.key);
|
|
182
183
|
_pressedKeys.add(key);
|
|
183
|
-
if (
|
|
184
|
+
if (captureModifiers && CAPTURABLE_MODIFIERS.has(key)) {
|
|
184
185
|
event.preventDefault();
|
|
185
186
|
}
|
|
186
|
-
if (event.repeat && !
|
|
187
|
+
if (event.repeat && !allowRepeat)
|
|
187
188
|
return;
|
|
188
|
-
const
|
|
189
|
-
for (const binding of bindings) {
|
|
189
|
+
for (const binding of getParsedShortcuts()) {
|
|
190
190
|
if (matchesShortcut(event, binding)) {
|
|
191
|
-
if (
|
|
191
|
+
if (shouldPrevent)
|
|
192
192
|
event.preventDefault();
|
|
193
|
-
}
|
|
194
193
|
binding.callback(event);
|
|
195
194
|
}
|
|
196
195
|
}
|
|
@@ -199,12 +198,21 @@ export function useKbd(options = {}) {
|
|
|
199
198
|
if (!getEnabled())
|
|
200
199
|
return;
|
|
201
200
|
reconcileModifiers(event);
|
|
202
|
-
|
|
203
|
-
_pressedKeys.delete(key);
|
|
201
|
+
_pressedKeys.delete(normalizeKey(event.key));
|
|
204
202
|
}
|
|
205
203
|
function handleClear() {
|
|
206
204
|
_pressedKeys.clear();
|
|
207
205
|
}
|
|
206
|
+
const callbacks = {
|
|
207
|
+
keydown: handleKeyDown,
|
|
208
|
+
keyup: handleKeyUp,
|
|
209
|
+
clear: handleClear
|
|
210
|
+
};
|
|
211
|
+
const clearOnlyCallbacks = {
|
|
212
|
+
keydown: () => { },
|
|
213
|
+
keyup: () => { },
|
|
214
|
+
clear: handleClear
|
|
215
|
+
};
|
|
208
216
|
$effect(() => {
|
|
209
217
|
if (!getEnabled()) {
|
|
210
218
|
_pressedKeys.clear();
|
|
@@ -213,40 +221,25 @@ export function useKbd(options = {}) {
|
|
|
213
221
|
const target = getTarget();
|
|
214
222
|
if (!target)
|
|
215
223
|
return;
|
|
216
|
-
|
|
217
|
-
const callbacks = {
|
|
218
|
-
keydown: handleKeyDown,
|
|
219
|
-
keyup: handleKeyUp,
|
|
220
|
-
clear: handleClear
|
|
221
|
-
};
|
|
222
|
-
if (isWindowTarget) {
|
|
224
|
+
if (typeof window !== 'undefined' && target === window) {
|
|
223
225
|
kbdRegistry.register(callbacks);
|
|
224
226
|
return () => {
|
|
225
227
|
kbdRegistry.unregister(callbacks);
|
|
226
228
|
_pressedKeys.clear();
|
|
227
229
|
};
|
|
228
230
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return () => {
|
|
239
|
-
target.removeEventListener('keydown', handleKeyDown);
|
|
240
|
-
target.removeEventListener('keyup', handleKeyUp);
|
|
241
|
-
kbdRegistry.unregister(clearOnly);
|
|
242
|
-
_pressedKeys.clear();
|
|
243
|
-
};
|
|
244
|
-
}
|
|
231
|
+
target.addEventListener('keydown', handleKeyDown);
|
|
232
|
+
target.addEventListener('keyup', handleKeyUp);
|
|
233
|
+
kbdRegistry.register(clearOnlyCallbacks);
|
|
234
|
+
return () => {
|
|
235
|
+
target.removeEventListener('keydown', handleKeyDown);
|
|
236
|
+
target.removeEventListener('keyup', handleKeyUp);
|
|
237
|
+
kbdRegistry.unregister(clearOnlyCallbacks);
|
|
238
|
+
_pressedKeys.clear();
|
|
239
|
+
};
|
|
245
240
|
});
|
|
246
241
|
return {
|
|
247
|
-
isPressed(key)
|
|
248
|
-
return _pressedKeys.has(normalizeKey(key));
|
|
249
|
-
},
|
|
242
|
+
isPressed: (key) => _pressedKeys.has(normalizeKey(key)),
|
|
250
243
|
get pressedKeys() {
|
|
251
244
|
return _pressedKeys;
|
|
252
245
|
}
|
package/dist/Link/Link.svelte
CHANGED
|
@@ -28,11 +28,15 @@
|
|
|
28
28
|
if (mode === false) return true
|
|
29
29
|
if (mode === 'partial') {
|
|
30
30
|
for (const [key, value] of linkQuery) {
|
|
31
|
-
if (currentQuery.
|
|
31
|
+
if (!currentQuery.getAll(key).includes(value)) return false
|
|
32
32
|
}
|
|
33
33
|
return true
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
// Exact: check size first (O(1) bail-out), then compare sorted strings
|
|
37
|
+
if (linkQuery.size !== currentQuery.size) return false
|
|
38
|
+
const sorted = (p: URLSearchParams) => new URLSearchParams([...p].sort()).toString()
|
|
39
|
+
return sorted(linkQuery) === sorted(currentQuery)
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
function isPathnameMatch(linkPath: string, currentPath: string, exactMatch: boolean): boolean {
|
|
@@ -53,8 +57,9 @@
|
|
|
53
57
|
const config = getComponentConfig('link', linkDefaults)
|
|
54
58
|
|
|
55
59
|
let {
|
|
60
|
+
ref = $bindable(null),
|
|
56
61
|
href,
|
|
57
|
-
|
|
62
|
+
type,
|
|
58
63
|
active,
|
|
59
64
|
exact = false,
|
|
60
65
|
exactQuery = false,
|
|
@@ -69,25 +74,36 @@
|
|
|
69
74
|
ui,
|
|
70
75
|
target,
|
|
71
76
|
rel,
|
|
77
|
+
onclick,
|
|
72
78
|
...restProps
|
|
73
79
|
}: Props = $props()
|
|
74
80
|
|
|
81
|
+
const isLink = $derived(!!href)
|
|
82
|
+
|
|
75
83
|
const isExternal = $derived(
|
|
76
|
-
|
|
77
|
-
(
|
|
84
|
+
isLink &&
|
|
85
|
+
(external ??
|
|
86
|
+
(href!.startsWith('http://') ||
|
|
87
|
+
href!.startsWith('https://') ||
|
|
88
|
+
href!.startsWith('//')))
|
|
78
89
|
)
|
|
79
90
|
|
|
80
|
-
const resolvedTarget = $derived(
|
|
91
|
+
const resolvedTarget = $derived(
|
|
92
|
+
isLink ? (target ?? (isExternal ? '_blank' : undefined)) : undefined
|
|
93
|
+
)
|
|
81
94
|
|
|
82
95
|
const resolvedRel = $derived(
|
|
83
|
-
|
|
96
|
+
isLink
|
|
97
|
+
? (rel ??
|
|
98
|
+
(isExternal || resolvedTarget === '_blank' ? 'noopener noreferrer' : undefined))
|
|
99
|
+
: undefined
|
|
84
100
|
)
|
|
85
101
|
|
|
86
102
|
const isActive = $derived.by(() => {
|
|
87
103
|
if (active !== undefined) return active
|
|
88
|
-
if (!page.url || isExternal) return false
|
|
104
|
+
if (!isLink || !page.url || isExternal) return false
|
|
89
105
|
|
|
90
|
-
const link = parseUrl(href
|
|
106
|
+
const link = parseUrl(href!, page.url)
|
|
91
107
|
|
|
92
108
|
if (exactHash && link.hash !== page.url.hash) return false
|
|
93
109
|
if (!isQueryMatch(link.query, page.url.searchParams, exactQuery)) return false
|
|
@@ -99,24 +115,53 @@
|
|
|
99
115
|
const stateClass = isActive ? activeClass : inactiveClass
|
|
100
116
|
if (raw) return [className, stateClass].filter(Boolean).join(' ')
|
|
101
117
|
|
|
102
|
-
const slots = linkVariants({
|
|
118
|
+
const slots = linkVariants({ active: isActive, disabled, raw })
|
|
103
119
|
return slots.base({ class: [config.slots.base, stateClass, className, ui?.base] })
|
|
104
120
|
})
|
|
105
121
|
|
|
106
122
|
const ariaCurrent = $derived(isActive && exact ? ('page' as const) : undefined)
|
|
123
|
+
|
|
124
|
+
function handleClick(e: MouseEvent) {
|
|
125
|
+
if (disabled) {
|
|
126
|
+
e.preventDefault()
|
|
127
|
+
e.stopPropagation()
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (typeof onclick === 'function') {
|
|
132
|
+
;(onclick as (e: MouseEvent) => void)(e)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
107
135
|
</script>
|
|
108
136
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
137
|
+
{#if isLink}
|
|
138
|
+
<!-- eslint-disable svelte/no-navigation-without-resolve -->
|
|
139
|
+
<a
|
|
140
|
+
bind:this={ref}
|
|
141
|
+
href={disabled ? undefined : href}
|
|
142
|
+
class={baseClass}
|
|
143
|
+
target={resolvedTarget}
|
|
144
|
+
rel={resolvedRel}
|
|
145
|
+
role={disabled ? 'link' : undefined}
|
|
146
|
+
aria-disabled={disabled ? 'true' : undefined}
|
|
147
|
+
aria-current={ariaCurrent}
|
|
148
|
+
tabindex={disabled ? -1 : undefined}
|
|
149
|
+
onclick={handleClick}
|
|
150
|
+
{...restProps}
|
|
151
|
+
>
|
|
152
|
+
<!-- eslint-enable svelte/no-navigation-without-resolve -->
|
|
153
|
+
{@render children?.()}
|
|
154
|
+
</a>
|
|
155
|
+
{:else}
|
|
156
|
+
<button
|
|
157
|
+
bind:this={ref}
|
|
158
|
+
type={type ?? 'button'}
|
|
159
|
+
class={baseClass}
|
|
160
|
+
{disabled}
|
|
161
|
+
aria-current={ariaCurrent}
|
|
162
|
+
onclick={handleClick}
|
|
163
|
+
{...restProps}
|
|
164
|
+
>
|
|
165
|
+
{@render children?.()}
|
|
166
|
+
</button>
|
|
167
|
+
{/if}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LinkProps } from './link.types.js';
|
|
2
2
|
export type Props = LinkProps;
|
|
3
|
-
declare const Link: import("svelte").Component<LinkProps, {}, "">;
|
|
3
|
+
declare const Link: import("svelte").Component<LinkProps, {}, "ref">;
|
|
4
4
|
type Link = ReturnType<typeof Link>;
|
|
5
5
|
export default Link;
|