kitzo 3.0.0 → 3.1.1
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 -28
- package/dist/index.d.ts +22 -6
- package/dist/index.js +6 -4
- package/dist/react/hooks/useOverlay.js +43 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,44 +1,40 @@
|
|
|
1
1
|
# Kitzo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Lightweight, production-ready React micro-utilities for modern web applications. Focus on simplicity, performance, and minimal footprint.
|
|
4
|
+
|
|
5
|
+
[Full Documentation & Demos](https://kitzo.vercel.app)
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
10
|
npm install kitzo
|
|
11
|
+
# or
|
|
12
|
+
pnpm add kitzo
|
|
9
13
|
```
|
|
10
14
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
### React Components
|
|
14
|
-
|
|
15
|
-
Essential, accessible, and performance-optimized UI components:
|
|
16
|
-
|
|
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.
|
|
19
|
-
|
|
20
|
-
### React Hooks
|
|
15
|
+
## Features
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
### Components
|
|
18
|
+
- **Toast**: Smart notification system with flexible positioning.
|
|
19
|
+
- **Tooltip**: Contextual information with auto-positioning logic.
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
27
|
-
- **
|
|
28
|
-
- **
|
|
29
|
-
- **
|
|
21
|
+
### Hooks
|
|
22
|
+
- **useCopy**: Easy clipboard management.
|
|
23
|
+
- **useDebounce**: Debounc any value.
|
|
24
|
+
- **useDebouncedCallback**: Debounce function calls.
|
|
25
|
+
- **useLocalStorage**: State persistence via storage.
|
|
26
|
+
- **useOverlay**: History-synchronized overlay management.
|
|
27
|
+
- **useThrottle**: Limit execution rate.
|
|
28
|
+
- **useWindowSize**: Real-time window dimensions.
|
|
30
29
|
|
|
31
|
-
###
|
|
30
|
+
### Utilities
|
|
31
|
+
- **copy**: Standalone programmatic clipboard copy.
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
For full usage guides, API references, and live demonstrations, visit the documentation site:
|
|
38
|
-
[https://kitzo.vercel.app](https://kitzo.vercel.app)
|
|
39
|
-
|
|
40
|
-
Check out the [root project](file:///home/riyad/Desktop/kitzo-monorepo/README.md) for project-wide information.
|
|
33
|
+
## See Also
|
|
34
|
+
- [Root Repository](https://github.com/riyad-96/kitzo)
|
|
35
|
+
- [Documentation](https://github.com/riyad-96/kitzo/tree/main/apps/docs)
|
|
41
36
|
|
|
42
37
|
## License
|
|
38
|
+
MIT
|
|
39
|
+
|
|
43
40
|
|
|
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