kitzo 2.3.45 → 2.5.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 +40 -40
- package/dist/fns.js +2 -2
- package/dist/functions/copy/{copy.js → index.js} +7 -7
- package/dist/index.d.ts +13 -12
- package/dist/index.js +13 -13
- package/dist/react/components/toast/Toaster.js +48 -46
- package/dist/react/components/toast/helpers/addToastStyles.js +15 -2
- package/dist/react/components/toast/helpers/manageToasts/swipeClose.js +1 -1
- package/dist/react/components/toast/helpers/triggerToasts.js +28 -28
- package/dist/react/components/toast/partials/Toast.js +41 -41
- package/dist/react/components/tooltip/Tooltip.js +10 -10
- package/dist/react/hooks/useCopy.js +6 -6
- package/dist/react/hooks/useDebounce.js +4 -4
- package/dist/react/hooks/useThrottle.js +2 -2
- package/dist/react/hooks/useWindowSize.js +2 -2
- package/package.json +77 -74
package/README.md
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
# Kitzo
|
|
2
|
-
|
|
3
|
-
**Lightweight React UI components and essential hooks.**
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
### Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install kitzo
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
### Core Features
|
|
16
|
-
|
|
17
|
-
#### Components
|
|
18
|
-
|
|
19
|
-
- **Toast** — Accessible, animated notifications.
|
|
20
|
-
- **Tooltip** — Smart-positioned contextual labels.
|
|
21
|
-
|
|
22
|
-
#### Hooks
|
|
23
|
-
|
|
24
|
-
- **useDebounce** — Optimize performance by delaying execution.
|
|
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.
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
### Documentation
|
|
32
|
-
|
|
33
|
-
For usage guides and live demos, visit documentation:
|
|
34
|
-
[https://kitzo.vercel.app](https://kitzo.vercel.app)
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
### License
|
|
39
|
-
|
|
40
|
-
MIT
|
|
1
|
+
# Kitzo
|
|
2
|
+
|
|
3
|
+
**Lightweight React UI components and essential hooks.**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install kitzo
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
### Core Features
|
|
16
|
+
|
|
17
|
+
#### Components
|
|
18
|
+
|
|
19
|
+
- **Toast** — Accessible, animated notifications.
|
|
20
|
+
- **Tooltip** — Smart-positioned contextual labels.
|
|
21
|
+
|
|
22
|
+
#### Hooks
|
|
23
|
+
|
|
24
|
+
- **useDebounce** — Optimize performance by delaying execution.
|
|
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.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
### Documentation
|
|
32
|
+
|
|
33
|
+
For usage guides and live demos, visit documentation:
|
|
34
|
+
[https://kitzo.vercel.app](https://kitzo.vercel.app)
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
### License
|
|
39
|
+
|
|
40
|
+
MIT
|
package/dist/fns.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
function
|
|
1
|
+
function o(e) {
|
|
2
2
|
const t = document.createElement("textarea");
|
|
3
3
|
t.value = e, document.body.appendChild(t), t.select(), document.execCommand("copy"), document.body.removeChild(t);
|
|
4
4
|
}
|
|
5
|
-
async function
|
|
5
|
+
async function r(e) {
|
|
6
6
|
if (!navigator.clipboard?.writeText) {
|
|
7
|
-
|
|
7
|
+
o(e);
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
try {
|
|
11
11
|
await navigator.clipboard.writeText(e);
|
|
12
12
|
} catch (t) {
|
|
13
|
-
|
|
13
|
+
o(e), console.error(t);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
async function
|
|
16
|
+
async function a(e) {
|
|
17
17
|
let t;
|
|
18
18
|
try {
|
|
19
19
|
t = typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? String(e) : JSON.stringify(e);
|
|
20
20
|
} catch {
|
|
21
21
|
t = "[Cannot copy circular object]";
|
|
22
22
|
}
|
|
23
|
-
await
|
|
23
|
+
await r(t);
|
|
24
24
|
}
|
|
25
25
|
export {
|
|
26
|
-
|
|
26
|
+
a as copy
|
|
27
27
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -15,10 +15,6 @@ declare type CopyStatus = 'standby' | 'copying' | 'copied' | 'error';
|
|
|
15
15
|
|
|
16
16
|
declare type Options = ToastOptionsWithoutType;
|
|
17
17
|
|
|
18
|
-
declare type Position = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
|
|
19
|
-
|
|
20
|
-
declare type Positions = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
21
|
-
|
|
22
18
|
declare type PromiseToastFn = <T, E = unknown>(promise: Promise<T>, msgs: PromiseToastMsgs<T, E>, options?: PromiseToastOptions) => Promise<T>;
|
|
23
19
|
|
|
24
20
|
declare type PromiseToastMsgs<T, E = unknown> = {
|
|
@@ -35,16 +31,17 @@ declare type ToastContent = ((dismiss: () => void) => ReactNode) | ReactNode;
|
|
|
35
31
|
|
|
36
32
|
export declare function Toaster(props: ToasterProps): JSX.Element | null;
|
|
37
33
|
|
|
38
|
-
declare type ToasterProps = {
|
|
39
|
-
position?:
|
|
40
|
-
richColors?: boolean;
|
|
41
|
-
animateTransformOrigin?: boolean;
|
|
34
|
+
export declare type ToasterProps = {
|
|
35
|
+
position?: ToastPositions;
|
|
42
36
|
gap?: number | `${number}`;
|
|
43
37
|
edgeOffset?: number | `${number}`;
|
|
44
|
-
|
|
38
|
+
toasterId?: string | number;
|
|
39
|
+
dark?: boolean;
|
|
40
|
+
compact?: boolean;
|
|
41
|
+
richColors?: boolean;
|
|
45
42
|
pauseOnHover?: boolean;
|
|
46
43
|
swipeToClose?: boolean;
|
|
47
|
-
|
|
44
|
+
animateTransformOrigin?: boolean;
|
|
48
45
|
};
|
|
49
46
|
|
|
50
47
|
declare type ToastFn = {
|
|
@@ -64,7 +61,7 @@ declare type ToastOptions = {
|
|
|
64
61
|
duration?: number;
|
|
65
62
|
showIcon?: boolean;
|
|
66
63
|
icon?: ReactNode;
|
|
67
|
-
position?:
|
|
64
|
+
position?: ToastPositions;
|
|
68
65
|
animateTransformOrigin?: boolean;
|
|
69
66
|
id?: string | number;
|
|
70
67
|
type?: ToastType;
|
|
@@ -74,6 +71,8 @@ declare type ToastOptions = {
|
|
|
74
71
|
|
|
75
72
|
declare type ToastOptionsWithoutType = Omit<ToastOptions, 'type'>;
|
|
76
73
|
|
|
74
|
+
export declare type ToastPositions = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
75
|
+
|
|
77
76
|
declare type ToastType = 'default' | 'success' | 'warning' | 'error' | 'info' | 'custom' | 'loading';
|
|
78
77
|
|
|
79
78
|
export declare function Tooltip(props: TooltipProps): ReactNode;
|
|
@@ -85,7 +84,7 @@ declare type TooltipCoreProps = {
|
|
|
85
84
|
* content is necessary
|
|
86
85
|
*/
|
|
87
86
|
content: ReactNode;
|
|
88
|
-
position?:
|
|
87
|
+
position?: TooltipPosition;
|
|
89
88
|
offset?: number;
|
|
90
89
|
smartHover?: boolean;
|
|
91
90
|
hideOnTouch?: boolean;
|
|
@@ -94,6 +93,8 @@ declare type TooltipCoreProps = {
|
|
|
94
93
|
isDark?: boolean;
|
|
95
94
|
};
|
|
96
95
|
|
|
96
|
+
export declare type TooltipPosition = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
|
|
97
|
+
|
|
97
98
|
declare type TooltipProps = PropsWithChildren<TooltipCoreProps>;
|
|
98
99
|
|
|
99
100
|
declare type UpdateToastOptions = Omit<ToastOptions, 'id'>;
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { Toaster as r } from "./react/components/toast/Toaster.js";
|
|
2
|
+
import { Tooltip as p } from "./react/components/tooltip/Tooltip.js";
|
|
3
|
+
import { toast as m } from "./react/components/toast/helpers/triggerToasts.js";
|
|
4
|
+
import { useCopy as s } from "./react/hooks/useCopy.js";
|
|
5
|
+
import { useDebounce as i } from "./react/hooks/useDebounce.js";
|
|
6
|
+
import { useThrottle as a } from "./react/hooks/useThrottle.js";
|
|
7
|
+
import { useWindowSize as n } from "./react/hooks/useWindowSize.js";
|
|
8
8
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
r as Toaster,
|
|
10
|
+
p as Tooltip,
|
|
11
|
+
m as toast,
|
|
12
12
|
s as useCopy,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
i as useDebounce,
|
|
14
|
+
a as useThrottle,
|
|
15
|
+
n as useWindowSize
|
|
16
16
|
};
|
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import t from "react";
|
|
3
|
-
import { subscribe as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { ToasterContext as
|
|
7
|
-
import { initSwipeToClose as
|
|
8
|
-
function
|
|
3
|
+
import { subscribe as w } from "./helpers/listenars.js";
|
|
4
|
+
import M from "./helpers/manageToasts/manageToasts.js";
|
|
5
|
+
import O from "./partials/ToastContainer.js";
|
|
6
|
+
import { ToasterContext as S } from "./context/ToasterContext.js";
|
|
7
|
+
import { initSwipeToClose as z } from "./helpers/manageToasts/swipeClose.js";
|
|
8
|
+
function q(s) {
|
|
9
9
|
const {
|
|
10
10
|
position: h = "top-center",
|
|
11
|
-
richColors:
|
|
11
|
+
richColors: u = !1,
|
|
12
12
|
animateTransformOrigin: g = !0,
|
|
13
|
-
gap:
|
|
14
|
-
edgeOffset:
|
|
15
|
-
|
|
13
|
+
gap: r = s?.compact ? 8 : 12,
|
|
14
|
+
edgeOffset: i = 16,
|
|
15
|
+
dark: c,
|
|
16
16
|
pauseOnHover: b = !0,
|
|
17
|
-
swipeToClose: y = !0
|
|
18
|
-
|
|
17
|
+
swipeToClose: y = !0,
|
|
18
|
+
compact: k = !1
|
|
19
|
+
} = s, [T, v] = t.useState(!1);
|
|
19
20
|
t.useEffect(() => {
|
|
20
|
-
|
|
21
|
+
v(!0);
|
|
21
22
|
}, []);
|
|
22
23
|
const [p, m] = t.useState([]);
|
|
23
24
|
t.useEffect(() => {
|
|
24
|
-
const e =
|
|
25
|
-
(o) =>
|
|
26
|
-
|
|
27
|
-
),
|
|
25
|
+
const e = w(
|
|
26
|
+
(o) => M({ toast: o, setToasts: m }),
|
|
27
|
+
s.toasterId
|
|
28
|
+
), a = z();
|
|
28
29
|
return () => {
|
|
29
|
-
e(),
|
|
30
|
+
e(), a();
|
|
30
31
|
};
|
|
31
|
-
}, [
|
|
32
|
-
const f = t.useRef(null),
|
|
32
|
+
}, [s.toasterId]);
|
|
33
|
+
const f = t.useRef(null), l = t.useCallback(() => {
|
|
33
34
|
if (!f.current) return;
|
|
34
|
-
const e = f.current.querySelectorAll("[data-toast-container]"),
|
|
35
|
+
const e = f.current.querySelectorAll("[data-toast-container]"), a = {
|
|
35
36
|
"top-left": 0,
|
|
36
37
|
"top-center": 0,
|
|
37
38
|
"top-right": 0,
|
|
@@ -40,17 +41,17 @@ function D(i) {
|
|
|
40
41
|
"bottom-right": 0
|
|
41
42
|
};
|
|
42
43
|
e.forEach((o) => {
|
|
43
|
-
const d = o.getAttribute("data-toast-position") || "top-center",
|
|
44
|
-
o.style.setProperty("--toast-offset-y", `${
|
|
45
|
-
const
|
|
46
|
-
|
|
44
|
+
const d = o.getAttribute("data-toast-position") || "top-center", C = parseFloat(o.style.getPropertyValue("--toast-height")) || 0;
|
|
45
|
+
o.style.setProperty("--toast-offset-y", `${a[d]}px`);
|
|
46
|
+
const E = isNaN(+r) ? 8 : +r;
|
|
47
|
+
a[d] += C + E;
|
|
47
48
|
});
|
|
48
|
-
}, [
|
|
49
|
+
}, [r]);
|
|
49
50
|
if (t.useLayoutEffect(() => {
|
|
50
|
-
|
|
51
|
-
}, [p,
|
|
52
|
-
const
|
|
53
|
-
return /* @__PURE__ */
|
|
51
|
+
l();
|
|
52
|
+
}, [p, l]), !T) return null;
|
|
53
|
+
const x = typeof c == "boolean" ? c : window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
54
|
+
return /* @__PURE__ */ n(
|
|
54
55
|
"div",
|
|
55
56
|
{
|
|
56
57
|
ref: f,
|
|
@@ -60,31 +61,32 @@ function D(i) {
|
|
|
60
61
|
zIndex: 2147483647,
|
|
61
62
|
pointerEvents: "none",
|
|
62
63
|
display: "grid",
|
|
63
|
-
padding:
|
|
64
|
+
padding: i != null ? `${Math.max(Math.min(+i, 200), 0)}px` : 16
|
|
64
65
|
},
|
|
65
|
-
className: `kitzo-toaster ${
|
|
66
|
-
children: /* @__PURE__ */
|
|
66
|
+
className: `kitzo-toaster ${u ? "kitzo-toaster-rich-colors" : ""} ${x ? "kitzo-toaster-dark" : ""}`,
|
|
67
|
+
children: /* @__PURE__ */ n(
|
|
67
68
|
"div",
|
|
68
69
|
{
|
|
69
70
|
style: {
|
|
70
71
|
position: "relative"
|
|
71
72
|
},
|
|
72
|
-
children: /* @__PURE__ */
|
|
73
|
-
|
|
73
|
+
children: /* @__PURE__ */ n(
|
|
74
|
+
S.Provider,
|
|
74
75
|
{
|
|
75
76
|
value: {
|
|
76
77
|
position: h,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
gap: s,
|
|
80
|
-
edgeOffset: n,
|
|
81
|
-
animateTransformOrigin: g,
|
|
82
|
-
pauseOnHover: b,
|
|
83
|
-
swipeToClose: y,
|
|
78
|
+
gap: r,
|
|
79
|
+
edgeOffset: i,
|
|
84
80
|
setToasts: m,
|
|
85
|
-
updateOffsets:
|
|
81
|
+
updateOffsets: l,
|
|
82
|
+
dark: c,
|
|
83
|
+
compact: k,
|
|
84
|
+
richColors: u,
|
|
85
|
+
swipeToClose: y,
|
|
86
|
+
pauseOnHover: b,
|
|
87
|
+
animateTransformOrigin: g
|
|
86
88
|
},
|
|
87
|
-
children: p.map((e) => /* @__PURE__ */
|
|
89
|
+
children: p.map((e) => /* @__PURE__ */ n(O, { t: e }, e.id))
|
|
88
90
|
}
|
|
89
91
|
)
|
|
90
92
|
}
|
|
@@ -93,5 +95,5 @@ function D(i) {
|
|
|
93
95
|
);
|
|
94
96
|
}
|
|
95
97
|
export {
|
|
96
|
-
|
|
98
|
+
q as Toaster
|
|
97
99
|
};
|
|
@@ -85,13 +85,16 @@ const a = `.kitzo-toaster {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
.kitzo-toast {
|
|
88
|
-
font-family: inherit;
|
|
89
|
-
font-size: 0.875rem;
|
|
90
88
|
transition:
|
|
91
89
|
transform 280ms,
|
|
92
90
|
opacity 280ms;
|
|
93
91
|
will-change: transform, opacity;
|
|
94
92
|
touch-action: pan-y;
|
|
93
|
+
|
|
94
|
+
font-family: inherit;
|
|
95
|
+
font-size: 0.875rem;
|
|
96
|
+
white-space: pre-wrap;
|
|
97
|
+
text-wrap: balance;
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
.kitzo-toast.is-swiping {
|
|
@@ -145,6 +148,16 @@ const a = `.kitzo-toaster {
|
|
|
145
148
|
box-shadow: 0 3px 8px -3px hsl(0, 0%, 0%, 0.15);
|
|
146
149
|
}
|
|
147
150
|
|
|
151
|
+
/*! toast size */
|
|
152
|
+
.kitzo-toast[data-compact='false']:not([data-type='custom']) {
|
|
153
|
+
flex: 1;
|
|
154
|
+
min-height: 40px;
|
|
155
|
+
|
|
156
|
+
@media (width > 380px) {
|
|
157
|
+
max-width: 250px;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
148
161
|
/*! toast transition styles */
|
|
149
162
|
.kitzo-toast {
|
|
150
163
|
--swipe-x: 0px;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createToast as n, updateToast as s, genId as c } from "./createToast.js";
|
|
2
|
-
import { notify as
|
|
3
|
-
const
|
|
4
|
-
r != null &&
|
|
2
|
+
import { notify as e } from "./listenars.js";
|
|
3
|
+
const i = (r, t) => {
|
|
4
|
+
r != null && e(
|
|
5
5
|
n({
|
|
6
6
|
type: "default",
|
|
7
7
|
action: "add",
|
|
@@ -10,15 +10,15 @@ const e = (r, t) => {
|
|
|
10
10
|
})
|
|
11
11
|
);
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
i.dismiss = (r, t) => {
|
|
14
|
+
e({
|
|
15
15
|
action: "dismiss",
|
|
16
16
|
id: r,
|
|
17
17
|
toasterId: t
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
r != null &&
|
|
20
|
+
i.info = (r, t) => {
|
|
21
|
+
r != null && e(
|
|
22
22
|
n({
|
|
23
23
|
action: "add",
|
|
24
24
|
type: "info",
|
|
@@ -27,8 +27,8 @@ e.info = (r, t) => {
|
|
|
27
27
|
})
|
|
28
28
|
);
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
r != null &&
|
|
30
|
+
i.success = (r, t) => {
|
|
31
|
+
r != null && e(
|
|
32
32
|
n({
|
|
33
33
|
action: "add",
|
|
34
34
|
type: "success",
|
|
@@ -37,8 +37,8 @@ e.success = (r, t) => {
|
|
|
37
37
|
})
|
|
38
38
|
);
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
r != null &&
|
|
40
|
+
i.warning = (r, t) => {
|
|
41
|
+
r != null && e(
|
|
42
42
|
n({
|
|
43
43
|
action: "add",
|
|
44
44
|
type: "warning",
|
|
@@ -47,8 +47,8 @@ e.warning = (r, t) => {
|
|
|
47
47
|
})
|
|
48
48
|
);
|
|
49
49
|
};
|
|
50
|
-
|
|
51
|
-
r != null &&
|
|
50
|
+
i.error = (r, t) => {
|
|
51
|
+
r != null && e(
|
|
52
52
|
n({
|
|
53
53
|
action: "add",
|
|
54
54
|
type: "error",
|
|
@@ -57,8 +57,8 @@ e.error = (r, t) => {
|
|
|
57
57
|
})
|
|
58
58
|
);
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
r != null &&
|
|
60
|
+
i.loading = (r, t) => {
|
|
61
|
+
r != null && e(
|
|
62
62
|
n({
|
|
63
63
|
action: "add",
|
|
64
64
|
type: "loading",
|
|
@@ -67,8 +67,8 @@ e.loading = (r, t) => {
|
|
|
67
67
|
})
|
|
68
68
|
);
|
|
69
69
|
};
|
|
70
|
-
|
|
71
|
-
r != null &&
|
|
70
|
+
i.custom = (r, t) => {
|
|
71
|
+
r != null && e(
|
|
72
72
|
n({
|
|
73
73
|
action: "add",
|
|
74
74
|
type: "custom",
|
|
@@ -77,27 +77,27 @@ e.custom = (r, t) => {
|
|
|
77
77
|
})
|
|
78
78
|
);
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
r != null && t != null &&
|
|
80
|
+
i.update = (r, t, o) => {
|
|
81
|
+
r != null && t != null && e(s({ id: `${r}`, content: t, options: o }));
|
|
82
82
|
};
|
|
83
|
-
|
|
83
|
+
i.promise = (async (r, t, o) => {
|
|
84
84
|
const u = c();
|
|
85
|
-
|
|
85
|
+
e(
|
|
86
86
|
n({
|
|
87
87
|
action: "add",
|
|
88
88
|
type: "loading",
|
|
89
89
|
content: t.loading,
|
|
90
|
-
options: { ...
|
|
90
|
+
options: { ...o, id: u, duration: 1 / 0, swipeToClose: !1 }
|
|
91
91
|
})
|
|
92
92
|
);
|
|
93
93
|
try {
|
|
94
|
-
const
|
|
95
|
-
return
|
|
96
|
-
} catch (
|
|
97
|
-
const d = typeof t.error == "function" ? await t.error(
|
|
98
|
-
throw
|
|
94
|
+
const a = await r, d = typeof t.success == "function" ? await t.success(a) : t.success;
|
|
95
|
+
return i.update(u, d, { ...o, type: "success" }), a;
|
|
96
|
+
} catch (a) {
|
|
97
|
+
const d = typeof t.error == "function" ? await t.error(a) : t.error;
|
|
98
|
+
throw i.update(u, d, { ...o, type: "error" }), a;
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
101
|
export {
|
|
102
|
-
|
|
102
|
+
i as toast
|
|
103
103
|
};
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { resumeToast as
|
|
3
|
-
import
|
|
4
|
-
import { InfoSvg as
|
|
1
|
+
import { jsxs as S, jsx as t, Fragment as o } from "react/jsx-runtime";
|
|
2
|
+
import { resumeToast as l, pauseToast as m } from "../helpers/manageToasts/timers.js";
|
|
3
|
+
import { toast as I } from "../helpers/triggerToasts.js";
|
|
4
|
+
import { InfoSvg as E, ErrorSvg as T, WarningSvg as k, SuccessSvg as w, LoadingSvg as L } from "./Svgs.js";
|
|
5
5
|
import { useToasterContext as M } from "../context/ToasterContext.js";
|
|
6
|
-
function
|
|
7
|
-
t:
|
|
8
|
-
position:
|
|
9
|
-
shouldAnimateTransformOrigin:
|
|
10
|
-
swipeToClose:
|
|
6
|
+
function z({
|
|
7
|
+
t: c,
|
|
8
|
+
position: s,
|
|
9
|
+
shouldAnimateTransformOrigin: p,
|
|
10
|
+
swipeToClose: u
|
|
11
11
|
}) {
|
|
12
|
-
const { pauseOnHover:
|
|
12
|
+
const { pauseOnHover: n, compact: f } = M(), {
|
|
13
13
|
id: e,
|
|
14
14
|
type: r,
|
|
15
|
-
action:
|
|
15
|
+
action: g,
|
|
16
16
|
content: i,
|
|
17
|
-
status:
|
|
18
|
-
showIcon:
|
|
17
|
+
status: v,
|
|
18
|
+
showIcon: h,
|
|
19
19
|
icon: a,
|
|
20
|
-
toasterId:
|
|
21
|
-
updateState:
|
|
22
|
-
} =
|
|
20
|
+
toasterId: y,
|
|
21
|
+
updateState: x
|
|
22
|
+
} = c, d = {
|
|
23
23
|
loading: /* @__PURE__ */ t(L, {}),
|
|
24
|
-
success: /* @__PURE__ */ t(
|
|
25
|
-
warning: /* @__PURE__ */ t(
|
|
26
|
-
error: /* @__PURE__ */ t(
|
|
27
|
-
info: /* @__PURE__ */ t(
|
|
24
|
+
success: /* @__PURE__ */ t(w, {}),
|
|
25
|
+
warning: /* @__PURE__ */ t(k, {}),
|
|
26
|
+
error: /* @__PURE__ */ t(T, {}),
|
|
27
|
+
info: /* @__PURE__ */ t(E, {}),
|
|
28
28
|
default: null,
|
|
29
29
|
custom: null
|
|
30
30
|
};
|
|
31
|
-
return /* @__PURE__ */
|
|
31
|
+
return /* @__PURE__ */ S(
|
|
32
32
|
"div",
|
|
33
33
|
{
|
|
34
34
|
id: e,
|
|
@@ -36,27 +36,27 @@ function P({
|
|
|
36
36
|
pointerEvents: "all",
|
|
37
37
|
display: "flex",
|
|
38
38
|
alignItems: "center",
|
|
39
|
-
gap: 8
|
|
40
|
-
whiteSpace: "pre-wrap"
|
|
39
|
+
gap: 8
|
|
41
40
|
},
|
|
42
|
-
"data-toaster-id":
|
|
43
|
-
"data-action":
|
|
44
|
-
"data-status":
|
|
41
|
+
"data-toaster-id": y,
|
|
42
|
+
"data-action": g,
|
|
43
|
+
"data-status": v,
|
|
45
44
|
"data-type": r,
|
|
46
|
-
"data-position":
|
|
47
|
-
"data-screen-x":
|
|
48
|
-
"data-screen-y":
|
|
45
|
+
"data-position": s,
|
|
46
|
+
"data-screen-x": s.split("-")[1],
|
|
47
|
+
"data-screen-y": s.split("-")[0],
|
|
49
48
|
"data-exit": "auto",
|
|
50
|
-
"data-swipeable":
|
|
51
|
-
"data-animate-transform-origin":
|
|
52
|
-
"data-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
"data-swipeable": u,
|
|
50
|
+
"data-animate-transform-origin": p,
|
|
51
|
+
"data-compact": f,
|
|
52
|
+
"data-update-state": x,
|
|
53
|
+
onPointerEnter: () => n && m(e),
|
|
54
|
+
onPointerLeave: () => n && l(e),
|
|
55
|
+
onMouseEnter: () => n && m(e),
|
|
56
|
+
onMouseLeave: () => n && l(e),
|
|
57
|
+
className: "kitzo-toast",
|
|
58
58
|
children: [
|
|
59
|
-
|
|
59
|
+
h && /* @__PURE__ */ t(o, { children: a ? /* @__PURE__ */ t(o, { children: typeof a == "string" || typeof a == "number" ? /* @__PURE__ */ t(
|
|
60
60
|
"div",
|
|
61
61
|
{
|
|
62
62
|
style: {
|
|
@@ -65,14 +65,14 @@ function P({
|
|
|
65
65
|
className: "svg-container",
|
|
66
66
|
children: a
|
|
67
67
|
}
|
|
68
|
-
) : /* @__PURE__ */ t(
|
|
68
|
+
) : /* @__PURE__ */ t(o, { children: a }) }) : /* @__PURE__ */ t(o, { children: d[r] && /* @__PURE__ */ t("div", { style: { flexShrink: 0 }, className: "svg-container", children: d[r] }) }) }),
|
|
69
69
|
/* @__PURE__ */ t(
|
|
70
70
|
"div",
|
|
71
71
|
{
|
|
72
72
|
style: {
|
|
73
73
|
flex: 1
|
|
74
74
|
},
|
|
75
|
-
children: typeof i == "function" ? i(() =>
|
|
75
|
+
children: typeof i == "function" ? i(() => I.dismiss(e, c.toasterId)) : i
|
|
76
76
|
}
|
|
77
77
|
)
|
|
78
78
|
]
|
|
@@ -80,5 +80,5 @@ function P({
|
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
82
|
export {
|
|
83
|
-
|
|
83
|
+
z as default
|
|
84
84
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as a, Fragment as r, jsxs as T } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import d from "react";
|
|
3
3
|
import v from "./helpers/addTooltipStyles.js";
|
|
4
4
|
import w from "./helpers/getPositionClass.js";
|
|
5
5
|
import O from "./partials/TooltipWrapper.js";
|
|
@@ -11,24 +11,24 @@ function C(h) {
|
|
|
11
11
|
position: y = "top",
|
|
12
12
|
animation: i = !0,
|
|
13
13
|
isHidden: s = !1,
|
|
14
|
-
offset:
|
|
15
|
-
smartHover:
|
|
14
|
+
offset: m = 8,
|
|
15
|
+
smartHover: f = !0,
|
|
16
16
|
hideOnTouch: l = !0,
|
|
17
17
|
isDark: u
|
|
18
|
-
} = h, [D, b] =
|
|
19
|
-
if (
|
|
18
|
+
} = h, [D, b] = d.useState(!1);
|
|
19
|
+
if (d.useEffect(() => {
|
|
20
20
|
b(!0), v();
|
|
21
21
|
}, []), !D) return /* @__PURE__ */ a(r, { children: t });
|
|
22
22
|
if (typeof s == "boolean" && s) return /* @__PURE__ */ a(r, { children: t });
|
|
23
23
|
if (n == null)
|
|
24
24
|
return /* @__PURE__ */ a(r, { children: t });
|
|
25
25
|
const o = {
|
|
26
|
-
offset: isNaN(Number(
|
|
27
|
-
smartHover: typeof
|
|
26
|
+
offset: isNaN(Number(m)) ? 8 : Number(m),
|
|
27
|
+
smartHover: typeof f == "boolean" ? f : !0,
|
|
28
28
|
hideOnTouch: typeof l == "boolean" ? l : !0
|
|
29
29
|
};
|
|
30
|
-
let p = !1,
|
|
31
|
-
if (typeof window < "u" && (
|
|
30
|
+
let p = !1, c = !1;
|
|
31
|
+
if (typeof window < "u" && (c = window.matchMedia("(pointer: coarse)").matches || navigator.maxTouchPoints > 0, p = typeof u == "boolean" ? u : window.matchMedia("(prefers-color-scheme: dark)").matches), c && o.hideOnTouch) return t;
|
|
32
32
|
const x = w(y), M = !!i, e = k(
|
|
33
33
|
i === !0 ? {} : i
|
|
34
34
|
);
|
|
@@ -63,5 +63,5 @@ function C(h) {
|
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
export {
|
|
66
|
-
C as
|
|
66
|
+
C as Tooltip
|
|
67
67
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { useState as u, useRef as i, useCallback as
|
|
2
|
-
import m from "../../functions/copy/
|
|
1
|
+
import { useState as u, useRef as i, useCallback as l, useEffect as p } from "react";
|
|
2
|
+
import { copy as m } from "../../functions/copy/index.js";
|
|
3
3
|
function E(c = 1500) {
|
|
4
|
-
const [r, e] = u("standby"), [a, s] = u(null), t = i(null), n = i(!1), f =
|
|
5
|
-
async (
|
|
4
|
+
const [r, e] = u("standby"), [a, s] = u(null), t = i(null), n = i(!1), f = l(
|
|
5
|
+
async (y) => {
|
|
6
6
|
if (!n.current) {
|
|
7
7
|
t.current && clearTimeout(t.current);
|
|
8
8
|
try {
|
|
9
|
-
n.current = !0, s(null), e("copying"), await m(
|
|
9
|
+
n.current = !0, s(null), e("copying"), await m(y), e("copied");
|
|
10
10
|
} catch (o) {
|
|
11
11
|
s(o instanceof Error ? o : new Error(String(o))), e("error");
|
|
12
12
|
} finally {
|
|
@@ -34,5 +34,5 @@ function E(c = 1500) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
export {
|
|
37
|
-
E as
|
|
37
|
+
E as useCopy
|
|
38
38
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useState as r, useEffect as c } from "react";
|
|
2
2
|
function f(e, t) {
|
|
3
3
|
t ??= 500;
|
|
4
|
-
const [
|
|
4
|
+
const [o, u] = r(e);
|
|
5
5
|
return c(() => {
|
|
6
6
|
const n = setTimeout(() => {
|
|
7
|
-
|
|
7
|
+
u(e);
|
|
8
8
|
}, t);
|
|
9
9
|
return () => {
|
|
10
10
|
clearTimeout(n);
|
|
11
11
|
};
|
|
12
|
-
}, [e, t]),
|
|
12
|
+
}, [e, t]), o;
|
|
13
13
|
}
|
|
14
14
|
export {
|
|
15
|
-
f as
|
|
15
|
+
f as useDebounce
|
|
16
16
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState as c, useRef as f, useEffect as i } from "react";
|
|
2
|
-
function
|
|
2
|
+
function l(t, e = 500) {
|
|
3
3
|
const [n, u] = c(t), r = f(0);
|
|
4
4
|
return i(() => {
|
|
5
5
|
function s() {
|
|
@@ -10,5 +10,5 @@ function a(t, e = 500) {
|
|
|
10
10
|
}, [t, e]), n;
|
|
11
11
|
}
|
|
12
12
|
export {
|
|
13
|
-
|
|
13
|
+
l as useThrottle
|
|
14
14
|
};
|
package/package.json
CHANGED
|
@@ -1,74 +1,77 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "kitzo",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "A lightweight React micro-utility.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist"
|
|
8
|
-
],
|
|
9
|
-
"sideEffects": false,
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"import": "./dist/index.js",
|
|
14
|
-
"default": "./dist/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./fns": {
|
|
17
|
-
"types": "./dist/fns.d.ts",
|
|
18
|
-
"import": "./dist/fns.js",
|
|
19
|
-
"default": "./dist/fns.js"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "kitzo",
|
|
3
|
+
"version": "2.5.0",
|
|
4
|
+
"description": "A lightweight React micro-utility.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./fns": {
|
|
17
|
+
"types": "./dist/fns.d.ts",
|
|
18
|
+
"import": "./dist/fns.js",
|
|
19
|
+
"default": "./dist/fns.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"kitzo",
|
|
24
|
+
"components",
|
|
25
|
+
"toast",
|
|
26
|
+
"toaster",
|
|
27
|
+
"tooltip",
|
|
28
|
+
"hooks",
|
|
29
|
+
"function",
|
|
30
|
+
"micro-utility",
|
|
31
|
+
"ui",
|
|
32
|
+
"react",
|
|
33
|
+
"reactjs"
|
|
34
|
+
],
|
|
35
|
+
"author": "Riyad",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/riyad-96/kitzo.git"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/riyad-96/kitzo#readme",
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": ">=19",
|
|
44
|
+
"react-dom": ">=19"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@changesets/cli": "^2.29.8",
|
|
48
|
+
"@eslint/js": "^9.39.2",
|
|
49
|
+
"@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
|
+
"@vitejs/plugin-react-swc": "^4.2.2",
|
|
54
|
+
"daisyui": "^5.5.14",
|
|
55
|
+
"eslint": "^9.39.2",
|
|
56
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
57
|
+
"eslint-plugin-react-refresh": "^0.4.26",
|
|
58
|
+
"globals": "^17.0.0",
|
|
59
|
+
"prettier": "^3.7.4",
|
|
60
|
+
"prettier-plugin-tailwindcss": "^0.7.2",
|
|
61
|
+
"react": "^19.2.3",
|
|
62
|
+
"react-dom": "^19.2.3",
|
|
63
|
+
"tailwindcss": "^4.1.18",
|
|
64
|
+
"typescript": "~5.8.2",
|
|
65
|
+
"typescript-eslint": "^8.52.0",
|
|
66
|
+
"vite": "^7.3.1",
|
|
67
|
+
"vite-plugin-dts": "^4.5.4"
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"dev": "vite",
|
|
71
|
+
"dev:host": "vite --host",
|
|
72
|
+
"build": "tsc -b && vite build",
|
|
73
|
+
"lint": "eslint .",
|
|
74
|
+
"preview": "vite preview",
|
|
75
|
+
"cs": "changeset"
|
|
76
|
+
}
|
|
77
|
+
}
|