kitzo 2.5.5 → 3.1.0
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 +24 -20
- package/dist/index.d.ts +22 -6
- package/dist/index.js +6 -4
- package/dist/react/hooks/useOverlay.js +43 -0
- package/package.json +3 -12
package/README.md
CHANGED
|
@@ -1,40 +1,44 @@
|
|
|
1
1
|
# Kitzo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A lightweight, production-ready React micro-utility library providing essential components, hooks, and functions for modern web applications.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
### Installation
|
|
5
|
+
## Installation
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
8
|
npm install kitzo
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
## Core Features
|
|
12
|
+
|
|
13
|
+
### React Components
|
|
14
|
+
|
|
15
|
+
Essential, accessible, and performance-optimized UI components:
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
- **Toast**: A flexible notification system with support for custom positions, animations, and interaction patterns.
|
|
18
|
+
- **Tooltip**: A contextual information component with smart positioning and customizable delay and animations.
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
### React Hooks
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
- **Tooltip** — Smart-positioned contextual labels.
|
|
22
|
+
A collection of hooks to simplify common React application logic:
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
- **useDebounce**: Delays value updates until a specified time has passed.
|
|
25
|
+
- **useDebouncedCallback**: Returns a debounced version of a callback function.
|
|
26
|
+
- **useThrottle**: Limits the execution rate of a frequently changing value.
|
|
27
|
+
- **useLocalStorage**: Synchronizes state with browser local storage.
|
|
28
|
+
- **useWindowSize**: Provides real-time window dimensions.
|
|
29
|
+
- **useCopy**: Simplifies clipboard operations within components.
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
- **useWindowSize** — Real-time viewport dimensions.
|
|
26
|
-
- **useCopy** — Simple "copy to clipboard" functionality.
|
|
27
|
-
- **useThrottle** — Limits how often a value can change within a specified time interval.
|
|
31
|
+
### Utility Functions
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+
- **copy**: A standalone function for programmatically interacting with the system clipboard.
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
## Documentation
|
|
32
36
|
|
|
33
|
-
For usage guides and live
|
|
37
|
+
For full usage guides, API references, and live demonstrations, visit the documentation site:
|
|
34
38
|
[https://kitzo.vercel.app](https://kitzo.vercel.app)
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
Check out the [root project](https://github.com/riyad-96/kitzo) for project-wide information.
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
## License
|
|
39
43
|
|
|
40
|
-
MIT
|
|
44
|
+
This project is licensed under the MIT License.
|
package/dist/index.d.ts
CHANGED
|
@@ -188,11 +188,27 @@ export declare function useDebouncedCallback<Args extends unknown[]>(callback: (
|
|
|
188
188
|
*/
|
|
189
189
|
export declare function useLocalStorage<T>(key: string, initialValue: T, options?: Options_2<T>): [T, Dispatch<SetStateAction<T>>];
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
/**
|
|
192
|
+
* A React hook that manages UI overlays (modal, drawer, popover, etc.)
|
|
193
|
+
* and synchronizes them with the browser navigation history.
|
|
194
|
+
*
|
|
195
|
+
* @param id - A stable unique identifier for the overlay.
|
|
196
|
+
* Required to maintain history state across navigations.
|
|
197
|
+
* Recommendation: Use page-scoped names like 'login-page:otp-modal'.
|
|
198
|
+
*
|
|
199
|
+
* @returns {isOpen: boolean, open: () => void, close: () => void}
|
|
200
|
+
*/
|
|
201
|
+
export declare function useOverlay(id: string): {
|
|
202
|
+
isOpen: boolean;
|
|
203
|
+
open: () => void;
|
|
204
|
+
close: () => void;
|
|
205
|
+
};
|
|
192
206
|
|
|
193
|
-
export declare function
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
207
|
+
export declare function useThrottle<T>(value: T, delay?: number): T;
|
|
208
|
+
|
|
209
|
+
export declare function useWindowSize(updateDelay?: number): {
|
|
210
|
+
screenWidth: number;
|
|
211
|
+
screenHeight: number;
|
|
212
|
+
};
|
|
197
213
|
|
|
198
|
-
export { }
|
|
214
|
+
export { }
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,9 @@ import { useCopy as s } from "./react/hooks/useCopy.js";
|
|
|
5
5
|
import { useDebounce as a } from "./react/hooks/useDebounce.js";
|
|
6
6
|
import { useDebouncedCallback as c } from "./react/hooks/useDebouncedCallback.js";
|
|
7
7
|
import { useLocalStorage as i } from "./react/hooks/useLocalStorage.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { useOverlay as T } from "./react/hooks/useOverlay.js";
|
|
9
|
+
import { useThrottle as y } from "./react/hooks/useThrottle.js";
|
|
10
|
+
import { useWindowSize as D } from "./react/hooks/useWindowSize.js";
|
|
10
11
|
export {
|
|
11
12
|
r as Toaster,
|
|
12
13
|
p as Tooltip,
|
|
@@ -15,6 +16,7 @@ export {
|
|
|
15
16
|
a as useDebounce,
|
|
16
17
|
c as useDebouncedCallback,
|
|
17
18
|
i as useLocalStorage,
|
|
18
|
-
T as
|
|
19
|
-
|
|
19
|
+
T as useOverlay,
|
|
20
|
+
y as useThrottle,
|
|
21
|
+
D as useWindowSize
|
|
20
22
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useState as w, useEffect as d } from "react";
|
|
2
|
+
const n = "__kitzo_overlays";
|
|
3
|
+
let o = [];
|
|
4
|
+
const a = /* @__PURE__ */ new Set();
|
|
5
|
+
if (typeof window < "u") {
|
|
6
|
+
const e = () => {
|
|
7
|
+
o = window.history.state?.[n] || [], a.forEach((r) => r(o));
|
|
8
|
+
};
|
|
9
|
+
window.addEventListener("popstate", e), window.history.state && (o = window.history.state[n] || []);
|
|
10
|
+
}
|
|
11
|
+
function f(e) {
|
|
12
|
+
if (!e)
|
|
13
|
+
throw new Error(
|
|
14
|
+
`useOverlay requires a unique "id" parameter to manage history state correctly. Recommendation: Use a page-scoped name like 'login-page:my-modal'.`
|
|
15
|
+
);
|
|
16
|
+
const [c, r] = w(() => o.includes(e));
|
|
17
|
+
return d(() => {
|
|
18
|
+
const t = (s) => {
|
|
19
|
+
r(s.includes(e));
|
|
20
|
+
};
|
|
21
|
+
return a.add(t), t(o), () => {
|
|
22
|
+
a.delete(t);
|
|
23
|
+
};
|
|
24
|
+
}, [e]), {
|
|
25
|
+
isOpen: c,
|
|
26
|
+
open: () => {
|
|
27
|
+
const t = window.history.state || {}, s = t[n] || [];
|
|
28
|
+
if (!s.includes(e)) {
|
|
29
|
+
const i = [...s, e];
|
|
30
|
+
window.history.pushState(
|
|
31
|
+
{ ...t, [n]: i },
|
|
32
|
+
""
|
|
33
|
+
), o = i, a.forEach((l) => l(o));
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
close: () => {
|
|
37
|
+
((window.history.state || {})[n] || []).includes(e) ? window.history.back() : r(!1);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
f as useOverlay
|
|
43
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kitzo",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A lightweight React micro-utility.",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "A lightweight production-ready React micro-utility library providing essential components, hooks, and functions for modern web applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -44,24 +44,14 @@
|
|
|
44
44
|
"react-dom": ">=19"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@changesets/cli": "^2.29.8",
|
|
48
47
|
"@eslint/js": "^9.39.2",
|
|
49
48
|
"@tailwindcss/vite": "^4.1.18",
|
|
50
|
-
"@types/node": "^25.0.6",
|
|
51
|
-
"@types/react": "^19.2.8",
|
|
52
|
-
"@types/react-dom": "^19.2.3",
|
|
53
49
|
"@vitejs/plugin-react-swc": "^4.2.2",
|
|
54
|
-
"daisyui": "^5.5.14",
|
|
55
|
-
"eslint": "^9.39.2",
|
|
56
50
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
57
51
|
"eslint-plugin-react-refresh": "^0.4.26",
|
|
58
52
|
"globals": "^17.0.0",
|
|
59
|
-
"prettier": "^3.7.4",
|
|
60
|
-
"prettier-plugin-tailwindcss": "^0.7.2",
|
|
61
53
|
"react": "^19.2.3",
|
|
62
54
|
"react-dom": "^19.2.3",
|
|
63
|
-
"tailwindcss": "^4.1.18",
|
|
64
|
-
"typescript": "~5.8.2",
|
|
65
55
|
"typescript-eslint": "^8.52.0",
|
|
66
56
|
"vite": "^7.3.1",
|
|
67
57
|
"vite-plugin-dts": "^4.5.4"
|
|
@@ -70,6 +60,7 @@
|
|
|
70
60
|
"dev": "vite",
|
|
71
61
|
"dev:host": "vite --host",
|
|
72
62
|
"build": "tsc -b && vite build",
|
|
63
|
+
"type-check": "tsc --noEmit",
|
|
73
64
|
"lint": "eslint .",
|
|
74
65
|
"preview": "vite preview",
|
|
75
66
|
"cs": "changeset"
|