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,245 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { Tabs } from 'bits-ui';
|
|
3
|
+
import { isComponent, isSnippet, useElementRects, type PropColor } from '../index.js';
|
|
4
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
5
|
+
import { tv } from 'tailwind-variants';
|
|
6
|
+
import { type Component, type Snippet } from 'svelte';
|
|
7
|
+
import { ElementRect } from 'runed';
|
|
8
|
+
|
|
9
|
+
export type TabItem =
|
|
10
|
+
| string
|
|
11
|
+
| {
|
|
12
|
+
label: string;
|
|
13
|
+
icon?: string | Component | Snippet;
|
|
14
|
+
iconposition?: 'before' | 'after';
|
|
15
|
+
content?: string | Component;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type TabsProps = {
|
|
19
|
+
value?: number;
|
|
20
|
+
items: TabItem[];
|
|
21
|
+
color?: PropColor;
|
|
22
|
+
variant?: 'link' | 'pill';
|
|
23
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
orientation?: 'vertical' | 'horizontal';
|
|
26
|
+
ui?: {
|
|
27
|
+
root?: ClassNameValue;
|
|
28
|
+
item?: ClassNameValue;
|
|
29
|
+
list?: ClassNameValue;
|
|
30
|
+
content?: ClassNameValue;
|
|
31
|
+
icon?: ClassNameValue;
|
|
32
|
+
indicator?: ClassNameValue;
|
|
33
|
+
};
|
|
34
|
+
[k: `content_${string}`]: Snippet<[{ item: TabItem; value: number }]>;
|
|
35
|
+
};
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<script lang="ts">
|
|
39
|
+
let {
|
|
40
|
+
value = $bindable(0),
|
|
41
|
+
items = [],
|
|
42
|
+
color = 'primary',
|
|
43
|
+
variant = 'pill',
|
|
44
|
+
size = 'md',
|
|
45
|
+
disabled,
|
|
46
|
+
orientation = 'horizontal',
|
|
47
|
+
ui = {},
|
|
48
|
+
...rest
|
|
49
|
+
}: TabsProps = $props();
|
|
50
|
+
|
|
51
|
+
let container_el = $state<HTMLElement | null>(null);
|
|
52
|
+
const container_rect = new ElementRect(() => container_el);
|
|
53
|
+
let item_els = $state<HTMLElement[]>([]);
|
|
54
|
+
const rects = useElementRects(() => item_els);
|
|
55
|
+
const rect = $derived.by(() => {
|
|
56
|
+
const result = { w: 0, h: 0, l: 0, t: 0 };
|
|
57
|
+
|
|
58
|
+
if (rects[value]) {
|
|
59
|
+
result.w = rects[value].width;
|
|
60
|
+
result.l = rects[value].left - container_rect.left;
|
|
61
|
+
result.h = rects[value].height;
|
|
62
|
+
result.t = rects[value].top - container_rect.top;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return result;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const classes = $derived.by(() =>
|
|
69
|
+
tv({
|
|
70
|
+
slots: {
|
|
71
|
+
root: '',
|
|
72
|
+
list: 'flex relative p-1',
|
|
73
|
+
item: 'flex items-center justify-center text-muted data-[state="inactive"]:hover:(text-highlighted) font-medium z-1 transition-all',
|
|
74
|
+
icon: '',
|
|
75
|
+
content: 'mt-2',
|
|
76
|
+
indicator: 'absolute z-0 transition-all duration-200 rounded-md w---width',
|
|
77
|
+
},
|
|
78
|
+
variants: {
|
|
79
|
+
variant: {
|
|
80
|
+
pill: {
|
|
81
|
+
list: 'bg-surface-elevated rounded-lg',
|
|
82
|
+
item: 'flex-1 data-[state="active"]:(text-inverted)',
|
|
83
|
+
trigger: 'flex-1',
|
|
84
|
+
indicator: 'rounded-md shadow-xs',
|
|
85
|
+
},
|
|
86
|
+
link: {
|
|
87
|
+
list: 'border-b border-surface-accented',
|
|
88
|
+
item: '',
|
|
89
|
+
indicator: 'rounded-full -bottom-px',
|
|
90
|
+
trigger: 'focus:outline-none',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
color: {
|
|
94
|
+
primary: {
|
|
95
|
+
item: 'data-[variant="link"]:data-[state="active"]:text-primary-500',
|
|
96
|
+
indicator: 'bg-primary-500',
|
|
97
|
+
},
|
|
98
|
+
surface: {
|
|
99
|
+
item: 'data-[variant="link"]:data-[state="active"]:text-surface-500',
|
|
100
|
+
indicator: 'bg-surface-900',
|
|
101
|
+
},
|
|
102
|
+
info: {
|
|
103
|
+
item: 'data-[variant="link"]:data-[state="active"]:text-info-500',
|
|
104
|
+
indicator: 'bg-info-500',
|
|
105
|
+
},
|
|
106
|
+
success: {
|
|
107
|
+
item: 'data-[variant="link"]:data-[state="active"]:text-success-500',
|
|
108
|
+
indicator: 'bg-success-500',
|
|
109
|
+
},
|
|
110
|
+
warning: {
|
|
111
|
+
item: 'data-[variant="link"]:data-[state="active"]:text-warning-500',
|
|
112
|
+
indicator: 'bg-warning-500',
|
|
113
|
+
},
|
|
114
|
+
error: {
|
|
115
|
+
item: 'data-[variant="link"]:data-[state="active"]:text-error-500',
|
|
116
|
+
indicator: 'bg-error-500',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
size: {
|
|
120
|
+
xs: {
|
|
121
|
+
list: 'text-xs',
|
|
122
|
+
item: 'min-h-6 gap-1 px-2',
|
|
123
|
+
icon: 'size-4',
|
|
124
|
+
},
|
|
125
|
+
sm: {
|
|
126
|
+
list: 'text-xs',
|
|
127
|
+
item: 'min-h-7 gap-1 px-3',
|
|
128
|
+
icon: 'size-4',
|
|
129
|
+
},
|
|
130
|
+
md: {
|
|
131
|
+
list: 'text-sm',
|
|
132
|
+
item: 'min-h-8 gap-2 px-4',
|
|
133
|
+
icon: 'size-5',
|
|
134
|
+
},
|
|
135
|
+
lg: {
|
|
136
|
+
list: 'text-sm',
|
|
137
|
+
item: 'min-h-9 gap-2 px-4',
|
|
138
|
+
icon: 'size-5',
|
|
139
|
+
},
|
|
140
|
+
xl: {
|
|
141
|
+
list: '',
|
|
142
|
+
item: 'min-h-10 gap-4 px-5',
|
|
143
|
+
icon: 'size-6',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
orientation: {
|
|
147
|
+
horizontal: {
|
|
148
|
+
indicator: 'h-px left---left',
|
|
149
|
+
},
|
|
150
|
+
vertical: {
|
|
151
|
+
root: '',
|
|
152
|
+
list: 'flex-col',
|
|
153
|
+
indicator: 'h-(--height) top-(--top)',
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
compoundVariants: [
|
|
158
|
+
{ size: 'xs', variant: 'pill', class: { indicator: 'h-6' } },
|
|
159
|
+
{ size: 'sm', variant: 'pill', class: { indicator: 'h-7' } },
|
|
160
|
+
{ size: 'md', variant: 'pill', class: { indicator: 'h-8' } },
|
|
161
|
+
{ size: 'lg', variant: 'pill', class: { indicator: 'h-9' } },
|
|
162
|
+
{ size: 'xl', variant: 'pill', class: { indicator: 'h-10' } },
|
|
163
|
+
{
|
|
164
|
+
size: 'xs',
|
|
165
|
+
variant: 'link',
|
|
166
|
+
orientation: 'vertical',
|
|
167
|
+
class: { indicator: 'h-6' },
|
|
168
|
+
},
|
|
169
|
+
{ size: 'sm', variant: 'link', orientation: 'vertical', class: { indicator: 'h-7' } },
|
|
170
|
+
{ size: 'md', variant: 'link', orientation: 'vertical', class: { indicator: 'h-8' } },
|
|
171
|
+
{ size: 'lg', variant: 'link', orientation: 'vertical', class: { indicator: 'h-9' } },
|
|
172
|
+
{ size: 'xl', variant: 'link', orientation: 'vertical', class: { indicator: 'h-10' } },
|
|
173
|
+
{
|
|
174
|
+
orientation: 'vertical',
|
|
175
|
+
variant: 'link',
|
|
176
|
+
class: { list: 'border-b-0 border-l', indicator: 'w-px -left-px' },
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
})({ color, size, orientation, variant }),
|
|
180
|
+
);
|
|
181
|
+
</script>
|
|
182
|
+
|
|
183
|
+
<Tabs.Root
|
|
184
|
+
{disabled}
|
|
185
|
+
bind:value={() => value.toString(), (v) => (value = parseInt(v))}
|
|
186
|
+
class={classes.root({ class: ui.root })}
|
|
187
|
+
{orientation}
|
|
188
|
+
>
|
|
189
|
+
<Tabs.List bind:ref={container_el} class={classes.list({ class: ui.list })}>
|
|
190
|
+
{#each items as item, idx (idx)}
|
|
191
|
+
{@const label = typeof item === 'string' ? item : item.label}
|
|
192
|
+
|
|
193
|
+
<Tabs.Trigger
|
|
194
|
+
bind:ref={
|
|
195
|
+
() => {
|
|
196
|
+
if (item_els[idx]) return item_els[idx];
|
|
197
|
+
if (typeof document !== 'undefined') return document.createElement('div');
|
|
198
|
+
},
|
|
199
|
+
(v) => {
|
|
200
|
+
if (v) item_els[idx] = v;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
value={idx.toString()}
|
|
204
|
+
class={classes.item({ class: ui.item })}
|
|
205
|
+
data-variant={variant}
|
|
206
|
+
>
|
|
207
|
+
{@render RenderIcon(typeof item === 'string' ? undefined : item.icon)}
|
|
208
|
+
|
|
209
|
+
{label}
|
|
210
|
+
</Tabs.Trigger>
|
|
211
|
+
{/each}
|
|
212
|
+
|
|
213
|
+
<span
|
|
214
|
+
class={classes.indicator({ class: ui.indicator })}
|
|
215
|
+
style:--width="{rect.w}px"
|
|
216
|
+
style:--left="{rect.l}px"
|
|
217
|
+
style:--height="{rect.w}px"
|
|
218
|
+
style:--top="{rect.t}px"
|
|
219
|
+
></span>
|
|
220
|
+
</Tabs.List>
|
|
221
|
+
{#each items as item, idx (idx)}
|
|
222
|
+
{#if typeof item === 'object' && item.content}
|
|
223
|
+
{@const Content = item.content}
|
|
224
|
+
<Tabs.Content value={idx.toString()} class={classes.content({ class: ui.content })}>
|
|
225
|
+
{#if `content_${idx}` in rest}
|
|
226
|
+
{@render rest[`content_${idx}`]({ item, value: idx })}
|
|
227
|
+
{:else if typeof Content === 'string'}
|
|
228
|
+
{Content}
|
|
229
|
+
{:else if isComponent(Content)}
|
|
230
|
+
<Content />
|
|
231
|
+
{/if}
|
|
232
|
+
</Tabs.Content>
|
|
233
|
+
{/if}
|
|
234
|
+
{/each}
|
|
235
|
+
</Tabs.Root>
|
|
236
|
+
|
|
237
|
+
{#snippet RenderIcon(IconProp?: string | Component | Snippet)}
|
|
238
|
+
{#if isSnippet(IconProp)}
|
|
239
|
+
{@render IconProp()}
|
|
240
|
+
{:else if isComponent(IconProp)}
|
|
241
|
+
<IconProp class={classes.icon({ class: ui.icon })} />
|
|
242
|
+
{:else if typeof IconProp === 'string'}
|
|
243
|
+
<div class={classes.icon({ class: [IconProp, ui.icon] })}></div>
|
|
244
|
+
{/if}
|
|
245
|
+
{/snippet}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Tabs } from 'bits-ui';
|
|
2
|
+
import { type PropColor } from '../index.js';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
import { type Component, type Snippet } from 'svelte';
|
|
5
|
+
export type TabItem = string | {
|
|
6
|
+
label: string;
|
|
7
|
+
icon?: string | Component | Snippet;
|
|
8
|
+
iconposition?: 'before' | 'after';
|
|
9
|
+
content?: string | Component;
|
|
10
|
+
};
|
|
11
|
+
export type TabsProps = {
|
|
12
|
+
value?: number;
|
|
13
|
+
items: TabItem[];
|
|
14
|
+
color?: PropColor;
|
|
15
|
+
variant?: 'link' | 'pill';
|
|
16
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
orientation?: 'vertical' | 'horizontal';
|
|
19
|
+
ui?: {
|
|
20
|
+
root?: ClassNameValue;
|
|
21
|
+
item?: ClassNameValue;
|
|
22
|
+
list?: ClassNameValue;
|
|
23
|
+
content?: ClassNameValue;
|
|
24
|
+
icon?: ClassNameValue;
|
|
25
|
+
indicator?: ClassNameValue;
|
|
26
|
+
};
|
|
27
|
+
[k: `content_${string}`]: Snippet<[{
|
|
28
|
+
item: TabItem;
|
|
29
|
+
value: number;
|
|
30
|
+
}]>;
|
|
31
|
+
};
|
|
32
|
+
declare const Tabs: Component<TabsProps, {}, "value">;
|
|
33
|
+
type Tabs = ReturnType<typeof Tabs>;
|
|
34
|
+
export default Tabs;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Component, Snippet } from 'svelte';
|
|
2
|
+
import { type MaybeGetter, type ElementSizeOptions } from 'runed';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a value is a Svelte component
|
|
5
|
+
* @param v - The value to check
|
|
6
|
+
* @returns true if the value is a component, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export declare const isComponent: (v: unknown) => v is Component;
|
|
9
|
+
/**
|
|
10
|
+
* Checks if a value is a Svelte snippet
|
|
11
|
+
* @param v - The value to check
|
|
12
|
+
* @returns true if the value is a snippet, false otherwise
|
|
13
|
+
*/
|
|
14
|
+
export declare const isSnippet: (v: unknown) => v is Snippet;
|
|
15
|
+
/**
|
|
16
|
+
* Returns a reactive value holding the dom rect of `node`s.
|
|
17
|
+
*
|
|
18
|
+
* Accepts an `options` object with the following properties:
|
|
19
|
+
* - `initialSize`: The initial size of the element. Defaults to `{ width: 0, height: 0 }`.
|
|
20
|
+
* - `box`: The box model to use. Can be either `"content-box"` or `"border-box"`. Defaults to `"border-box"`.
|
|
21
|
+
*
|
|
22
|
+
* @returns an array of dom rects.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useElementRects(nodes: MaybeGetter<HTMLElement[]>, options?: ElementSizeOptions): DOMRect[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { extract, useMutationObserver, useResizeObserver, } from 'runed';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a value is a Svelte component
|
|
4
|
+
* @param v - The value to check
|
|
5
|
+
* @returns true if the value is a component, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export const isComponent = (v) => {
|
|
8
|
+
return typeof v === 'function' || (typeof v === 'object' && v !== null && !('$$render' in v));
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a value is a Svelte snippet
|
|
12
|
+
* @param v - The value to check
|
|
13
|
+
* @returns true if the value is a snippet, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
export const isSnippet = (v) => {
|
|
16
|
+
return typeof v === 'object' && v !== null && '$$render' in v;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Returns a reactive value holding the dom rect of `node`s.
|
|
20
|
+
*
|
|
21
|
+
* Accepts an `options` object with the following properties:
|
|
22
|
+
* - `initialSize`: The initial size of the element. Defaults to `{ width: 0, height: 0 }`.
|
|
23
|
+
* - `box`: The box model to use. Can be either `"content-box"` or `"border-box"`. Defaults to `"border-box"`.
|
|
24
|
+
*
|
|
25
|
+
* @returns an array of dom rects.
|
|
26
|
+
*/
|
|
27
|
+
export function useElementRects(nodes, options = {}) {
|
|
28
|
+
const rects = $state(extract(nodes).map((v) => v.getBoundingClientRect()));
|
|
29
|
+
const elements = $derived(extract(nodes));
|
|
30
|
+
const update = () => {
|
|
31
|
+
if (!elements || elements.length === 0)
|
|
32
|
+
return;
|
|
33
|
+
elements.forEach((el, idx) => (rects[idx] = el.getBoundingClientRect()));
|
|
34
|
+
};
|
|
35
|
+
$effect(() => {
|
|
36
|
+
const stops = [];
|
|
37
|
+
elements.forEach((v) => {
|
|
38
|
+
stops.push(useResizeObserver(() => v, update, { window: options.window }).stop);
|
|
39
|
+
stops.push(useMutationObserver(() => v, update, {
|
|
40
|
+
attributeFilter: ['style', 'class'],
|
|
41
|
+
window: options.window,
|
|
42
|
+
}).stop);
|
|
43
|
+
});
|
|
44
|
+
return () => stops.forEach((v) => v());
|
|
45
|
+
});
|
|
46
|
+
return rects;
|
|
47
|
+
}
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { presetIcons } from 'unocss';
|
|
2
|
+
import { type WebFontsOptions } from '@unocss/preset-web-fonts';
|
|
3
|
+
import type { PropColor } from './index.js';
|
|
4
|
+
import type { Plugin } from 'vite';
|
|
5
|
+
export type Colors = Record<string, string | Record<string, string>>;
|
|
6
|
+
export type NestedObject<K extends string, V> = {
|
|
7
|
+
[key in K]: NestedObject<K, V> | V;
|
|
8
|
+
};
|
|
9
|
+
export type PluginOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* Colors as UnoCSS color name, hex color, or UnoCSS theme color object
|
|
12
|
+
* @example
|
|
13
|
+
* {
|
|
14
|
+
* primary: 'orange',
|
|
15
|
+
* surface: 'neutral',
|
|
16
|
+
* info: '#00F',
|
|
17
|
+
* success: '#0F0',
|
|
18
|
+
* warning: 'FF0',
|
|
19
|
+
* error: {
|
|
20
|
+
* 50: '#fef2f2';
|
|
21
|
+
* 100: '#fee2e2';
|
|
22
|
+
* 200: '#fecaca';
|
|
23
|
+
* 300: '#fca5a5';
|
|
24
|
+
* 400: '#f87171';
|
|
25
|
+
* 500: '#ef4444';
|
|
26
|
+
* 600: '#dc2626';
|
|
27
|
+
* 700: '#b91c1c';
|
|
28
|
+
* 800: '#991b1b';
|
|
29
|
+
* 900: '#7f1d1d';
|
|
30
|
+
* 950: '#450a0a';
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
*/
|
|
34
|
+
colors?: Partial<Record<PropColor, string | Record<number, string>>>;
|
|
35
|
+
/**
|
|
36
|
+
* UnoCSS theme object for shared configuration between rules
|
|
37
|
+
*/
|
|
38
|
+
theme?: object;
|
|
39
|
+
/**
|
|
40
|
+
* Options for the UnoCSS web fonts preset
|
|
41
|
+
*/
|
|
42
|
+
fonts?: WebFontsOptions;
|
|
43
|
+
/**
|
|
44
|
+
* Corner radius for every* component
|
|
45
|
+
*/
|
|
46
|
+
radius?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Options for the UnoCSS icon preset
|
|
49
|
+
*/
|
|
50
|
+
icons?: Parameters<typeof presetIcons>[0];
|
|
51
|
+
};
|
|
52
|
+
export declare function uisv(options: PluginOptions): Plugin<any>[][];
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import uno_plugin from 'unocss/vite';
|
|
2
|
+
import { transformerVariantGroup, transformerCompileClass, transformerDirectives, presetWebFonts, presetIcons, presetWind4, definePreset, } from 'unocss';
|
|
3
|
+
import {} from '@unocss/preset-web-fonts';
|
|
4
|
+
import { defu } from 'defu';
|
|
5
|
+
import { getColors } from 'theme-colors';
|
|
6
|
+
import { dir, exists, write } from 'files';
|
|
7
|
+
import { resolve } from 'node:path';
|
|
8
|
+
export function uisv(options) {
|
|
9
|
+
const _opts = defu(options, {
|
|
10
|
+
colors: {
|
|
11
|
+
primary: 'orange',
|
|
12
|
+
surface: 'neutral',
|
|
13
|
+
info: 'blue',
|
|
14
|
+
success: 'green',
|
|
15
|
+
warning: 'yellow',
|
|
16
|
+
error: 'red',
|
|
17
|
+
},
|
|
18
|
+
fonts: {
|
|
19
|
+
fonts: {
|
|
20
|
+
sans: 'Public Sans:400,500,600',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
icons: {},
|
|
24
|
+
theme: {
|
|
25
|
+
radius: {
|
|
26
|
+
base: `${options.radius || 0.375}rem`,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const theme_plugin = {
|
|
31
|
+
name: 'vite-plugin-uisv',
|
|
32
|
+
enforce: 'pre',
|
|
33
|
+
async configResolved() {
|
|
34
|
+
const path = resolve('node_modules/uisv/theme.js');
|
|
35
|
+
console.log(await write(path, `export const button = {}`));
|
|
36
|
+
},
|
|
37
|
+
resolveId(source, importer, options) {
|
|
38
|
+
if (source === '$build')
|
|
39
|
+
return resolve('node_modules/uisv/theme.js');
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
return [
|
|
43
|
+
uno_plugin({
|
|
44
|
+
content: {
|
|
45
|
+
pipeline: {
|
|
46
|
+
include: [
|
|
47
|
+
// the default
|
|
48
|
+
/\.(vue|svelte|[jt]sx|vine.ts|mdx?|astro|elm|php|phtml|marko|html)($|\?)/,
|
|
49
|
+
// include js/ts files
|
|
50
|
+
'src/**/*.{js,ts}',
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
theme: _opts.theme,
|
|
55
|
+
preflights: [
|
|
56
|
+
{
|
|
57
|
+
getCSS({ theme }) {
|
|
58
|
+
if (!('colors' in theme) || typeof theme.colors !== 'object')
|
|
59
|
+
return;
|
|
60
|
+
const colors = theme.colors;
|
|
61
|
+
if (typeof colors.surface !== 'object')
|
|
62
|
+
return '';
|
|
63
|
+
const variables = `
|
|
64
|
+
--colors-DEFAULT: ${colors.surface['200']};
|
|
65
|
+
--colors-dimmed: ${colors.surface['500']};
|
|
66
|
+
--colors-muted: ${colors.surface['400']};
|
|
67
|
+
--colors-toned: ${colors.surface['300']};
|
|
68
|
+
--colors-highlighted: white;
|
|
69
|
+
--colors-inverted: ${colors.surface['900']};
|
|
70
|
+
|
|
71
|
+
--colors-surface-DEFAULT: ${colors.surface['900']};
|
|
72
|
+
--colors-surface-muted: ${colors.surface['800']};
|
|
73
|
+
--colors-surface-elevated: ${colors.surface['800']};
|
|
74
|
+
--colors-surface-accented: ${colors.surface['700']};
|
|
75
|
+
--colors-surface-inverted: white;
|
|
76
|
+
`;
|
|
77
|
+
return `
|
|
78
|
+
body {
|
|
79
|
+
background-color: var(--colors-inverted);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.dark {
|
|
83
|
+
${variables}
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
presets: [
|
|
90
|
+
presetWind4({
|
|
91
|
+
dark: 'media',
|
|
92
|
+
preflights: {
|
|
93
|
+
reset: true,
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
presetWebFonts(_opts.fonts),
|
|
97
|
+
presetIcons(_opts.icons),
|
|
98
|
+
],
|
|
99
|
+
transformers: [transformerVariantGroup(), transformerCompileClass(), transformerDirectives()],
|
|
100
|
+
extendTheme: (theme) => {
|
|
101
|
+
if (!('colors' in theme) || typeof theme.colors !== 'object')
|
|
102
|
+
theme.colors = {};
|
|
103
|
+
const colors = theme.colors;
|
|
104
|
+
for (const [color, value] of Object.entries(_opts.colors)) {
|
|
105
|
+
if (typeof value !== 'string') {
|
|
106
|
+
colors[color] = value;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const in_theme = colors[value];
|
|
110
|
+
colors[color] = in_theme ? in_theme : getColors(value);
|
|
111
|
+
}
|
|
112
|
+
if (typeof colors.surface === 'object') {
|
|
113
|
+
colors['DEFAULT'] = colors.surface['700'];
|
|
114
|
+
colors['dimmed'] = colors.surface['400'];
|
|
115
|
+
colors['muted'] = colors.surface['500'];
|
|
116
|
+
colors['toned'] = colors.surface['600'];
|
|
117
|
+
colors['highlighted'] = colors.surface['900'];
|
|
118
|
+
colors['inverted'] = 'white';
|
|
119
|
+
colors['surface'] = defu(colors.surface, {
|
|
120
|
+
DEFAULT: 'white',
|
|
121
|
+
muted: colors.surface['50'],
|
|
122
|
+
elevated: colors.surface['100'],
|
|
123
|
+
accented: colors.surface['200'],
|
|
124
|
+
inverted: colors.surface['900'],
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (theme.colors)
|
|
128
|
+
theme.colors = colors;
|
|
129
|
+
},
|
|
130
|
+
}),
|
|
131
|
+
];
|
|
132
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uisv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "ui library for the rest of us",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "ui-sv/uisv",
|
|
7
7
|
"homepage": "https://uisv.pages.dev",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"dev": "vite dev",
|
|
10
|
-
"build": "vite build &&
|
|
10
|
+
"build": "vite build && npm run prepack",
|
|
11
11
|
"preview": "vite preview",
|
|
12
12
|
"prepare": "svelte-kit sync || echo ''",
|
|
13
13
|
"prepack": "svelte-kit sync && svelte-package && publint",
|
|
@@ -32,74 +32,71 @@
|
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
34
34
|
"types": "./dist/index.d.ts",
|
|
35
|
-
"svelte": "./dist/index.js"
|
|
35
|
+
"svelte": "./dist/index.js",
|
|
36
|
+
"default": "./dist/index.js"
|
|
36
37
|
},
|
|
37
38
|
"./vite": {
|
|
38
39
|
"types": "./dist/vite.d.ts",
|
|
39
|
-
"svelte": "./dist/vite.js"
|
|
40
|
+
"svelte": "./dist/vite.js",
|
|
41
|
+
"default": "./dist/vite.js"
|
|
40
42
|
}
|
|
41
43
|
},
|
|
42
44
|
"peerDependencies": {
|
|
43
45
|
"svelte": "^5.0.0"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
46
|
-
"@eslint/compat": "^2.0.
|
|
47
|
-
"@eslint/js": "^
|
|
48
|
+
"@eslint/compat": "^2.0.2",
|
|
49
|
+
"@eslint/js": "^10.0.1",
|
|
48
50
|
"@iconify-json/logos": "^1.2.10",
|
|
49
|
-
"@iconify-json/lucide": "^1.2.
|
|
51
|
+
"@iconify-json/lucide": "^1.2.90",
|
|
50
52
|
"@iconify-json/solar": "^1.2.5",
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@sveltejs/
|
|
54
|
-
"@sveltejs/kit": "^2.49.4",
|
|
53
|
+
"@internationalized/date": "^3.11.0",
|
|
54
|
+
"@sveltejs/adapter-auto": "^7.0.1",
|
|
55
|
+
"@sveltejs/kit": "^2.52.0",
|
|
55
56
|
"@sveltejs/package": "^2.5.7",
|
|
56
57
|
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
57
58
|
"@tailwindcss/vite": "^4.1.18",
|
|
58
|
-
"@types/node": "^25.
|
|
59
|
-
"@unocss/preset-web-fonts": "^66.
|
|
59
|
+
"@types/node": "^25.2.3",
|
|
60
|
+
"@unocss/preset-web-fonts": "^66.6.0",
|
|
60
61
|
"@unocss/reset": "^66.6.0",
|
|
61
|
-
"@vitest/browser": "^4.0.
|
|
62
|
-
"bits-ui": "^2.15.
|
|
62
|
+
"@vitest/browser": "^4.0.18",
|
|
63
|
+
"bits-ui": "^2.15.5",
|
|
63
64
|
"carta-md": "^4.11.1",
|
|
64
|
-
"colortranslator": "^5.0.0",
|
|
65
65
|
"defu": "^6.1.4",
|
|
66
66
|
"doc-path": "^4.1.3",
|
|
67
|
-
"eslint": "^
|
|
67
|
+
"eslint": "^10.0.0",
|
|
68
68
|
"eslint-config-prettier": "^10.1.8",
|
|
69
|
-
"eslint-plugin-svelte": "^3.
|
|
69
|
+
"eslint-plugin-svelte": "^3.15.0",
|
|
70
70
|
"files": "^3.0.2",
|
|
71
|
-
"globals": "^
|
|
72
|
-
"maska": "^3.2.0",
|
|
73
|
-
"mdsvex": "^0.12.6",
|
|
71
|
+
"globals": "^17.3.0",
|
|
74
72
|
"mode-watcher": "^1.1.0",
|
|
75
|
-
"playwright": "^1.
|
|
76
|
-
"prettier": "^3.
|
|
73
|
+
"playwright": "^1.58.2",
|
|
74
|
+
"prettier": "^3.8.1",
|
|
77
75
|
"prettier-plugin-svelte": "^3.4.1",
|
|
78
|
-
"publint": "^0.3.
|
|
76
|
+
"publint": "^0.3.17",
|
|
79
77
|
"runed": "^0.37.1",
|
|
80
78
|
"scule": "^1.3.0",
|
|
81
|
-
"svelte": "^5.
|
|
82
|
-
"svelte-check": "^4.
|
|
79
|
+
"svelte": "^5.51.2",
|
|
80
|
+
"svelte-check": "^4.4.0",
|
|
83
81
|
"svelte-exmarkdown": "^5.0.2",
|
|
84
|
-
"tailwind-merge": "^3.4.
|
|
82
|
+
"tailwind-merge": "^3.4.1",
|
|
85
83
|
"tailwind-variants": "^3.2.2",
|
|
86
84
|
"theme-colors": "^0.1.0",
|
|
87
85
|
"typescript": "^5.9.3",
|
|
88
|
-
"typescript-eslint": "^8.
|
|
89
|
-
"unocss": "^66.
|
|
86
|
+
"typescript-eslint": "^8.55.0",
|
|
87
|
+
"unocss": "^66.6.0",
|
|
90
88
|
"unocss-preset-theme": "^0.14.1",
|
|
91
|
-
"unplugin-icons": "^
|
|
89
|
+
"unplugin-icons": "^23.0.1",
|
|
92
90
|
"vite": "^7.3.1",
|
|
93
|
-
"vitest": "^4.0.
|
|
94
|
-
"vitest-browser-svelte": "^2.0.
|
|
91
|
+
"vitest": "^4.0.18",
|
|
92
|
+
"vitest-browser-svelte": "^2.0.2"
|
|
93
|
+
},
|
|
94
|
+
"dependencies": {
|
|
95
|
+
"colortranslator": "^5.0.0",
|
|
96
|
+
"maska": "^3.2.0"
|
|
95
97
|
},
|
|
96
98
|
"keywords": [
|
|
97
99
|
"svelte",
|
|
98
100
|
"ui"
|
|
99
|
-
]
|
|
100
|
-
"pnpm": {
|
|
101
|
-
"onlyBuiltDependencies": [
|
|
102
|
-
"esbuild"
|
|
103
|
-
]
|
|
104
|
-
}
|
|
101
|
+
]
|
|
105
102
|
}
|