uisv 0.0.3 → 0.0.5
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/alert.svelte +274 -0
- package/dist/components/alert.svelte.d.ts +24 -0
- package/dist/components/badge.svelte +227 -0
- package/dist/components/badge.svelte.d.ts +19 -0
- package/dist/components/banner.svelte +257 -0
- package/dist/components/banner.svelte.d.ts +24 -0
- package/dist/components/button.svelte +380 -0
- package/dist/components/button.svelte.d.ts +50 -0
- package/dist/components/card.svelte +70 -0
- package/dist/components/card.svelte.d.ts +17 -0
- package/dist/components/checkbox.svelte +176 -0
- package/dist/components/checkbox.svelte.d.ts +27 -0
- package/dist/components/checkboxgroup.svelte +260 -0
- package/dist/components/checkboxgroup.svelte.d.ts +26 -0
- package/dist/components/chip.svelte +82 -0
- package/dist/components/chip.svelte.d.ts +17 -0
- package/dist/components/index.d.ts +22 -0
- package/dist/components/index.js +22 -0
- package/dist/components/placeholder.svelte +32 -0
- package/dist/components/placeholder.svelte.d.ts +7 -0
- package/dist/components/progress.svelte +124 -0
- package/dist/components/progress.svelte.d.ts +21 -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/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js +1 -0
- package/dist/utils/common.d.ts +14 -0
- package/dist/utils/common.js +18 -0
- package/dist/utils/keys.d.ts +8 -0
- package/dist/utils/keys.js +8 -0
- package/dist/utils/types.d.ts +1 -0
- package/dist/utils/types.js +1 -0
- package/dist/vite.d.ts +38 -0
- package/dist/vite.js +57 -0
- package/package.json +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
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 CardProps = {
|
|
7
|
+
children: Snippet;
|
|
8
|
+
header?: Snippet;
|
|
9
|
+
footer?: Snippet;
|
|
10
|
+
variant?: 'solid' | 'outline' | 'soft' | 'subtle';
|
|
11
|
+
ui?: {
|
|
12
|
+
base?: ClassNameValue;
|
|
13
|
+
header?: ClassNameValue;
|
|
14
|
+
content?: ClassNameValue;
|
|
15
|
+
footer?: ClassNameValue;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
let { header, children, footer, variant = 'solid', ui = {} }: CardProps = $props();
|
|
22
|
+
|
|
23
|
+
const classes = $derived.by(() =>
|
|
24
|
+
tv({
|
|
25
|
+
slots: {
|
|
26
|
+
base: 'rounded overflow-hidden',
|
|
27
|
+
header: 'p-4 sm:px-6',
|
|
28
|
+
content: 'p-4 sm:p-6',
|
|
29
|
+
footer: 'p-4 sm:px-6'
|
|
30
|
+
},
|
|
31
|
+
variants: {
|
|
32
|
+
variant: {
|
|
33
|
+
solid: {
|
|
34
|
+
base: 'bg-secondary-900 text-secondary-50',
|
|
35
|
+
header: 'border-transparent',
|
|
36
|
+
footer: 'border-transparent'
|
|
37
|
+
},
|
|
38
|
+
outline: {
|
|
39
|
+
base: 'border border-secondary-300 divide-y divide-secondary-300'
|
|
40
|
+
},
|
|
41
|
+
soft: {
|
|
42
|
+
base: 'bg-secondary-50 divide-y divide-secondary-300'
|
|
43
|
+
},
|
|
44
|
+
subtle: {
|
|
45
|
+
base: 'bg-secondary-50 border-secondary-300 border divide-y divide-secondary-300'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
compoundVariants: []
|
|
50
|
+
})({ variant })
|
|
51
|
+
);
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<div class={classes.base({ class: [ui.base] })}>
|
|
55
|
+
{#if header}
|
|
56
|
+
<div class={classes.header({ class: [ui.header] })}>
|
|
57
|
+
{@render header()}
|
|
58
|
+
</div>
|
|
59
|
+
{/if}
|
|
60
|
+
|
|
61
|
+
<div class={classes.content({ class: ui.content })}>
|
|
62
|
+
{@render children()}
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
{#if footer}
|
|
66
|
+
<div class={classes.header({ class: [ui.header] })}>
|
|
67
|
+
{@render footer()}
|
|
68
|
+
</div>
|
|
69
|
+
{/if}
|
|
70
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
|
+
export type CardProps = {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
header?: Snippet;
|
|
6
|
+
footer?: Snippet;
|
|
7
|
+
variant?: 'solid' | 'outline' | 'soft' | 'subtle';
|
|
8
|
+
ui?: {
|
|
9
|
+
base?: ClassNameValue;
|
|
10
|
+
header?: ClassNameValue;
|
|
11
|
+
content?: ClassNameValue;
|
|
12
|
+
footer?: ClassNameValue;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
declare const Card: import("svelte").Component<CardProps, {}, "">;
|
|
16
|
+
type Card = ReturnType<typeof Card>;
|
|
17
|
+
export default Card;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { PropColor } from '../types.js';
|
|
3
|
+
import { isComponent, isSnippet } from '../utils/common.js';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
6
|
+
import { tv } from 'tailwind-variants';
|
|
7
|
+
import type { Component } from 'vitest-browser-svelte';
|
|
8
|
+
|
|
9
|
+
export type CheckboxProps = {
|
|
10
|
+
value?: boolean | 'intermediate';
|
|
11
|
+
color?: PropColor;
|
|
12
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
icon?: string | Snippet | Component;
|
|
15
|
+
intermediateicon?: string | Snippet | Component;
|
|
16
|
+
label?: string | Snippet;
|
|
17
|
+
description?: string | Snippet;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
indicator?: 'start' | 'end' | 'hidden';
|
|
20
|
+
as?: string;
|
|
21
|
+
ui?: {
|
|
22
|
+
root?: ClassNameValue;
|
|
23
|
+
container?: ClassNameValue;
|
|
24
|
+
icon?: ClassNameValue;
|
|
25
|
+
label?: ClassNameValue;
|
|
26
|
+
description?: ClassNameValue;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<script lang="ts">
|
|
32
|
+
let {
|
|
33
|
+
value = $bindable(false),
|
|
34
|
+
color = 'primary',
|
|
35
|
+
size = 'md',
|
|
36
|
+
disabled,
|
|
37
|
+
icon = 'i-lucide-check',
|
|
38
|
+
intermediateicon = 'i-lucide-minus',
|
|
39
|
+
label,
|
|
40
|
+
description,
|
|
41
|
+
required,
|
|
42
|
+
indicator = 'start',
|
|
43
|
+
as = 'div',
|
|
44
|
+
ui = {}
|
|
45
|
+
}: CheckboxProps = $props();
|
|
46
|
+
const id = $props.id();
|
|
47
|
+
|
|
48
|
+
const classes = $derived.by(() =>
|
|
49
|
+
tv({
|
|
50
|
+
slots: {
|
|
51
|
+
root: 'relative flex-inline gap-2',
|
|
52
|
+
container:
|
|
53
|
+
'rounded-md border border-neutral-200 relative transition m-0.5 mr-0 grid place-items-center',
|
|
54
|
+
icon: 'pi text-white',
|
|
55
|
+
label: 'text-sm font-medium',
|
|
56
|
+
description: 'text-sm text-neutral-500'
|
|
57
|
+
},
|
|
58
|
+
variants: {
|
|
59
|
+
color: {
|
|
60
|
+
primary: {
|
|
61
|
+
container: [value && 'bg-primary-500 border-primary-500 text-primary-500']
|
|
62
|
+
},
|
|
63
|
+
secondary: {
|
|
64
|
+
container: [value && 'bg-neutral-900 border-neutral-900 text-neutral-900']
|
|
65
|
+
},
|
|
66
|
+
info: {
|
|
67
|
+
container: [value && 'bg-info-500 border-info-500 text-info-500']
|
|
68
|
+
},
|
|
69
|
+
success: {
|
|
70
|
+
container: [value && 'bg-success-500 border-success-500 text-success-500']
|
|
71
|
+
},
|
|
72
|
+
warning: {
|
|
73
|
+
container: [value && 'bg-warning-500 border-warning-500 text-warning-500']
|
|
74
|
+
},
|
|
75
|
+
error: {
|
|
76
|
+
container: [value && 'bg-error-500 border-error-500 text-error-500']
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
size: {
|
|
80
|
+
xs: {
|
|
81
|
+
container: 'size-3',
|
|
82
|
+
icon: 'size-3'
|
|
83
|
+
},
|
|
84
|
+
sm: {
|
|
85
|
+
container: 'size-3.5',
|
|
86
|
+
icon: 'size-3.5'
|
|
87
|
+
},
|
|
88
|
+
md: {
|
|
89
|
+
container: 'size-4',
|
|
90
|
+
icon: 'size-4'
|
|
91
|
+
},
|
|
92
|
+
lg: {
|
|
93
|
+
container: 'size-4.5',
|
|
94
|
+
icon: 'size-4.5'
|
|
95
|
+
},
|
|
96
|
+
xl: {
|
|
97
|
+
container: 'size-5',
|
|
98
|
+
icon: 'size-5'
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
indicator: {
|
|
102
|
+
start: '',
|
|
103
|
+
end: {
|
|
104
|
+
root: 'flex-row-reverse'
|
|
105
|
+
},
|
|
106
|
+
hidden: {
|
|
107
|
+
container: 'hidden'
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
compoundVariants: []
|
|
112
|
+
})({ color, size, indicator })
|
|
113
|
+
);
|
|
114
|
+
</script>
|
|
115
|
+
|
|
116
|
+
<svelte:element
|
|
117
|
+
this={as}
|
|
118
|
+
data-state={value ? 'checked' : 'unchecked'}
|
|
119
|
+
class={classes.root({
|
|
120
|
+
class: [disabled && 'opacity-50', ui.root]
|
|
121
|
+
})}
|
|
122
|
+
>
|
|
123
|
+
<button
|
|
124
|
+
{id}
|
|
125
|
+
aria-label="checkbox"
|
|
126
|
+
class={classes.container({ class: [ui.container] })}
|
|
127
|
+
onclick={() => {
|
|
128
|
+
if (disabled) return;
|
|
129
|
+
if (value === 'intermediate') return (value = true);
|
|
130
|
+
value = !value;
|
|
131
|
+
}}
|
|
132
|
+
>
|
|
133
|
+
{@render Icon(icon, [value !== true && 'opacity-0'])}
|
|
134
|
+
{@render Icon(intermediateicon, [value !== 'intermediate' && 'opacity-0'])}
|
|
135
|
+
</button>
|
|
136
|
+
|
|
137
|
+
{#if label}
|
|
138
|
+
<div class="flex flex-col justify-start">
|
|
139
|
+
<label
|
|
140
|
+
for={id}
|
|
141
|
+
class={classes.label({
|
|
142
|
+
class: [required ? 'after:content-["*"] after:text-error-500' : '', ui.label]
|
|
143
|
+
})}
|
|
144
|
+
>
|
|
145
|
+
{#if typeof label === 'string'}
|
|
146
|
+
{label}
|
|
147
|
+
{:else}
|
|
148
|
+
{@render label()}
|
|
149
|
+
{/if}
|
|
150
|
+
</label>
|
|
151
|
+
|
|
152
|
+
{#if description}
|
|
153
|
+
<div class={classes.description({ class: ui.description })}>
|
|
154
|
+
{#if typeof description === 'string'}
|
|
155
|
+
{description}
|
|
156
|
+
{:else}
|
|
157
|
+
{@render description()}
|
|
158
|
+
{/if}
|
|
159
|
+
</div>
|
|
160
|
+
{/if}
|
|
161
|
+
</div>
|
|
162
|
+
{/if}
|
|
163
|
+
</svelte:element>
|
|
164
|
+
|
|
165
|
+
{#snippet Icon(ico?: CheckboxProps['icon'], icon_class?: ClassNameValue)}
|
|
166
|
+
<div class={['absolute', icon_class]}>
|
|
167
|
+
{#if typeof ico === 'string'}
|
|
168
|
+
<div class={classes.icon({ class: [ico, ui.icon] })}></div>
|
|
169
|
+
{:else if isSnippet(ico)}
|
|
170
|
+
{@render ico()}
|
|
171
|
+
{:else if isComponent(ico)}
|
|
172
|
+
{@const Iconn = ico}
|
|
173
|
+
<Iconn />
|
|
174
|
+
{/if}
|
|
175
|
+
</div>
|
|
176
|
+
{/snippet}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PropColor } from '../types.js';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
import type { Component } from 'vitest-browser-svelte';
|
|
5
|
+
export type CheckboxProps = {
|
|
6
|
+
value?: boolean | 'intermediate';
|
|
7
|
+
color?: PropColor;
|
|
8
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
icon?: string | Snippet | Component;
|
|
11
|
+
intermediateicon?: string | Snippet | Component;
|
|
12
|
+
label?: string | Snippet;
|
|
13
|
+
description?: string | Snippet;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
indicator?: 'start' | 'end' | 'hidden';
|
|
16
|
+
as?: string;
|
|
17
|
+
ui?: {
|
|
18
|
+
root?: ClassNameValue;
|
|
19
|
+
container?: ClassNameValue;
|
|
20
|
+
icon?: ClassNameValue;
|
|
21
|
+
label?: ClassNameValue;
|
|
22
|
+
description?: ClassNameValue;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
declare const Checkbox: import("svelte").Component<CheckboxProps, {}, "value">;
|
|
26
|
+
type Checkbox = ReturnType<typeof Checkbox>;
|
|
27
|
+
export default Checkbox;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { isComponent, isSnippet } from '../utils/common.js';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
import { tv } from 'tailwind-variants';
|
|
5
|
+
import { Checkbox } from './index.js';
|
|
6
|
+
import type { Component, Snippet } from 'svelte';
|
|
7
|
+
import type { PropColor } from '../types.js';
|
|
8
|
+
|
|
9
|
+
/* eslint @typescript-eslint/no-explicit-any: 0 */
|
|
10
|
+
|
|
11
|
+
export type CheckboxGroupProps = {
|
|
12
|
+
color?: PropColor;
|
|
13
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
14
|
+
icon?: string | Snippet | Component;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
indicator?: 'start' | 'end' | 'hidden';
|
|
17
|
+
value?: any[];
|
|
18
|
+
valuekey?: string;
|
|
19
|
+
variant?: 'list' | 'card' | 'table';
|
|
20
|
+
items: Array<any>;
|
|
21
|
+
labelkey?: string;
|
|
22
|
+
descriptionkey?: string;
|
|
23
|
+
legend?: string | Snippet | Component;
|
|
24
|
+
orientation?: 'horizontal' | 'vertical';
|
|
25
|
+
ui?: {
|
|
26
|
+
root?: ClassNameValue;
|
|
27
|
+
container?: ClassNameValue;
|
|
28
|
+
checkbox?: ClassNameValue;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<script lang="ts">
|
|
34
|
+
let {
|
|
35
|
+
value = $bindable([]),
|
|
36
|
+
valuekey = 'value',
|
|
37
|
+
color = 'primary',
|
|
38
|
+
size = 'md',
|
|
39
|
+
variant = 'list',
|
|
40
|
+
items = [],
|
|
41
|
+
labelkey = 'label',
|
|
42
|
+
descriptionkey = 'description',
|
|
43
|
+
legend,
|
|
44
|
+
orientation = 'horizontal',
|
|
45
|
+
ui = {},
|
|
46
|
+
...props
|
|
47
|
+
}: CheckboxGroupProps = $props();
|
|
48
|
+
|
|
49
|
+
const classes = $derived.by(() =>
|
|
50
|
+
tv({
|
|
51
|
+
slots: {
|
|
52
|
+
root: '',
|
|
53
|
+
container: 'flex',
|
|
54
|
+
checkbox: ''
|
|
55
|
+
},
|
|
56
|
+
variants: {
|
|
57
|
+
color: {
|
|
58
|
+
primary: {
|
|
59
|
+
container: []
|
|
60
|
+
},
|
|
61
|
+
secondary: {
|
|
62
|
+
container: []
|
|
63
|
+
},
|
|
64
|
+
info: {
|
|
65
|
+
container: []
|
|
66
|
+
},
|
|
67
|
+
success: {
|
|
68
|
+
container: []
|
|
69
|
+
},
|
|
70
|
+
warning: {
|
|
71
|
+
container: []
|
|
72
|
+
},
|
|
73
|
+
error: {
|
|
74
|
+
container: []
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
size: {
|
|
78
|
+
xs: {
|
|
79
|
+
container: '',
|
|
80
|
+
icon: 'size-3'
|
|
81
|
+
},
|
|
82
|
+
sm: {
|
|
83
|
+
container: '',
|
|
84
|
+
icon: 'size-3.5'
|
|
85
|
+
},
|
|
86
|
+
md: {
|
|
87
|
+
container: '',
|
|
88
|
+
icon: 'size-4'
|
|
89
|
+
},
|
|
90
|
+
lg: {
|
|
91
|
+
container: '',
|
|
92
|
+
icon: 'size-4.5'
|
|
93
|
+
},
|
|
94
|
+
xl: {
|
|
95
|
+
container: '',
|
|
96
|
+
icon: 'size-5'
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
variant: {
|
|
100
|
+
list: { container: 'gap-2' },
|
|
101
|
+
card: { container: 'gap-2', checkbox: 'p-4 rounded-lg border border-neutral-200' },
|
|
102
|
+
table: {
|
|
103
|
+
container: 'gap-0 ',
|
|
104
|
+
checkbox: 'border border-neutral-200 p-4 data-[state=checked]:z-1'
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
orientation: {
|
|
108
|
+
horizontal: {
|
|
109
|
+
container: 'flex-row',
|
|
110
|
+
checkbox:
|
|
111
|
+
'[&:not(:last-child)]:(-me-px ms-0) first-of-type:rounded-s-lg last-of-type:rounded-e-lg'
|
|
112
|
+
},
|
|
113
|
+
vertical: {
|
|
114
|
+
container: 'flex-col -space-y-px'
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
selected: { true: '', false: '' }
|
|
118
|
+
},
|
|
119
|
+
compoundVariants: [
|
|
120
|
+
{
|
|
121
|
+
color: 'primary',
|
|
122
|
+
selected: true,
|
|
123
|
+
variant: ['table', 'card'],
|
|
124
|
+
class: {
|
|
125
|
+
checkbox: 'border-primary-500'
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
color: 'secondary',
|
|
130
|
+
selected: true,
|
|
131
|
+
variant: ['table', 'card'],
|
|
132
|
+
class: {
|
|
133
|
+
checkbox: 'border-secondary-500'
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
color: 'info',
|
|
138
|
+
selected: true,
|
|
139
|
+
variant: ['table', 'card'],
|
|
140
|
+
class: {
|
|
141
|
+
checkbox: 'border-info-500'
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
color: 'success',
|
|
146
|
+
selected: true,
|
|
147
|
+
variant: ['table', 'card'],
|
|
148
|
+
class: {
|
|
149
|
+
checkbox: 'border-success-500'
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
color: 'warning',
|
|
154
|
+
selected: true,
|
|
155
|
+
variant: ['table', 'card'],
|
|
156
|
+
class: {
|
|
157
|
+
checkbox: 'border-warning-500'
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
color: 'error',
|
|
162
|
+
selected: true,
|
|
163
|
+
variant: ['table', 'card'],
|
|
164
|
+
class: {
|
|
165
|
+
checkbox: 'border-error-500'
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
{
|
|
170
|
+
color: 'primary',
|
|
171
|
+
selected: true,
|
|
172
|
+
variant: ['table'],
|
|
173
|
+
class: {
|
|
174
|
+
checkbox: 'bg-primary-100'
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
color: 'secondary',
|
|
179
|
+
selected: true,
|
|
180
|
+
variant: ['table'],
|
|
181
|
+
class: {
|
|
182
|
+
checkbox: 'bg-secondary-100'
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
color: 'info',
|
|
187
|
+
selected: true,
|
|
188
|
+
variant: ['table'],
|
|
189
|
+
class: {
|
|
190
|
+
checkbox: 'bg-info-100'
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
color: 'success',
|
|
195
|
+
selected: true,
|
|
196
|
+
variant: ['table'],
|
|
197
|
+
class: {
|
|
198
|
+
checkbox: 'bg-success-100'
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
color: 'warning',
|
|
203
|
+
selected: true,
|
|
204
|
+
variant: ['table'],
|
|
205
|
+
class: {
|
|
206
|
+
checkbox: 'bg-warning-100'
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
color: 'error',
|
|
211
|
+
selected: true,
|
|
212
|
+
variant: ['table'],
|
|
213
|
+
class: {
|
|
214
|
+
checkbox: 'bg-error-100'
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
})({ color, size, variant, orientation })
|
|
219
|
+
);
|
|
220
|
+
</script>
|
|
221
|
+
|
|
222
|
+
<div class={classes.root({ class: [ui.root] })}>
|
|
223
|
+
{#if typeof legend === 'string'}
|
|
224
|
+
<legend>{legend}</legend>
|
|
225
|
+
{:else if isSnippet(legend)}
|
|
226
|
+
{@render legend()}
|
|
227
|
+
{:else if isComponent(legend)}
|
|
228
|
+
{@const Legend = legend}
|
|
229
|
+
<Legend />
|
|
230
|
+
{/if}
|
|
231
|
+
|
|
232
|
+
<fieldset class={classes.container({ class: [ui.container] })}>
|
|
233
|
+
{#each items as item, index (index)}
|
|
234
|
+
{@const key = typeof item === 'object' ? item[valuekey] : item}
|
|
235
|
+
|
|
236
|
+
<Checkbox
|
|
237
|
+
{...props}
|
|
238
|
+
{color}
|
|
239
|
+
as={variant === 'list' ? 'div' : 'label'}
|
|
240
|
+
ui={{
|
|
241
|
+
root: classes.checkbox({
|
|
242
|
+
class: [ui.checkbox],
|
|
243
|
+
selected: value.includes(key)
|
|
244
|
+
})
|
|
245
|
+
}}
|
|
246
|
+
bind:value={
|
|
247
|
+
() => value.includes(key),
|
|
248
|
+
(v) => {
|
|
249
|
+
if (v) return value.push(key);
|
|
250
|
+
const index = value.findIndex((x) => x === key);
|
|
251
|
+
if (index < 0) return;
|
|
252
|
+
value.splice(index, 1);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
description={typeof item === 'object' ? item[descriptionkey] : undefined}
|
|
256
|
+
label={typeof item === 'object' ? item[labelkey] : item}
|
|
257
|
+
/>
|
|
258
|
+
{/each}
|
|
259
|
+
</fieldset>
|
|
260
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
2
|
+
import type { Component, Snippet } from 'svelte';
|
|
3
|
+
import type { PropColor } from '../types.js';
|
|
4
|
+
export type CheckboxGroupProps = {
|
|
5
|
+
color?: PropColor;
|
|
6
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
7
|
+
icon?: string | Snippet | Component;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
indicator?: 'start' | 'end' | 'hidden';
|
|
10
|
+
value?: any[];
|
|
11
|
+
valuekey?: string;
|
|
12
|
+
variant?: 'list' | 'card' | 'table';
|
|
13
|
+
items: Array<any>;
|
|
14
|
+
labelkey?: string;
|
|
15
|
+
descriptionkey?: string;
|
|
16
|
+
legend?: string | Snippet | Component;
|
|
17
|
+
orientation?: 'horizontal' | 'vertical';
|
|
18
|
+
ui?: {
|
|
19
|
+
root?: ClassNameValue;
|
|
20
|
+
container?: ClassNameValue;
|
|
21
|
+
checkbox?: ClassNameValue;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
declare const Checkboxgroup: Component<CheckboxGroupProps, {}, "value">;
|
|
25
|
+
type Checkboxgroup = ReturnType<typeof Checkboxgroup>;
|
|
26
|
+
export default Checkboxgroup;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { PropColor } from '../types.js';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
5
|
+
import { tv } from 'tailwind-variants';
|
|
6
|
+
|
|
7
|
+
export type ChipProps = {
|
|
8
|
+
children: Snippet;
|
|
9
|
+
text?: string;
|
|
10
|
+
color?: PropColor;
|
|
11
|
+
position?: 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
|
|
12
|
+
size?: number;
|
|
13
|
+
ui?: {
|
|
14
|
+
base?: ClassNameValue;
|
|
15
|
+
chip?: ClassNameValue;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
let {
|
|
22
|
+
children,
|
|
23
|
+
text,
|
|
24
|
+
color = 'primary',
|
|
25
|
+
position = 'top-right',
|
|
26
|
+
size = 8,
|
|
27
|
+
ui = {}
|
|
28
|
+
}: ChipProps = $props();
|
|
29
|
+
|
|
30
|
+
const classes = $derived.by(() =>
|
|
31
|
+
tv({
|
|
32
|
+
slots: {
|
|
33
|
+
base: 'relative inline-flex items-center justify-center shrink-0',
|
|
34
|
+
chip: [
|
|
35
|
+
'absolute rounded-full ring ring-white flex items-center justify-center text-white font-medium whitespace-nowrap',
|
|
36
|
+
'-translate-y-1/2 translate-x-1/2 px-0.5'
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
variants: {
|
|
40
|
+
color: {
|
|
41
|
+
primary: {
|
|
42
|
+
chip: 'bg-primary'
|
|
43
|
+
},
|
|
44
|
+
secondary: {
|
|
45
|
+
chip: 'bg-secondary'
|
|
46
|
+
},
|
|
47
|
+
success: {
|
|
48
|
+
chip: 'bg-success'
|
|
49
|
+
},
|
|
50
|
+
info: {
|
|
51
|
+
chip: 'bg-info'
|
|
52
|
+
},
|
|
53
|
+
warning: {
|
|
54
|
+
chip: 'bg-warning'
|
|
55
|
+
},
|
|
56
|
+
error: {
|
|
57
|
+
chip: 'bg-error'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
position: {
|
|
61
|
+
'top-right': { chip: 'top-0 right-0' },
|
|
62
|
+
'bottom-right': { chip: 'bottom-0 right-0' },
|
|
63
|
+
'top-left': { chip: 'top-0 left-0' },
|
|
64
|
+
'bottom-left': { chip: 'bottom-0 left-0' }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
})({ color, position })
|
|
68
|
+
);
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<div class={classes.base({ class: [ui.base] })}>
|
|
72
|
+
{@render children()}
|
|
73
|
+
|
|
74
|
+
<span
|
|
75
|
+
class={classes.chip({ class: ui.chip })}
|
|
76
|
+
style:height="{size}px"
|
|
77
|
+
style:min-width="{size}px"
|
|
78
|
+
style:font-size="{size}px"
|
|
79
|
+
>
|
|
80
|
+
{text}
|
|
81
|
+
</span>
|
|
82
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PropColor } from '../types.js';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
export type ChipProps = {
|
|
5
|
+
children: Snippet;
|
|
6
|
+
text?: string;
|
|
7
|
+
color?: PropColor;
|
|
8
|
+
position?: 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
|
|
9
|
+
size?: number;
|
|
10
|
+
ui?: {
|
|
11
|
+
base?: ClassNameValue;
|
|
12
|
+
chip?: ClassNameValue;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
declare const Chip: import("svelte").Component<ChipProps, {}, "">;
|
|
16
|
+
type Chip = ReturnType<typeof Chip>;
|
|
17
|
+
export default Chip;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from './button.svelte';
|
|
2
|
+
export { default as Button } from './button.svelte';
|
|
3
|
+
export * from './badge.svelte';
|
|
4
|
+
export { default as Badge } from './badge.svelte';
|
|
5
|
+
export * from './alert.svelte';
|
|
6
|
+
export { default as Alert } from './alert.svelte';
|
|
7
|
+
export * from './banner.svelte';
|
|
8
|
+
export { default as Banner } from './banner.svelte';
|
|
9
|
+
export * from './progress.svelte';
|
|
10
|
+
export { default as Progress } from './progress.svelte';
|
|
11
|
+
export * from './card.svelte';
|
|
12
|
+
export { default as Card } from './card.svelte';
|
|
13
|
+
export * from './chip.svelte';
|
|
14
|
+
export { default as Chip } from './chip.svelte';
|
|
15
|
+
export * from './switch.svelte';
|
|
16
|
+
export { default as Switch } from './switch.svelte';
|
|
17
|
+
export * from './slider.svelte';
|
|
18
|
+
export { default as Slider } from './slider.svelte';
|
|
19
|
+
export * from './checkbox.svelte';
|
|
20
|
+
export { default as Checkbox } from './checkbox.svelte';
|
|
21
|
+
export * from './checkboxgroup.svelte';
|
|
22
|
+
export { default as CheckboxGroup } from './checkboxgroup.svelte';
|