uisv 0.0.12 → 0.0.14
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 +108 -0
- package/dist/components/accordion.svelte.d.ts +58 -0
- package/dist/components/alert.svelte +271 -0
- package/dist/components/alert.svelte.d.ts +23 -0
- package/dist/components/badge.svelte +225 -0
- package/dist/components/badge.svelte.d.ts +19 -0
- package/dist/components/banner.svelte +254 -0
- package/dist/components/banner.svelte.d.ts +23 -0
- package/dist/components/button.svelte +409 -0
- package/dist/components/button.svelte.d.ts +49 -0
- package/dist/components/card.svelte +70 -0
- package/dist/components/card.svelte.d.ts +17 -0
- package/dist/components/checkbox-group.svelte +258 -0
- package/dist/components/checkbox-group.svelte.d.ts +26 -0
- package/dist/components/checkbox.svelte +175 -0
- package/dist/components/checkbox.svelte.d.ts +27 -0
- package/dist/components/chip.svelte +82 -0
- package/dist/components/chip.svelte.d.ts +17 -0
- package/dist/components/color-picker.svelte +48 -0
- package/dist/components/color-picker.svelte.d.ts +10 -0
- package/dist/components/h1.svelte +15 -0
- package/dist/components/h1.svelte.d.ts +3 -0
- package/dist/components/h2.svelte +19 -0
- package/dist/components/h2.svelte.d.ts +3 -0
- package/dist/components/h3.svelte +16 -0
- package/dist/components/h3.svelte.d.ts +3 -0
- package/dist/components/h4.svelte +19 -0
- package/dist/components/h4.svelte.d.ts +3 -0
- package/dist/components/h5.svelte +19 -0
- package/dist/components/h5.svelte.d.ts +3 -0
- package/dist/components/h6.svelte +19 -0
- package/dist/components/h6.svelte.d.ts +3 -0
- package/dist/components/index.d.ts +45 -0
- package/dist/components/index.js +45 -0
- package/dist/components/input-time.svelte +234 -0
- package/dist/components/input-time.svelte.d.ts +54 -0
- package/dist/components/input.svelte +285 -0
- package/dist/components/input.svelte.d.ts +55 -0
- package/dist/components/kbd.svelte +239 -0
- package/dist/components/kbd.svelte.d.ts +40 -0
- package/dist/components/p.svelte +9 -0
- package/dist/components/p.svelte.d.ts +3 -0
- package/dist/components/pin-input.svelte +162 -0
- package/dist/components/pin-input.svelte.d.ts +25 -0
- package/dist/components/placeholder.svelte +34 -0
- package/dist/components/placeholder.svelte.d.ts +3 -0
- package/dist/components/popover.svelte +151 -0
- package/dist/components/popover.svelte.d.ts +88 -0
- package/dist/components/progress.svelte +124 -0
- package/dist/components/progress.svelte.d.ts +21 -0
- package/dist/components/select.svelte +171 -0
- package/dist/components/select.svelte.d.ts +50 -0
- package/dist/components/slider.svelte +172 -0
- package/dist/components/slider.svelte.d.ts +44 -0
- package/dist/components/switch.svelte +180 -0
- package/dist/components/switch.svelte.d.ts +27 -0
- package/dist/components/tabs.svelte +245 -0
- package/dist/components/tabs.svelte.d.ts +34 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/utilities.svelte.d.ts +24 -0
- package/dist/utilities.svelte.js +47 -0
- package/dist/vite.d.ts +52 -0
- package/dist/vite.js +132 -0
- package/package.json +35 -38
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { type PropColor, isComponent, isSnippet } from '../index.js';
|
|
3
|
+
import type { Component, Snippet } from 'svelte';
|
|
4
|
+
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
5
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
6
|
+
import { maska } from 'maska/svelte';
|
|
7
|
+
import { type MaskInputOptions } from 'maska';
|
|
8
|
+
import { tv } from 'tailwind-variants';
|
|
9
|
+
|
|
10
|
+
export type InputProps = Omit<SvelteHTMLElements['input'], 'size'> & {
|
|
11
|
+
name?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The placeholder text when the input is empty.
|
|
14
|
+
*/
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
/**
|
|
17
|
+
* @default primary
|
|
18
|
+
*/
|
|
19
|
+
color?: PropColor;
|
|
20
|
+
/**
|
|
21
|
+
* @default outline
|
|
22
|
+
*/
|
|
23
|
+
variant?: 'outline' | 'soft' | 'subtle' | 'ghost' | 'none';
|
|
24
|
+
/**
|
|
25
|
+
* @default md
|
|
26
|
+
*/
|
|
27
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
28
|
+
/**
|
|
29
|
+
* @default off
|
|
30
|
+
*/
|
|
31
|
+
autocomplete?: 'on' | 'off';
|
|
32
|
+
/**
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
autofocus?: boolean | number;
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Highlight the ring color like a focus state.
|
|
39
|
+
*/
|
|
40
|
+
highlight?: boolean;
|
|
41
|
+
value?: string;
|
|
42
|
+
icon?: string | Snippet | Component;
|
|
43
|
+
iconposition?: 'leading' | 'trailing';
|
|
44
|
+
leading?: string | Snippet | Component;
|
|
45
|
+
trailing?: string | Snippet | Component;
|
|
46
|
+
loading?: boolean;
|
|
47
|
+
loadingicon?: string | Snippet | Component;
|
|
48
|
+
mask?: string | MaskInputOptions;
|
|
49
|
+
ui?: {
|
|
50
|
+
root?: ClassNameValue;
|
|
51
|
+
base?: ClassNameValue;
|
|
52
|
+
leading?: ClassNameValue;
|
|
53
|
+
icon?: ClassNameValue;
|
|
54
|
+
trailing?: ClassNameValue;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<script lang="ts">
|
|
60
|
+
let {
|
|
61
|
+
type,
|
|
62
|
+
value = $bindable(),
|
|
63
|
+
color = 'primary',
|
|
64
|
+
variant = 'outline',
|
|
65
|
+
size = 'md',
|
|
66
|
+
icon,
|
|
67
|
+
iconposition,
|
|
68
|
+
disabled,
|
|
69
|
+
highlight,
|
|
70
|
+
leading,
|
|
71
|
+
loading,
|
|
72
|
+
loadingicon = 'i-lucide-loader-circle',
|
|
73
|
+
required,
|
|
74
|
+
trailing,
|
|
75
|
+
mask,
|
|
76
|
+
ui = {},
|
|
77
|
+
...rest
|
|
78
|
+
}: InputProps = $props();
|
|
79
|
+
const id = $props.id();
|
|
80
|
+
|
|
81
|
+
const variants = $derived(
|
|
82
|
+
tv({
|
|
83
|
+
slots: {
|
|
84
|
+
root: 'inline-flex items-center rounded transition-all ring ring-inset ring-transparent',
|
|
85
|
+
base: 'appearance-none outline-none placeholder:text-muted',
|
|
86
|
+
leading: 'text-muted',
|
|
87
|
+
trailing: 'text-muted',
|
|
88
|
+
icon: '',
|
|
89
|
+
},
|
|
90
|
+
variants: {
|
|
91
|
+
fieldGroup: {
|
|
92
|
+
horizontal: {
|
|
93
|
+
root: '',
|
|
94
|
+
base: '',
|
|
95
|
+
},
|
|
96
|
+
vertical: {
|
|
97
|
+
root: '',
|
|
98
|
+
base: '',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
size: {
|
|
102
|
+
xs: {
|
|
103
|
+
base: 'px-2 py-1 text-xs gap-1',
|
|
104
|
+
leading: 'ps-2',
|
|
105
|
+
trailing: 'pe-2',
|
|
106
|
+
icon: 'size-4',
|
|
107
|
+
},
|
|
108
|
+
sm: {
|
|
109
|
+
base: 'px-2.5 py-1.5 text-xs gap-1.5',
|
|
110
|
+
leading: 'ps-2.5',
|
|
111
|
+
trailing: 'pe-2.5',
|
|
112
|
+
icon: 'size-4',
|
|
113
|
+
},
|
|
114
|
+
md: {
|
|
115
|
+
base: 'px-2.5 py-1.5 text-sm gap-1.5',
|
|
116
|
+
leading: 'ps-2.5',
|
|
117
|
+
trailing: 'pe-2.5',
|
|
118
|
+
icon: 'size-5',
|
|
119
|
+
},
|
|
120
|
+
lg: {
|
|
121
|
+
base: 'px-3 py-2 text-sm gap-2',
|
|
122
|
+
leading: 'ps-3',
|
|
123
|
+
trailing: 'pe-3',
|
|
124
|
+
icon: 'size-5',
|
|
125
|
+
},
|
|
126
|
+
xl: {
|
|
127
|
+
base: 'px-3 py-2 text-base gap-2',
|
|
128
|
+
leading: 'ps-3',
|
|
129
|
+
trailing: 'pe-3',
|
|
130
|
+
icon: 'size-6',
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
variant: {
|
|
134
|
+
outline: { root: 'ring ring-dimmed' },
|
|
135
|
+
soft: {
|
|
136
|
+
root: 'bg-surface-muted hover:bg-surface-elevated focus-within:bg-surface-elevated',
|
|
137
|
+
},
|
|
138
|
+
subtle: { root: 'ring ring-dimmed' },
|
|
139
|
+
ghost: { root: 'hover:bg-surface-elevated focus-within:bg-surface-elevated' },
|
|
140
|
+
none: { root: '' },
|
|
141
|
+
},
|
|
142
|
+
color: {
|
|
143
|
+
primary: { root: '' },
|
|
144
|
+
surface: { root: '' },
|
|
145
|
+
info: { root: '' },
|
|
146
|
+
success: { root: '' },
|
|
147
|
+
warning: { root: '' },
|
|
148
|
+
error: { root: '' },
|
|
149
|
+
},
|
|
150
|
+
leading: {
|
|
151
|
+
false: { leading: 'hidden' },
|
|
152
|
+
},
|
|
153
|
+
trailing: {
|
|
154
|
+
false: { trailing: 'hidden' },
|
|
155
|
+
},
|
|
156
|
+
loading: {
|
|
157
|
+
true: '',
|
|
158
|
+
},
|
|
159
|
+
highlight: {
|
|
160
|
+
true: '',
|
|
161
|
+
},
|
|
162
|
+
type: {
|
|
163
|
+
file: 'file:me-1.5 file:font-medium file:text-muted file:outline-none',
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
compoundVariants: [
|
|
167
|
+
{
|
|
168
|
+
color: 'primary',
|
|
169
|
+
variant: ['outline', 'subtle'],
|
|
170
|
+
class: {
|
|
171
|
+
root: 'focus-within:(ring-primary-500 ring-2)',
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
color: 'surface',
|
|
176
|
+
variant: ['outline', 'subtle'],
|
|
177
|
+
class: {
|
|
178
|
+
root: 'focus-within:(ring-surface-800 ring-2)',
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
color: 'info',
|
|
183
|
+
variant: ['outline', 'subtle'],
|
|
184
|
+
class: {
|
|
185
|
+
root: 'focus-within:(ring-info-500 ring-2)',
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
color: 'success',
|
|
190
|
+
variant: ['outline', 'subtle'],
|
|
191
|
+
class: {
|
|
192
|
+
root: 'focus-within:(ring-success-500 ring-2)',
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
color: 'warning',
|
|
197
|
+
variant: ['outline', 'subtle'],
|
|
198
|
+
class: {
|
|
199
|
+
root: 'focus-within:(ring-warning-500 ring-2)',
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
color: 'error',
|
|
204
|
+
variant: ['outline', 'subtle'],
|
|
205
|
+
class: {
|
|
206
|
+
root: 'focus-within:(ring-error-500 ring-2)',
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
})({
|
|
211
|
+
size,
|
|
212
|
+
color,
|
|
213
|
+
variant,
|
|
214
|
+
highlight,
|
|
215
|
+
loading,
|
|
216
|
+
leading: !!leading || (!!icon && iconposition === 'leading') || loading,
|
|
217
|
+
trailing: !!trailing || (!!icon && iconposition === 'trailing'),
|
|
218
|
+
type: type === 'file' ? 'file' : undefined,
|
|
219
|
+
}),
|
|
220
|
+
);
|
|
221
|
+
</script>
|
|
222
|
+
|
|
223
|
+
<div class={variants.root({ class: ui.root })}>
|
|
224
|
+
{#if leading || (icon && iconposition === 'leading') || loading}
|
|
225
|
+
{@const TrailingIcon = loading ? loadingicon : icon}
|
|
226
|
+
|
|
227
|
+
<span class={variants.leading({ class: ui.leading })}>
|
|
228
|
+
{#if !!leading && !loading}
|
|
229
|
+
{#if typeof leading === 'string'}
|
|
230
|
+
{leading}
|
|
231
|
+
{:else if isSnippet(leading)}
|
|
232
|
+
{@render leading()}
|
|
233
|
+
{:else if isComponent(leading)}
|
|
234
|
+
{@const Leading = leading}
|
|
235
|
+
<Leading />
|
|
236
|
+
{/if}
|
|
237
|
+
{:else if typeof TrailingIcon === 'string'}
|
|
238
|
+
<div
|
|
239
|
+
class={variants.icon({
|
|
240
|
+
class: [loading && 'animate-spin', TrailingIcon, ui.icon],
|
|
241
|
+
})}
|
|
242
|
+
></div>
|
|
243
|
+
{:else if isSnippet(TrailingIcon)}
|
|
244
|
+
{@render TrailingIcon()}
|
|
245
|
+
{:else if isComponent(TrailingIcon)}
|
|
246
|
+
<TrailingIcon class={variants.icon({ class: [ui.icon] })} />
|
|
247
|
+
{/if}
|
|
248
|
+
</span>
|
|
249
|
+
{/if}
|
|
250
|
+
|
|
251
|
+
<input
|
|
252
|
+
{id}
|
|
253
|
+
{type}
|
|
254
|
+
{...rest}
|
|
255
|
+
class={variants.base({ class: [ui.base] })}
|
|
256
|
+
{...rest}
|
|
257
|
+
use:maska={mask}
|
|
258
|
+
/>
|
|
259
|
+
|
|
260
|
+
{#if trailing || (icon && iconposition === 'trailing')}
|
|
261
|
+
<span class={variants.trailing({ class: ui.trailing })}>
|
|
262
|
+
{#if !!trailing}
|
|
263
|
+
{#if typeof trailing === 'string'}
|
|
264
|
+
{trailing}
|
|
265
|
+
{:else if isSnippet(trailing)}
|
|
266
|
+
{@render trailing()}
|
|
267
|
+
{:else if isComponent(trailing)}
|
|
268
|
+
{@const Trailing = trailing}
|
|
269
|
+
<Trailing />
|
|
270
|
+
{/if}
|
|
271
|
+
{:else if typeof icon === 'string'}
|
|
272
|
+
<div
|
|
273
|
+
class={variants.icon({
|
|
274
|
+
class: [icon, ui.icon],
|
|
275
|
+
})}
|
|
276
|
+
></div>
|
|
277
|
+
{:else if isSnippet(icon)}
|
|
278
|
+
{@render icon()}
|
|
279
|
+
{:else if isComponent(icon)}
|
|
280
|
+
{@const Icon = icon}
|
|
281
|
+
<Icon class={variants.icon({ class: [ui.icon] })} />
|
|
282
|
+
{/if}
|
|
283
|
+
</span>
|
|
284
|
+
{/if}
|
|
285
|
+
</div>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type PropColor } from '../index.js';
|
|
2
|
+
import type { Component, Snippet } from 'svelte';
|
|
3
|
+
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
4
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
5
|
+
import { type MaskInputOptions } from 'maska';
|
|
6
|
+
export type InputProps = Omit<SvelteHTMLElements['input'], 'size'> & {
|
|
7
|
+
name?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The placeholder text when the input is empty.
|
|
10
|
+
*/
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @default primary
|
|
14
|
+
*/
|
|
15
|
+
color?: PropColor;
|
|
16
|
+
/**
|
|
17
|
+
* @default outline
|
|
18
|
+
*/
|
|
19
|
+
variant?: 'outline' | 'soft' | 'subtle' | 'ghost' | 'none';
|
|
20
|
+
/**
|
|
21
|
+
* @default md
|
|
22
|
+
*/
|
|
23
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
24
|
+
/**
|
|
25
|
+
* @default off
|
|
26
|
+
*/
|
|
27
|
+
autocomplete?: 'on' | 'off';
|
|
28
|
+
/**
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
autofocus?: boolean | number;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Highlight the ring color like a focus state.
|
|
35
|
+
*/
|
|
36
|
+
highlight?: boolean;
|
|
37
|
+
value?: string;
|
|
38
|
+
icon?: string | Snippet | Component;
|
|
39
|
+
iconposition?: 'leading' | 'trailing';
|
|
40
|
+
leading?: string | Snippet | Component;
|
|
41
|
+
trailing?: string | Snippet | Component;
|
|
42
|
+
loading?: boolean;
|
|
43
|
+
loadingicon?: string | Snippet | Component;
|
|
44
|
+
mask?: string | MaskInputOptions;
|
|
45
|
+
ui?: {
|
|
46
|
+
root?: ClassNameValue;
|
|
47
|
+
base?: ClassNameValue;
|
|
48
|
+
leading?: ClassNameValue;
|
|
49
|
+
icon?: ClassNameValue;
|
|
50
|
+
trailing?: ClassNameValue;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
declare const Input: Component<InputProps, {}, "value">;
|
|
54
|
+
type Input = ReturnType<typeof Input>;
|
|
55
|
+
export default Input;
|
|
@@ -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>
|