holie-vkit 1.1.10 → 1.1.11

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.
@@ -0,0 +1,10 @@
1
+ export interface ToastOptions {
2
+ message: string;
3
+ type?: "info" | "success" | "warning" | "error";
4
+ duration?: number;
5
+ }
6
+ export declare function useToast(): {
7
+ showToast: (options: ToastOptions) => void;
8
+ hideToast: () => void;
9
+ ToastComponent: () => import("react/jsx-runtime").JSX.Element | null;
10
+ };
@@ -1,2 +1,26 @@
1
- "use strict";
2
- // File intentionally removed. Use useToast.tsx instead.
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ export function useToast() {
4
+ const [toast, setToast] = React.useState(null);
5
+ const showToast = (options) => setToast(options);
6
+ const hideToast = () => setToast(null);
7
+ React.useEffect(() => {
8
+ if (toast && toast.duration !== 0) {
9
+ const timer = setTimeout(() => setToast(null), toast.duration || 3000);
10
+ return () => clearTimeout(timer);
11
+ }
12
+ }, [toast]);
13
+ let bgClass = "bg-blue-500 text-white";
14
+ if ((toast === null || toast === void 0 ? void 0 : toast.type) === "success")
15
+ bgClass = "bg-green-500 text-white";
16
+ else if ((toast === null || toast === void 0 ? void 0 : toast.type) === "error")
17
+ bgClass = "bg-red-500 text-white";
18
+ else if ((toast === null || toast === void 0 ? void 0 : toast.type) === "warning")
19
+ bgClass = "bg-yellow-500 text-black";
20
+ function ToastComponent() {
21
+ if (!toast)
22
+ return null;
23
+ return (_jsx("div", { className: `fixed bottom-4 right-4 px-4 py-2 rounded shadow-lg z-50 ${bgClass}`, children: toast.message }));
24
+ }
25
+ return { showToast, hideToast, ToastComponent };
26
+ }
package/dist/index.d.ts CHANGED
@@ -38,3 +38,4 @@ export * from './components/Progress';
38
38
  export * from './components/Skeleton';
39
39
  export * from './components/Table';
40
40
  export * from './components/Toast';
41
+ export { useToast } from './hooks/useToast';
package/dist/index.js CHANGED
@@ -39,3 +39,5 @@ export * from './components/Progress';
39
39
  export * from './components/Skeleton';
40
40
  export * from './components/Table';
41
41
  export * from './components/Toast';
42
+ // Export hooks
43
+ export { useToast } from './hooks/useToast';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holie-vkit",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",