uisv 0.0.5 → 0.0.7
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 +3 -0
- package/dist/components/accordion.svelte +108 -0
- package/dist/components/accordion.svelte.d.ts +58 -0
- package/dist/components/alert.svelte +2 -4
- package/dist/components/alert.svelte.d.ts +2 -2
- package/dist/components/badge.svelte +1 -1
- package/dist/components/badge.svelte.d.ts +1 -1
- package/dist/components/banner.svelte +2 -4
- package/dist/components/banner.svelte.d.ts +2 -2
- package/dist/components/button.svelte +20 -16
- package/dist/components/button.svelte.d.ts +6 -7
- package/dist/components/checkbox.svelte +1 -2
- package/dist/components/checkbox.svelte.d.ts +1 -1
- package/dist/components/checkboxgroup.svelte +1 -2
- package/dist/components/checkboxgroup.svelte.d.ts +1 -1
- package/dist/components/chip.svelte +1 -1
- package/dist/components/chip.svelte.d.ts +1 -1
- package/dist/components/h1.svelte +28 -0
- package/dist/components/h1.svelte.d.ts +11 -0
- package/dist/components/h2.svelte +30 -0
- package/dist/components/h2.svelte.d.ts +11 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/index.js +12 -0
- package/dist/components/kbd.svelte +239 -0
- package/dist/components/kbd.svelte.d.ts +40 -0
- package/dist/components/p.svelte +22 -0
- package/dist/components/p.svelte.d.ts +11 -0
- package/dist/components/pin-input.svelte +162 -0
- package/dist/components/pin-input.svelte.d.ts +25 -0
- package/dist/components/progress.svelte +1 -1
- package/dist/components/progress.svelte.d.ts +1 -1
- package/dist/components/slider.svelte +1 -1
- package/dist/components/slider.svelte.d.ts +1 -1
- package/dist/components/switch.svelte +2 -2
- package/dist/components/switch.svelte.d.ts +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/utils/common.d.ts +0 -1
- package/dist/utils/common.js +0 -2
- package/dist/vite.js +1 -1
- package/package.json +4 -4
- package/dist/types.d.ts +0 -7
- package/dist/types.js +0 -1
- package/dist/utils/keys.d.ts +0 -8
- package/dist/utils/keys.js +0 -8
- package/dist/utils/types.d.ts +0 -1
- package/dist/utils/types.js +0 -1
package/README.md
CHANGED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { Accordion } from 'bits-ui';
|
|
3
|
+
import type { Component, Snippet } from 'svelte';
|
|
4
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
5
|
+
import { tv } from 'tailwind-variants';
|
|
6
|
+
|
|
7
|
+
export type AccordionItem = {
|
|
8
|
+
label: string;
|
|
9
|
+
icon?: string | Snippet | Component;
|
|
10
|
+
trailingicon?: string | Snippet | Component;
|
|
11
|
+
content: string;
|
|
12
|
+
value?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type AccordionProps = {
|
|
16
|
+
value?: string | string[];
|
|
17
|
+
items: AccordionItem[];
|
|
18
|
+
collapsible?: boolean;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
type?: 'single' | 'multiple';
|
|
21
|
+
trailingicon?: string | Snippet | Component;
|
|
22
|
+
leading?: Snippet<[{ item: AccordionItem; index: number; open: boolean }]>;
|
|
23
|
+
default?: Snippet<[{ item: AccordionItem; index: number; open: boolean }]>;
|
|
24
|
+
trailing?: Snippet<[{ item: AccordionItem; index: number; open: boolean }]>;
|
|
25
|
+
content?: Snippet<[{ item: AccordionItem; index: number; open: boolean }]>;
|
|
26
|
+
body?: Snippet<[{ item: AccordionItem; index: number; open: boolean }]>;
|
|
27
|
+
ui?: {
|
|
28
|
+
root?: ClassNameValue;
|
|
29
|
+
item?: ClassNameValue;
|
|
30
|
+
header?: ClassNameValue;
|
|
31
|
+
trigger?: ClassNameValue;
|
|
32
|
+
content?: ClassNameValue;
|
|
33
|
+
body?: ClassNameValue;
|
|
34
|
+
leadingicon?: ClassNameValue;
|
|
35
|
+
trailingicon?: ClassNameValue;
|
|
36
|
+
label?: ClassNameValue;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<script lang="ts">
|
|
42
|
+
let {
|
|
43
|
+
value = $bindable(),
|
|
44
|
+
items,
|
|
45
|
+
collapsible = true,
|
|
46
|
+
disabled,
|
|
47
|
+
type = 'single',
|
|
48
|
+
trailingicon = 'i-lucide-baret-down',
|
|
49
|
+
leading,
|
|
50
|
+
default: defau,
|
|
51
|
+
trailing,
|
|
52
|
+
content,
|
|
53
|
+
body,
|
|
54
|
+
ui = {}
|
|
55
|
+
}: AccordionProps = $props();
|
|
56
|
+
const classes = $derived(
|
|
57
|
+
tv({
|
|
58
|
+
slots: {
|
|
59
|
+
root: 'w-full',
|
|
60
|
+
item: 'border-b border-default last:border-b-0',
|
|
61
|
+
header: 'flex',
|
|
62
|
+
trigger:
|
|
63
|
+
'group flex-1 flex items-center gap-1.5 font-medium text-sm py-3.5 focus-visible:outline-primary min-w-0',
|
|
64
|
+
content:
|
|
65
|
+
'data-[state=open]:animate-[accordion-down_200ms_ease-out] data-[state=closed]:animate-[accordion-up_200ms_ease-out] overflow-hidden focus:outline-none',
|
|
66
|
+
body: 'text-sm pb-3.5',
|
|
67
|
+
leadingIcon: 'shrink-0 size-5',
|
|
68
|
+
trailingIcon:
|
|
69
|
+
'shrink-0 size-5 ms-auto group-data-[state=open]:rotate-180 transition-transform duration-200',
|
|
70
|
+
label: 'text-start break-words'
|
|
71
|
+
},
|
|
72
|
+
variants: {
|
|
73
|
+
disabled: {
|
|
74
|
+
true: {
|
|
75
|
+
trigger: 'cursor-not-allowed opacity-75'
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
})({
|
|
80
|
+
disabled
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<Accordion.Root
|
|
86
|
+
class={classes.root({ class: ui.root })}
|
|
87
|
+
type="multiple"
|
|
88
|
+
bind:value={
|
|
89
|
+
() => {
|
|
90
|
+
if (!value) return;
|
|
91
|
+
if (Array.isArray(value)) return value;
|
|
92
|
+
return [value];
|
|
93
|
+
},
|
|
94
|
+
(val) => {
|
|
95
|
+
if (!val) return (value = val);
|
|
96
|
+
value = type === 'single' ? val[0] : val;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
>
|
|
100
|
+
{#each items as item, idx (idx)}
|
|
101
|
+
<Accordion.Item value="item-1">
|
|
102
|
+
<Accordion.Header>
|
|
103
|
+
<Accordion.Trigger>{item.label}</Accordion.Trigger>
|
|
104
|
+
</Accordion.Header>
|
|
105
|
+
<Accordion.Content>This is the collapsible content for this section.</Accordion.Content>
|
|
106
|
+
</Accordion.Item>
|
|
107
|
+
{/each}
|
|
108
|
+
</Accordion.Root>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Accordion } from 'bits-ui';
|
|
2
|
+
import type { Component, Snippet } from 'svelte';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
export type AccordionItem = {
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: string | Snippet | Component;
|
|
7
|
+
trailingicon?: string | Snippet | Component;
|
|
8
|
+
content: string;
|
|
9
|
+
value?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type AccordionProps = {
|
|
13
|
+
value?: string | string[];
|
|
14
|
+
items: AccordionItem[];
|
|
15
|
+
collapsible?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
type?: 'single' | 'multiple';
|
|
18
|
+
trailingicon?: string | Snippet | Component;
|
|
19
|
+
leading?: Snippet<[{
|
|
20
|
+
item: AccordionItem;
|
|
21
|
+
index: number;
|
|
22
|
+
open: boolean;
|
|
23
|
+
}]>;
|
|
24
|
+
default?: Snippet<[{
|
|
25
|
+
item: AccordionItem;
|
|
26
|
+
index: number;
|
|
27
|
+
open: boolean;
|
|
28
|
+
}]>;
|
|
29
|
+
trailing?: Snippet<[{
|
|
30
|
+
item: AccordionItem;
|
|
31
|
+
index: number;
|
|
32
|
+
open: boolean;
|
|
33
|
+
}]>;
|
|
34
|
+
content?: Snippet<[{
|
|
35
|
+
item: AccordionItem;
|
|
36
|
+
index: number;
|
|
37
|
+
open: boolean;
|
|
38
|
+
}]>;
|
|
39
|
+
body?: Snippet<[{
|
|
40
|
+
item: AccordionItem;
|
|
41
|
+
index: number;
|
|
42
|
+
open: boolean;
|
|
43
|
+
}]>;
|
|
44
|
+
ui?: {
|
|
45
|
+
root?: ClassNameValue;
|
|
46
|
+
item?: ClassNameValue;
|
|
47
|
+
header?: ClassNameValue;
|
|
48
|
+
trigger?: ClassNameValue;
|
|
49
|
+
content?: ClassNameValue;
|
|
50
|
+
body?: ClassNameValue;
|
|
51
|
+
leadingicon?: ClassNameValue;
|
|
52
|
+
trailingicon?: ClassNameValue;
|
|
53
|
+
label?: ClassNameValue;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
declare const Accordion: Component<AccordionProps, {}, "value">;
|
|
57
|
+
type Accordion = ReturnType<typeof Accordion>;
|
|
58
|
+
export default Accordion;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
import type
|
|
2
|
+
import { type PropColor, isSnippet } from '../index.js';
|
|
3
3
|
import type { Component, Snippet } from 'svelte';
|
|
4
|
-
import
|
|
4
|
+
import Button, { type ButtonProps } from './button.svelte';
|
|
5
5
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
6
6
|
import { tv } from 'tailwind-variants';
|
|
7
|
-
import { isSnippet } from '../utils/common.js';
|
|
8
7
|
import { defu } from 'defu';
|
|
9
|
-
import Button from './button.svelte';
|
|
10
8
|
|
|
11
9
|
export type AlertProps = {
|
|
12
10
|
title?: string | Snippet;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PropColor } from '../index.js';
|
|
2
2
|
import type { Component, Snippet } from 'svelte';
|
|
3
|
-
import type
|
|
3
|
+
import { type ButtonProps } from './button.svelte';
|
|
4
4
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
5
5
|
export type AlertProps = {
|
|
6
6
|
title?: string | Snippet;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<script lang="ts">
|
|
20
20
|
import { tv } from 'tailwind-variants';
|
|
21
21
|
import { isSnippet } from '../utils/common.js';
|
|
22
|
-
import type { PropColor } from '../
|
|
22
|
+
import type { PropColor } from '../index.js';
|
|
23
23
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
24
24
|
|
|
25
25
|
let {
|
|
@@ -12,7 +12,7 @@ export type BadgeProps = {
|
|
|
12
12
|
icon?: ClassNameValue;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
import type { PropColor } from '../
|
|
15
|
+
import type { PropColor } from '../index.js';
|
|
16
16
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
17
17
|
declare const Badge: Component<BadgeProps, {}, "">;
|
|
18
18
|
type Badge = ReturnType<typeof Badge>;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
import type
|
|
2
|
+
import { isSnippet, type PropColor } from '../index.js';
|
|
3
3
|
import type { Component, Snippet } from 'svelte';
|
|
4
|
-
import
|
|
4
|
+
import Button, { type ButtonProps } from './button.svelte';
|
|
5
5
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
6
6
|
import { tv } from 'tailwind-variants';
|
|
7
|
-
import { isSnippet } from '../utils/common.js';
|
|
8
7
|
import { defu } from 'defu';
|
|
9
8
|
import { useId } from 'bits-ui';
|
|
10
|
-
import Button from './button.svelte';
|
|
11
9
|
|
|
12
10
|
export type BannerProps = {
|
|
13
11
|
title: string | Snippet;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PropColor } from '../index.js';
|
|
2
2
|
import type { Component, Snippet } from 'svelte';
|
|
3
|
-
import type
|
|
3
|
+
import { type ButtonProps } from './button.svelte';
|
|
4
4
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
5
5
|
export type BannerProps = {
|
|
6
6
|
title: string | Snippet;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
|
|
2
|
+
// import { FORM_LOADING_CONTEXT_KEY } from '../utils/keys.js';
|
|
3
|
+
import { type Component, type Snippet } from 'svelte';
|
|
4
|
+
import { tv } from 'tailwind-variants';
|
|
5
|
+
import { type PropColor, isSnippet } from '../index.js';
|
|
6
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
7
|
|
|
4
8
|
export type ButtonProps = {
|
|
5
9
|
/** The underlying DOM element being rendered. You can bind to this to get a reference to the element. */
|
|
@@ -30,7 +34,7 @@
|
|
|
30
34
|
/**
|
|
31
35
|
* @defaultValue 'solid'
|
|
32
36
|
*/
|
|
33
|
-
variant?:
|
|
37
|
+
variant?: 'link' | 'solid' | 'outline' | 'soft' | 'subtle' | 'ghost';
|
|
34
38
|
// activevariant?: ButtonVariant;
|
|
35
39
|
/**
|
|
36
40
|
* @defaultValue 'md'
|
|
@@ -42,21 +46,14 @@
|
|
|
42
46
|
loadingauto?: boolean;
|
|
43
47
|
onclick?: (event: MouseEvent) => void | Promise<void>;
|
|
44
48
|
ui?: {
|
|
45
|
-
base?:
|
|
46
|
-
icon?:
|
|
49
|
+
base?: ClassNameValue;
|
|
50
|
+
icon?: ClassNameValue;
|
|
47
51
|
};
|
|
48
52
|
children?: Snippet;
|
|
49
53
|
};
|
|
50
54
|
</script>
|
|
51
55
|
|
|
52
56
|
<script lang="ts">
|
|
53
|
-
// import { FORM_LOADING_CONTEXT_KEY } from '../utils/keys.js';
|
|
54
|
-
import { type Component, type Snippet } from 'svelte';
|
|
55
|
-
import { isSnippet } from '../utils/common.js';
|
|
56
|
-
import { tv } from 'tailwind-variants';
|
|
57
|
-
import type { ClassValue } from 'svelte/elements';
|
|
58
|
-
import type { PropColor } from '../types.js';
|
|
59
|
-
|
|
60
57
|
// let form_loading = getContext<{ value: boolean } | undefined>(FORM_LOADING_CONTEXT_KEY);
|
|
61
58
|
let {
|
|
62
59
|
ref = $bindable(),
|
|
@@ -93,7 +90,7 @@
|
|
|
93
90
|
tv({
|
|
94
91
|
slots: {
|
|
95
92
|
icon: '',
|
|
96
|
-
base: 'transition flex items-center font-sans'
|
|
93
|
+
base: 'transition flex-inline items-center font-sans'
|
|
97
94
|
},
|
|
98
95
|
variants: {
|
|
99
96
|
color: {
|
|
@@ -126,7 +123,8 @@
|
|
|
126
123
|
true: 'w-full'
|
|
127
124
|
},
|
|
128
125
|
disabled: {
|
|
129
|
-
true: 'cursor-not-allowed'
|
|
126
|
+
true: 'cursor-not-allowed',
|
|
127
|
+
false: 'cursor-pointer'
|
|
130
128
|
}
|
|
131
129
|
},
|
|
132
130
|
compoundVariants: [
|
|
@@ -333,7 +331,9 @@
|
|
|
333
331
|
<a
|
|
334
332
|
{href}
|
|
335
333
|
{target}
|
|
336
|
-
class={
|
|
334
|
+
class={classes.base({
|
|
335
|
+
class: [!children && icon ? 'px-0 aspect-square justify-center' : '', ui.base]
|
|
336
|
+
})}
|
|
337
337
|
onclick={onClickWrapper}
|
|
338
338
|
>
|
|
339
339
|
{@render Content()}
|
|
@@ -342,7 +342,9 @@
|
|
|
342
342
|
<button
|
|
343
343
|
{type}
|
|
344
344
|
disabled={disabled || is_loading}
|
|
345
|
-
class={
|
|
345
|
+
class={classes.base({
|
|
346
|
+
class: [!children && icon ? 'px-0 aspect-square justify-center' : '', ui.base]
|
|
347
|
+
})}
|
|
346
348
|
onclick={onClickWrapper}
|
|
347
349
|
>
|
|
348
350
|
{@render Content()}
|
|
@@ -370,7 +372,9 @@
|
|
|
370
372
|
|
|
371
373
|
{#if IconCom}
|
|
372
374
|
{#if typeof IconCom === 'string'}
|
|
373
|
-
<div
|
|
375
|
+
<div
|
|
376
|
+
class={classes.icon({ class: ['pi', IconCom, is_loading && 'animate-spin', ui.icon] })}
|
|
377
|
+
></div>
|
|
374
378
|
{:else if isSnippet(IconCom)}
|
|
375
379
|
{@render IconCom()}
|
|
376
380
|
{:else}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { type Component, type Snippet } from 'svelte';
|
|
2
|
+
import { type PropColor } from '../index.js';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
2
4
|
export type ButtonProps = {
|
|
3
5
|
/** The underlying DOM element being rendered. You can bind to this to get a reference to the element. */
|
|
4
6
|
ref?: HTMLButtonElement | HTMLAnchorElement;
|
|
@@ -26,7 +28,7 @@ export type ButtonProps = {
|
|
|
26
28
|
/**
|
|
27
29
|
* @defaultValue 'solid'
|
|
28
30
|
*/
|
|
29
|
-
variant?:
|
|
31
|
+
variant?: 'link' | 'solid' | 'outline' | 'soft' | 'subtle' | 'ghost';
|
|
30
32
|
/**
|
|
31
33
|
* @defaultValue 'md'
|
|
32
34
|
*/
|
|
@@ -37,14 +39,11 @@ export type ButtonProps = {
|
|
|
37
39
|
loadingauto?: boolean;
|
|
38
40
|
onclick?: (event: MouseEvent) => void | Promise<void>;
|
|
39
41
|
ui?: {
|
|
40
|
-
base?:
|
|
41
|
-
icon?:
|
|
42
|
+
base?: ClassNameValue;
|
|
43
|
+
icon?: ClassNameValue;
|
|
42
44
|
};
|
|
43
45
|
children?: Snippet;
|
|
44
46
|
};
|
|
45
|
-
import { type Component, type Snippet } from 'svelte';
|
|
46
|
-
import type { ClassValue } from 'svelte/elements';
|
|
47
|
-
import type { PropColor } from '../types.js';
|
|
48
47
|
declare const Button: Component<ButtonProps, {}, "ref">;
|
|
49
48
|
type Button = ReturnType<typeof Button>;
|
|
50
49
|
export default Button;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
import type
|
|
3
|
-
import { isComponent, isSnippet } from '../utils/common.js';
|
|
2
|
+
import { type PropColor, isComponent, isSnippet } from '../index.js';
|
|
4
3
|
import type { Snippet } from 'svelte';
|
|
5
4
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
6
5
|
import { tv } from 'tailwind-variants';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
import { isComponent, isSnippet } from '../utils/common.js';
|
|
3
2
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
3
|
import { tv } from 'tailwind-variants';
|
|
5
4
|
import { Checkbox } from './index.js';
|
|
6
5
|
import type { Component, Snippet } from 'svelte';
|
|
7
|
-
import type
|
|
6
|
+
import { type PropColor, isComponent, isSnippet } from '../index.js';
|
|
8
7
|
|
|
9
8
|
/* eslint @typescript-eslint/no-explicit-any: 0 */
|
|
10
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
2
2
|
import type { Component, Snippet } from 'svelte';
|
|
3
|
-
import type
|
|
3
|
+
import { type PropColor } from '../index.js';
|
|
4
4
|
export type CheckboxGroupProps = {
|
|
5
5
|
color?: PropColor;
|
|
6
6
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
import { tv } from 'tailwind-variants';
|
|
5
|
+
|
|
6
|
+
export type H1Props = {
|
|
7
|
+
children: Snippet;
|
|
8
|
+
ui?: { root?: ClassNameValue };
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
const { children, ui = {} }: H1Props = $props();
|
|
14
|
+
|
|
15
|
+
const classes = $derived(
|
|
16
|
+
tv({
|
|
17
|
+
variants: {
|
|
18
|
+
slots: {
|
|
19
|
+
root: 'text-4xl text-highlighted font-bold mb-8 scroll-mt-[calc(45px+var(--ui-header-height))] lg:scroll-mt-(--ui-header-height)'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
})({ class: ui.root })
|
|
23
|
+
);
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<h1 class={classes}>
|
|
27
|
+
{@render children()}
|
|
28
|
+
</h1>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
|
+
export type H1Props = {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
ui?: {
|
|
6
|
+
root?: ClassNameValue;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
declare const H1: import("svelte").Component<H1Props, {}, "">;
|
|
10
|
+
type H1 = ReturnType<typeof H1>;
|
|
11
|
+
export default H1;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
import { tv } from 'tailwind-variants';
|
|
5
|
+
|
|
6
|
+
export type H2Props = {
|
|
7
|
+
children: Snippet;
|
|
8
|
+
ui?: { root?: ClassNameValue };
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
const { children, ui = {} }: H2Props = $props();
|
|
14
|
+
|
|
15
|
+
const classes = $derived(
|
|
16
|
+
tv({
|
|
17
|
+
base: [
|
|
18
|
+
'relative text-2xl text-highlighted font-bold mt-12 mb-6',
|
|
19
|
+
'scroll-mt-[calc(48px+45px+var(--ui-header-height))] lg:scroll-mt-[calc(48px+var(--ui-header-height))]',
|
|
20
|
+
'hover:[&>a>code]:(border-primary text-primary)',
|
|
21
|
+
'[&>a>code]:(transition-colors text-xl/7 font-bold border-dashed)',
|
|
22
|
+
'[&>a]:focus-visible:outline-primary'
|
|
23
|
+
]
|
|
24
|
+
})({ class: ui.root })
|
|
25
|
+
);
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<h1 class={classes}>
|
|
29
|
+
{@render children()}
|
|
30
|
+
</h1>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
|
+
export type H2Props = {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
ui?: {
|
|
6
|
+
root?: ClassNameValue;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
declare const H2: import("svelte").Component<H2Props, {}, "">;
|
|
10
|
+
type H2 = ReturnType<typeof H2>;
|
|
11
|
+
export default H2;
|
|
@@ -20,3 +20,15 @@ export * from './checkbox.svelte';
|
|
|
20
20
|
export { default as Checkbox } from './checkbox.svelte';
|
|
21
21
|
export * from './checkboxgroup.svelte';
|
|
22
22
|
export { default as CheckboxGroup } from './checkboxgroup.svelte';
|
|
23
|
+
export * from './h1.svelte';
|
|
24
|
+
export { default as H1 } from './h1.svelte';
|
|
25
|
+
export * from './h2.svelte';
|
|
26
|
+
export { default as H2 } from './h2.svelte';
|
|
27
|
+
export * from './p.svelte';
|
|
28
|
+
export { default as P } from './p.svelte';
|
|
29
|
+
export * from './pin-input.svelte';
|
|
30
|
+
export { default as PinInput } from './pin-input.svelte';
|
|
31
|
+
export * from './accordion.svelte';
|
|
32
|
+
export { default as Accordion } from './accordion.svelte';
|
|
33
|
+
export * from './kbd.svelte';
|
|
34
|
+
export { default as KBD } from './kbd.svelte';
|
package/dist/components/index.js
CHANGED
|
@@ -20,3 +20,15 @@ export * from './checkbox.svelte';
|
|
|
20
20
|
export { default as Checkbox } from './checkbox.svelte';
|
|
21
21
|
export * from './checkboxgroup.svelte';
|
|
22
22
|
export { default as CheckboxGroup } from './checkboxgroup.svelte';
|
|
23
|
+
export * from './h1.svelte';
|
|
24
|
+
export { default as H1 } from './h1.svelte';
|
|
25
|
+
export * from './h2.svelte';
|
|
26
|
+
export { default as H2 } from './h2.svelte';
|
|
27
|
+
export * from './p.svelte';
|
|
28
|
+
export { default as P } from './p.svelte';
|
|
29
|
+
export * from './pin-input.svelte';
|
|
30
|
+
export { default as PinInput } from './pin-input.svelte';
|
|
31
|
+
export * from './accordion.svelte';
|
|
32
|
+
export { default as Accordion } from './accordion.svelte';
|
|
33
|
+
export * from './kbd.svelte';
|
|
34
|
+
export { default as KBD } from './kbd.svelte';
|
|
@@ -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
|
+
secondary: '',
|
|
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: 'secondary',
|
|
112
|
+
variant: 'outline',
|
|
113
|
+
class: 'border-secondary-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: 'secondary',
|
|
144
|
+
variant: 'solid',
|
|
145
|
+
class: 'bg-secondary-600 border-secondary-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: 'secondary',
|
|
176
|
+
variant: 'soft',
|
|
177
|
+
class: 'bg-secondary-100 text-secondary-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: 'secondary',
|
|
208
|
+
variant: 'subtle',
|
|
209
|
+
class: 'bg-secondary-100 border-secondary-200 text-secondary-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,22 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
import { tv } from 'tailwind-variants';
|
|
5
|
+
|
|
6
|
+
export type ParagraphProps = {
|
|
7
|
+
children: Snippet;
|
|
8
|
+
ui?: { root?: ClassNameValue };
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
const { children, ui = {} }: ParagraphProps = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<p
|
|
17
|
+
class={tv({
|
|
18
|
+
base: 'my-5 leading-7 text-pretty'
|
|
19
|
+
})({ class: ui.root })}
|
|
20
|
+
>
|
|
21
|
+
{@render children()}
|
|
22
|
+
</p>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
|
+
export type ParagraphProps = {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
ui?: {
|
|
6
|
+
root?: ClassNameValue;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
declare const P: import("svelte").Component<ParagraphProps, {}, "">;
|
|
10
|
+
type P = ReturnType<typeof P>;
|
|
11
|
+
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
|
+
secondary: '',
|
|
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-secondary-300 focus:(border-2)'
|
|
84
|
+
},
|
|
85
|
+
soft: {
|
|
86
|
+
cell: 'bg-secondary-50 hover:(bg-secondary-100) focus:(bg-secondary-100)'
|
|
87
|
+
},
|
|
88
|
+
subtle: { cell: 'border border-secondary-300 bg-secondary-100 focus:(border-2)' },
|
|
89
|
+
ghost: { cell: 'hover:(bg-secondary-100) focus:(bg-secondary-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: 'secondary',
|
|
102
|
+
class: { cell: 'focus:(border-secondary-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;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
import type
|
|
3
|
-
import { isComponent, isSnippet } from '../utils/common.js';
|
|
2
|
+
import { type PropColor, isComponent, isSnippet } from '../index.js';
|
|
4
3
|
import type { Snippet } from 'svelte';
|
|
5
4
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
6
5
|
import { tv } from 'tailwind-variants';
|
|
@@ -122,6 +121,7 @@
|
|
|
122
121
|
data-state={value ? 'checked' : 'unchecked'}
|
|
123
122
|
class={classes.container({ class: [loading && 'cursor-not-allowed', ui.thumb] })}
|
|
124
123
|
onclick={() => {
|
|
124
|
+
console.log('click');
|
|
125
125
|
if (loading) return;
|
|
126
126
|
value = !value;
|
|
127
127
|
}}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/utils/common.d.ts
CHANGED
package/dist/utils/common.js
CHANGED
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uisv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "ui library for the rest of us",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "ui-sv/uisv",
|
|
7
|
-
"homepage": "https://
|
|
7
|
+
"homepage": "https://uisv.pages.dev",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"dev": "vite dev",
|
|
10
10
|
"build": "vite build && npm run prepack",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@eslint/compat": "^1.2.5",
|
|
47
47
|
"@eslint/js": "^9.22.0",
|
|
48
|
+
"@iconify-json/logos": "^1.2.9",
|
|
48
49
|
"@iconify-json/lucide": "^1.2.68",
|
|
49
50
|
"@iconify-json/solar": "^1.2.4",
|
|
50
51
|
"@sveltejs/adapter-auto": "^6.0.0",
|
|
@@ -57,13 +58,13 @@
|
|
|
57
58
|
"@unocss/reset": "^66.5.1",
|
|
58
59
|
"@vitest/browser": "^3.2.3",
|
|
59
60
|
"bits-ui": "^2.11.0",
|
|
60
|
-
"carta-md": "^4.11.1",
|
|
61
61
|
"defu": "^6.1.4",
|
|
62
62
|
"eslint": "^9.22.0",
|
|
63
63
|
"eslint-config-prettier": "^10.0.1",
|
|
64
64
|
"eslint-plugin-svelte": "^3.0.0",
|
|
65
65
|
"globals": "^16.0.0",
|
|
66
66
|
"mdsvex": "^0.12.3",
|
|
67
|
+
"mode-watcher": "^1.1.0",
|
|
67
68
|
"playwright": "^1.53.0",
|
|
68
69
|
"prettier": "^3.4.2",
|
|
69
70
|
"prettier-plugin-svelte": "^3.3.3",
|
|
@@ -73,7 +74,6 @@
|
|
|
73
74
|
"svelte-check": "^4.0.0",
|
|
74
75
|
"tailwind-merge": "^3.3.1",
|
|
75
76
|
"tailwind-variants": "^3.1.1",
|
|
76
|
-
"tailwindcss": "^4.1.13",
|
|
77
77
|
"theme-colors": "^0.1.0",
|
|
78
78
|
"typescript": "^5.0.0",
|
|
79
79
|
"typescript-eslint": "^8.20.0",
|
package/dist/types.d.ts
DELETED
package/dist/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/utils/keys.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const FORM_OPTION_CONTEXT_KEY: unique symbol;
|
|
2
|
-
export declare const FORM_BUS_CONTEXT_KEY: unique symbol;
|
|
3
|
-
export declare const FORM_STATE_CONTEXT_KEY: unique symbol;
|
|
4
|
-
export declare const FORM_FIELD_CONTEXT_KEY: unique symbol;
|
|
5
|
-
export declare const FORM_TID_CONTEXT_KEY: unique symbol;
|
|
6
|
-
export declare const FORM_INPUTS_CONTEXT_KEY: unique symbol;
|
|
7
|
-
export declare const FORM_LOADING_CONTEXT_KEY: unique symbol;
|
|
8
|
-
export declare const FORM_ERRORS_CONTEXT_KEY: unique symbol;
|
package/dist/utils/keys.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export const FORM_OPTION_CONTEXT_KEY = Symbol('uisv.form-options');
|
|
2
|
-
export const FORM_BUS_CONTEXT_KEY = Symbol('uisv.form-events');
|
|
3
|
-
export const FORM_STATE_CONTEXT_KEY = Symbol('uisv.form-state');
|
|
4
|
-
export const FORM_FIELD_CONTEXT_KEY = Symbol('uisv.form-field');
|
|
5
|
-
export const FORM_TID_CONTEXT_KEY = Symbol('uisv.input-id');
|
|
6
|
-
export const FORM_INPUTS_CONTEXT_KEY = Symbol('uisv.form-inputs');
|
|
7
|
-
export const FORM_LOADING_CONTEXT_KEY = Symbol('uisv.form-loading');
|
|
8
|
-
export const FORM_ERRORS_CONTEXT_KEY = Symbol('uisv.form-errors');
|
package/dist/utils/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/utils/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|