uisv 0.0.21 → 0.0.23
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 +22 -22
- package/dist/components/accordion.svelte.d.ts +10 -10
- package/dist/components/alert.svelte +22 -28
- package/dist/components/alert.svelte.d.ts +5 -5
- package/dist/components/app.svelte +63 -0
- package/dist/components/app.svelte.d.ts +8 -0
- package/dist/components/badge.svelte +18 -23
- package/dist/components/badge.svelte.d.ts +3 -3
- package/dist/components/banner.svelte +18 -24
- package/dist/components/banner.svelte.d.ts +5 -5
- package/dist/components/breadcrumb.svelte +7 -8
- package/dist/components/breadcrumb.svelte.d.ts +5 -26
- package/dist/components/button.svelte +36 -44
- package/dist/components/button.svelte.d.ts +12 -11
- package/dist/components/calendar.svelte +6 -7
- package/dist/components/calendar.svelte.d.ts +3 -3
- package/dist/components/card.svelte +11 -12
- package/dist/components/card.svelte.d.ts +5 -5
- package/dist/components/checkbox-group.svelte +12 -13
- package/dist/components/checkbox-group.svelte.d.ts +4 -4
- package/dist/components/checkbox.svelte +42 -40
- package/dist/components/checkbox.svelte.d.ts +6 -6
- package/dist/components/chip.svelte +7 -8
- package/dist/components/chip.svelte.d.ts +3 -3
- package/dist/components/collapsible.svelte +7 -6
- package/dist/components/collapsible.svelte.d.ts +4 -4
- package/dist/components/color-picker.svelte +1 -1
- package/dist/components/h1.svelte +8 -7
- package/dist/components/h2.svelte +12 -11
- package/dist/components/h3.svelte +9 -8
- package/dist/components/h4.svelte +12 -11
- package/dist/components/h5.svelte +12 -11
- package/dist/components/h6.svelte +12 -11
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.js +7 -0
- package/dist/components/input-number.svelte +8 -9
- package/dist/components/input-number.svelte.d.ts +5 -5
- package/dist/components/input-time.svelte +11 -12
- package/dist/components/input-time.svelte.d.ts +6 -6
- package/dist/components/input.svelte +19 -29
- package/dist/components/input.svelte.d.ts +6 -6
- package/dist/components/kbd.svelte +6 -7
- package/dist/components/kbd.svelte.d.ts +2 -2
- package/dist/components/modal.svelte +189 -0
- package/dist/components/modal.svelte.d.ts +33 -0
- package/dist/components/p.svelte +3 -1
- package/dist/components/pin-input.svelte +10 -11
- package/dist/components/pin-input.svelte.d.ts +3 -3
- package/dist/components/placeholder.svelte +4 -4
- package/dist/components/popover.svelte +33 -61
- package/dist/components/popover.svelte.d.ts +8 -30
- package/dist/components/progress.svelte +62 -26
- package/dist/components/progress.svelte.d.ts +8 -7
- package/dist/components/select.svelte +49 -53
- package/dist/components/select.svelte.d.ts +22 -29
- package/dist/components/seperator.svelte +7 -8
- package/dist/components/seperator.svelte.d.ts +6 -6
- package/dist/components/slider.svelte +13 -14
- package/dist/components/slider.svelte.d.ts +4 -4
- package/dist/components/switch.svelte +19 -23
- package/dist/components/switch.svelte.d.ts +6 -6
- package/dist/components/tabs.svelte +19 -20
- package/dist/components/tabs.svelte.d.ts +7 -7
- package/dist/components/toast.svelte +173 -0
- package/dist/components/toast.svelte.d.ts +8 -0
- package/dist/components/toast.svelte.js +11 -0
- package/dist/components/tooltip.svelte +94 -0
- package/dist/components/tooltip.svelte.d.ts +24 -0
- package/dist/contexts.d.ts +54 -0
- package/dist/contexts.js +46 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mode.d.ts +89 -0
- package/dist/mode.js +1 -0
- package/dist/utilities/index.d.ts +5 -0
- package/dist/utilities/index.js +5 -0
- package/dist/utilities/isComponent.d.ts +7 -0
- package/dist/utilities/isComponent.js +10 -0
- package/dist/utilities/isSnippet.d.ts +7 -0
- package/dist/utilities/isSnippet.js +8 -0
- package/dist/utilities/useElementRects.svelte.d.ts +11 -0
- package/dist/{utilities.svelte.js → utilities/useElementRects.svelte.js} +0 -38
- package/dist/utilities/useRafFn.svelte.d.ts +43 -0
- package/dist/utilities/useRafFn.svelte.js +56 -0
- package/dist/utilities/useStyle.svelte.d.ts +8 -0
- package/dist/utilities/useStyle.svelte.js +21 -0
- package/dist/vite.js +30 -35
- package/package.json +39 -27
- package/dist/utilities.svelte.d.ts +0 -31
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call function on every `requestAnimationFrame`. With controls of pausing and resuming.
|
|
3
|
+
*
|
|
4
|
+
* @see https://vueuse.org/useRafFn
|
|
5
|
+
* @param fn
|
|
6
|
+
* @param options
|
|
7
|
+
*/
|
|
8
|
+
export function useRafFn(fn, options = {}) {
|
|
9
|
+
const { immediate = true, fpslimit = -1, once = false } = options;
|
|
10
|
+
let is_active = $state(false);
|
|
11
|
+
const interval_limit = $derived.by(() => {
|
|
12
|
+
return fpslimit ? 1000 / fpslimit : null;
|
|
13
|
+
});
|
|
14
|
+
let previousFrameTimestamp = 0;
|
|
15
|
+
let rafId = null;
|
|
16
|
+
function loop(timestamp) {
|
|
17
|
+
if (!is_active || !window)
|
|
18
|
+
return;
|
|
19
|
+
if (!previousFrameTimestamp)
|
|
20
|
+
previousFrameTimestamp = timestamp;
|
|
21
|
+
const delta = timestamp - previousFrameTimestamp;
|
|
22
|
+
if (interval_limit && delta < interval_limit) {
|
|
23
|
+
rafId = window.requestAnimationFrame(loop);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
previousFrameTimestamp = timestamp;
|
|
27
|
+
fn({ delta, timestamp });
|
|
28
|
+
if (once) {
|
|
29
|
+
is_active = false;
|
|
30
|
+
rafId = null;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
rafId = window.requestAnimationFrame(loop);
|
|
34
|
+
}
|
|
35
|
+
function resume() {
|
|
36
|
+
if (!is_active && window) {
|
|
37
|
+
is_active = true;
|
|
38
|
+
previousFrameTimestamp = 0;
|
|
39
|
+
rafId = window.requestAnimationFrame(loop);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function pause() {
|
|
43
|
+
is_active = false;
|
|
44
|
+
if (rafId != null && window) {
|
|
45
|
+
window.cancelAnimationFrame(rafId);
|
|
46
|
+
rafId = null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (immediate)
|
|
50
|
+
resume();
|
|
51
|
+
return {
|
|
52
|
+
is_active,
|
|
53
|
+
pause,
|
|
54
|
+
resume,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { extract } from 'runed';
|
|
2
|
+
let uisv_usestyle_id = 0;
|
|
3
|
+
/**
|
|
4
|
+
* Inject reactive style element in head.
|
|
5
|
+
* @param css string
|
|
6
|
+
*/
|
|
7
|
+
export function useStyle(css) {
|
|
8
|
+
const id = `uisv_styletag_${++uisv_usestyle_id}`;
|
|
9
|
+
let el = $state();
|
|
10
|
+
$effect(() => {
|
|
11
|
+
if (!el) {
|
|
12
|
+
el = (document.getElementById(id) || document.createElement('style'));
|
|
13
|
+
if (!el.isConnected) {
|
|
14
|
+
el.id = id;
|
|
15
|
+
document.head.appendChild(el);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
el.textContent = extract(css);
|
|
19
|
+
});
|
|
20
|
+
return { id };
|
|
21
|
+
}
|
package/dist/vite.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import uno_plugin from 'unocss/vite';
|
|
2
1
|
import { transformerVariantGroup, transformerCompileClass, transformerDirectives, presetWebFonts, presetIcons, presetWind4, } from 'unocss';
|
|
3
2
|
import {} from '@unocss/preset-web-fonts';
|
|
4
3
|
import { defu } from 'defu';
|
|
5
4
|
import { getColors } from 'theme-colors';
|
|
5
|
+
// import type { Plugin } from 'vite';
|
|
6
|
+
// import { resolve } from 'node:path';
|
|
7
|
+
import uno_plugin from 'unocss/vite';
|
|
6
8
|
export default (options = {}) => {
|
|
7
9
|
const _opts = defu(options, {
|
|
8
10
|
colors: {
|
|
@@ -38,17 +40,6 @@ export default (options = {}) => {
|
|
|
38
40
|
},
|
|
39
41
|
},
|
|
40
42
|
});
|
|
41
|
-
// const theme_plugin: Plugin = {
|
|
42
|
-
// name: 'vite-plugin-uisv',
|
|
43
|
-
// enforce: 'pre',
|
|
44
|
-
// async configResolved() {
|
|
45
|
-
// const path = resolve('node_modules/uisv/theme.js');
|
|
46
|
-
// console.log(await write(path, `export const button = {}`));
|
|
47
|
-
// },
|
|
48
|
-
// resolveId(source, importer, options) {
|
|
49
|
-
// if (source === '$build') return resolve('node_modules/uisv/theme.js');
|
|
50
|
-
// },
|
|
51
|
-
// };
|
|
52
43
|
return [
|
|
53
44
|
uno_plugin({
|
|
54
45
|
content: {
|
|
@@ -71,12 +62,12 @@ export default (options = {}) => {
|
|
|
71
62
|
if (typeof colors.surface !== 'object')
|
|
72
63
|
return '';
|
|
73
64
|
const variables = `
|
|
74
|
-
--colors-base: ${colors.surface['200']};
|
|
75
|
-
--colors-dimmed: ${colors.surface['500']};
|
|
76
|
-
--colors-muted: ${colors.surface['400']};
|
|
77
|
-
--colors-toned: ${colors.surface['300']};
|
|
78
|
-
--colors-highlighted: white;
|
|
79
|
-
--colors-inverted: ${colors.surface['900']};
|
|
65
|
+
--colors-label-base: ${colors.surface['200']};
|
|
66
|
+
--colors-label-dimmed: ${colors.surface['500']};
|
|
67
|
+
--colors-label-muted: ${colors.surface['400']};
|
|
68
|
+
--colors-label-toned: ${colors.surface['300']};
|
|
69
|
+
--colors-label-highlighted: white;
|
|
70
|
+
--colors-label-inverted: ${colors.surface['900']};
|
|
80
71
|
|
|
81
72
|
--colors-surface-base: ${colors.surface['900']};
|
|
82
73
|
--colors-surface-muted: ${colors.surface['800']};
|
|
@@ -86,7 +77,7 @@ export default (options = {}) => {
|
|
|
86
77
|
`;
|
|
87
78
|
return `
|
|
88
79
|
body {
|
|
89
|
-
background-color: var(--colors-inverted);
|
|
80
|
+
background-color: var(--colors-label-inverted);
|
|
90
81
|
}
|
|
91
82
|
|
|
92
83
|
.dark {
|
|
@@ -109,7 +100,7 @@ export default (options = {}) => {
|
|
|
109
100
|
transformers: [transformerVariantGroup(), transformerCompileClass(), transformerDirectives()],
|
|
110
101
|
extendTheme: (theme) => {
|
|
111
102
|
if (!('colors' in theme) || typeof theme.colors !== 'object')
|
|
112
|
-
|
|
103
|
+
return;
|
|
113
104
|
const colors = theme.colors;
|
|
114
105
|
for (const [color, value] of Object.entries(_opts.colors)) {
|
|
115
106
|
if (typeof value !== 'string') {
|
|
@@ -119,21 +110,25 @@ export default (options = {}) => {
|
|
|
119
110
|
const in_theme = colors[value];
|
|
120
111
|
colors[color] = in_theme ? in_theme : getColors(value);
|
|
121
112
|
}
|
|
122
|
-
if (typeof colors.surface
|
|
123
|
-
colors
|
|
124
|
-
|
|
125
|
-
colors
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
colors['
|
|
129
|
-
colors['
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
113
|
+
if (typeof colors.surface !== 'object')
|
|
114
|
+
colors.surface = {};
|
|
115
|
+
if (typeof colors.label === 'object')
|
|
116
|
+
colors.label = {};
|
|
117
|
+
colors.label = defu(colors.label, {
|
|
118
|
+
base: colors.surface['700'],
|
|
119
|
+
dimmed: colors.surface['400'],
|
|
120
|
+
muted: colors.surface['500'],
|
|
121
|
+
toned: colors.surface['600'],
|
|
122
|
+
highlighted: colors.surface['900'],
|
|
123
|
+
inverted: 'white',
|
|
124
|
+
});
|
|
125
|
+
colors['surface'] = defu(colors.surface, {
|
|
126
|
+
base: 'white',
|
|
127
|
+
muted: colors.surface['50'],
|
|
128
|
+
elevated: colors.surface['100'],
|
|
129
|
+
accented: colors.surface['200'],
|
|
130
|
+
inverted: colors.surface['900'],
|
|
131
|
+
});
|
|
137
132
|
if (theme.colors)
|
|
138
133
|
theme.colors = colors;
|
|
139
134
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uisv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"description": "ui library for the rest of us",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "ui-sv/uisv",
|
|
@@ -49,54 +49,66 @@
|
|
|
49
49
|
"types": "./dist/mode.d.ts",
|
|
50
50
|
"svelte": "./dist/mode.js",
|
|
51
51
|
"default": "./dist/mode.js"
|
|
52
|
+
},
|
|
53
|
+
"./contexts": {
|
|
54
|
+
"types": "./dist/contexts.d.ts",
|
|
55
|
+
"svelte": "./dist/contexts.js",
|
|
56
|
+
"default": "./dist/contexts.js"
|
|
52
57
|
}
|
|
53
58
|
},
|
|
54
59
|
"peerDependencies": {
|
|
55
60
|
"svelte": "^5.0.0"
|
|
56
61
|
},
|
|
57
62
|
"devDependencies": {
|
|
58
|
-
"@eslint/compat": "^2.0.
|
|
63
|
+
"@eslint/compat": "^2.0.5",
|
|
59
64
|
"@eslint/js": "^10.0.1",
|
|
60
|
-
"@iconify-json/lucide": "^1.2.
|
|
65
|
+
"@iconify-json/lucide": "^1.2.105",
|
|
61
66
|
"@sveltejs/adapter-auto": "^7.0.1",
|
|
62
|
-
"@sveltejs/kit": "^2.
|
|
67
|
+
"@sveltejs/kit": "^2.59.1",
|
|
63
68
|
"@sveltejs/package": "^2.5.7",
|
|
64
69
|
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
65
|
-
"@types/node": "^25.
|
|
66
|
-
"@vitest/browser": "^4.
|
|
67
|
-
"eslint": "^10.
|
|
70
|
+
"@types/node": "^25.6.1",
|
|
71
|
+
"@vitest/browser": "^4.1.5",
|
|
72
|
+
"eslint": "^10.3.0",
|
|
68
73
|
"eslint-config-prettier": "^10.1.8",
|
|
69
|
-
"eslint-plugin-svelte": "^3.
|
|
70
|
-
"globals": "^17.
|
|
71
|
-
"playwright": "^1.
|
|
72
|
-
"prettier": "^3.8.
|
|
73
|
-
"prettier-plugin-svelte": "^3.
|
|
74
|
-
"publint": "^0.3.
|
|
75
|
-
"svelte": "^5.
|
|
76
|
-
"svelte-check": "^4.4.
|
|
74
|
+
"eslint-plugin-svelte": "^3.17.1",
|
|
75
|
+
"globals": "^17.6.0",
|
|
76
|
+
"playwright": "^1.59.1",
|
|
77
|
+
"prettier": "^3.8.3",
|
|
78
|
+
"prettier-plugin-svelte": "^3.5.1",
|
|
79
|
+
"publint": "^0.3.19",
|
|
80
|
+
"svelte": "^5.55.5",
|
|
81
|
+
"svelte-check": "^4.4.8",
|
|
77
82
|
"typescript": "^5.9.3",
|
|
78
|
-
"typescript-eslint": "^8.
|
|
79
|
-
"vite": "^7.3.
|
|
80
|
-
"vitest": "^4.
|
|
81
|
-
"vitest-browser-svelte": "^2.
|
|
83
|
+
"typescript-eslint": "^8.59.2",
|
|
84
|
+
"vite": "^7.3.3",
|
|
85
|
+
"vitest": "^4.1.5",
|
|
86
|
+
"vitest-browser-svelte": "^2.1.1"
|
|
82
87
|
},
|
|
83
88
|
"dependencies": {
|
|
84
|
-
"@internationalized/date": "^3.
|
|
85
|
-
"@unocss/preset-web-fonts": "^66.6.
|
|
86
|
-
"bits-ui": "^2.
|
|
87
|
-
"colortranslator": "^
|
|
88
|
-
"defu": "^6.1.
|
|
89
|
+
"@internationalized/date": "^3.12.1",
|
|
90
|
+
"@unocss/preset-web-fonts": "^66.6.8",
|
|
91
|
+
"bits-ui": "^2.18.1",
|
|
92
|
+
"colortranslator": "^6.1.1",
|
|
93
|
+
"defu": "^6.1.7",
|
|
94
|
+
"devalue": "^5.8.0",
|
|
89
95
|
"maska": "^3.2.0",
|
|
96
|
+
"mlly": "^1.8.2",
|
|
90
97
|
"mode-watcher": "^1.1.0",
|
|
91
98
|
"runed": "^0.37.1",
|
|
92
99
|
"scule": "^1.3.0",
|
|
93
|
-
"
|
|
100
|
+
"svelte-sonner": "^1.1.1",
|
|
101
|
+
"svelte-toolbelt": "^0.10.6",
|
|
102
|
+
"tailwind-merge": "^3.6.0",
|
|
94
103
|
"tailwind-variants": "^3.2.2",
|
|
95
104
|
"theme-colors": "^0.1.0",
|
|
96
|
-
"unocss": "^66.6.
|
|
105
|
+
"unocss": "^66.6.8"
|
|
97
106
|
},
|
|
98
107
|
"keywords": [
|
|
99
108
|
"svelte",
|
|
100
109
|
"ui"
|
|
101
|
-
]
|
|
110
|
+
],
|
|
111
|
+
"patchedDependencies": {
|
|
112
|
+
"svelte-sonner@1.1.1": "patches/svelte-sonner@1.1.1.patch"
|
|
113
|
+
}
|
|
102
114
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
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 function 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 function 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[];
|
|
25
|
-
/**
|
|
26
|
-
* Inject reactive style element in head.
|
|
27
|
-
* @param css string
|
|
28
|
-
*/
|
|
29
|
-
export declare function useStyle(css: MaybeGetter<string>): {
|
|
30
|
-
id: string;
|
|
31
|
-
};
|