holie-vkit 1.1.12 → 1.2.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.
@@ -0,0 +1,45 @@
1
+ import * as React from "react";
2
+ export type ToasterToast = {
3
+ id: string;
4
+ title?: React.ReactNode;
5
+ description?: React.ReactNode;
6
+ action?: React.ReactNode;
7
+ open?: boolean;
8
+ onOpenChange?: (open: boolean) => void;
9
+ };
10
+ declare const actionTypes: {
11
+ readonly ADD_TOAST: "ADD_TOAST";
12
+ readonly UPDATE_TOAST: "UPDATE_TOAST";
13
+ readonly DISMISS_TOAST: "DISMISS_TOAST";
14
+ readonly REMOVE_TOAST: "REMOVE_TOAST";
15
+ };
16
+ type ActionType = typeof actionTypes;
17
+ type Action = {
18
+ type: ActionType["ADD_TOAST"];
19
+ toast: ToasterToast;
20
+ } | {
21
+ type: ActionType["UPDATE_TOAST"];
22
+ toast: Partial<ToasterToast>;
23
+ } | {
24
+ type: ActionType["DISMISS_TOAST"];
25
+ toastId?: ToasterToast["id"];
26
+ } | {
27
+ type: ActionType["REMOVE_TOAST"];
28
+ toastId?: ToasterToast["id"];
29
+ };
30
+ interface State {
31
+ toasts: ToasterToast[];
32
+ }
33
+ export declare const reducer: (state: State, action: Action) => State;
34
+ type Toast = Omit<ToasterToast, "id">;
35
+ declare function toast({ ...props }: Toast): {
36
+ id: string;
37
+ dismiss: () => void;
38
+ update: (props: ToasterToast) => void;
39
+ };
40
+ declare function useToast(): {
41
+ toast: typeof toast;
42
+ dismiss: (toastId?: string) => void;
43
+ toasts: ToasterToast[];
44
+ };
45
+ export { useToast };
@@ -0,0 +1,124 @@
1
+ import * as React from "react";
2
+ const TOAST_LIMIT = 1;
3
+ const TOAST_REMOVE_DELAY = 1000000;
4
+ const actionTypes = {
5
+ ADD_TOAST: "ADD_TOAST",
6
+ UPDATE_TOAST: "UPDATE_TOAST",
7
+ DISMISS_TOAST: "DISMISS_TOAST",
8
+ REMOVE_TOAST: "REMOVE_TOAST",
9
+ };
10
+ let count = 0;
11
+ function genId() {
12
+ count = (count + 1) % Number.MAX_SAFE_INTEGER;
13
+ return count.toString();
14
+ }
15
+ const toastTimeouts = new Map();
16
+ const addToRemoveQueue = (toastId) => {
17
+ if (toastTimeouts.has(toastId)) {
18
+ return;
19
+ }
20
+ const timeout = setTimeout(() => {
21
+ toastTimeouts.delete(toastId);
22
+ dispatch({
23
+ type: "REMOVE_TOAST",
24
+ toastId: toastId,
25
+ });
26
+ }, TOAST_REMOVE_DELAY);
27
+ toastTimeouts.set(toastId, timeout);
28
+ };
29
+ export const reducer = (state, action) => {
30
+ switch (action.type) {
31
+ case "ADD_TOAST":
32
+ return {
33
+ ...state,
34
+ toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
35
+ };
36
+ case "UPDATE_TOAST":
37
+ return {
38
+ ...state,
39
+ toasts: state.toasts.map((t) => (t.id === action.toast.id ? { ...t, ...action.toast } : t)),
40
+ };
41
+ case "DISMISS_TOAST": {
42
+ const { toastId } = action;
43
+ if (toastId) {
44
+ addToRemoveQueue(toastId);
45
+ }
46
+ else {
47
+ state.toasts.forEach((toast) => {
48
+ addToRemoveQueue(toast.id);
49
+ });
50
+ }
51
+ return {
52
+ ...state,
53
+ toasts: state.toasts.map((t) => t.id === toastId || toastId === undefined
54
+ ? {
55
+ ...t,
56
+ open: false,
57
+ }
58
+ : t),
59
+ };
60
+ }
61
+ case "REMOVE_TOAST":
62
+ if (action.toastId === undefined) {
63
+ return {
64
+ ...state,
65
+ toasts: [],
66
+ };
67
+ }
68
+ return {
69
+ ...state,
70
+ toasts: state.toasts.filter((t) => t.id !== action.toastId),
71
+ };
72
+ }
73
+ };
74
+ const listeners = [];
75
+ let memoryState = { toasts: [] };
76
+ function dispatch(action) {
77
+ memoryState = reducer(memoryState, action);
78
+ listeners.forEach((listener) => {
79
+ listener(memoryState);
80
+ });
81
+ }
82
+ function toast({ ...props }) {
83
+ const id = genId();
84
+ const update = (props) => dispatch({
85
+ type: "UPDATE_TOAST",
86
+ toast: { ...props, id },
87
+ });
88
+ const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
89
+ dispatch({
90
+ type: "ADD_TOAST",
91
+ toast: {
92
+ ...props,
93
+ id,
94
+ open: true,
95
+ onOpenChange: (open) => {
96
+ if (!open)
97
+ dismiss();
98
+ },
99
+ },
100
+ });
101
+ return {
102
+ id: id,
103
+ dismiss,
104
+ update,
105
+ };
106
+ }
107
+ function useToast() {
108
+ const [state, setState] = React.useState({ toasts: [] });
109
+ React.useEffect(() => {
110
+ listeners.push(setState);
111
+ return () => {
112
+ const index = listeners.indexOf(setState);
113
+ if (index > -1) {
114
+ listeners.splice(index, 1);
115
+ }
116
+ };
117
+ }, [state]);
118
+ return {
119
+ toast,
120
+ dismiss: (toastId) => dispatch({ type: "DISMISS_TOAST", toastId }),
121
+ toasts: state.toasts,
122
+ };
123
+ }
124
+ export { useToast };
@@ -1,3 +1,12 @@
1
+ type AICompletionContextType = {
2
+ complete: (prompt: string, options?: Record<string, any>) => Promise<string>;
3
+ isLoading: boolean;
4
+ error: Error | null;
5
+ } | null;
6
+ export declare const AICompletionContext: import("react").Context<AICompletionContextType>;
1
7
  export declare function useAICompletion(): {
2
- complete: (prompt: string) => Promise<string>;
8
+ complete: (prompt: string, options?: Record<string, any>) => Promise<string>;
9
+ isLoading: boolean;
10
+ error: Error | null;
3
11
  };
12
+ export {};
@@ -1,5 +1,14 @@
1
- // Shared AI completion hook placeholder
1
+ import { useContext, createContext } from 'react';
2
+ export const AICompletionContext = createContext(null);
2
3
  export function useAICompletion() {
3
- // TODO: Implement shared AI completion logic or delegate to project-specific context
4
- return { complete: async (prompt) => '' };
4
+ const context = useContext(AICompletionContext);
5
+ if (!context) {
6
+ // Fallback for projects that don't use AICompletionProvider
7
+ return {
8
+ complete: async (prompt) => '',
9
+ isLoading: false,
10
+ error: null,
11
+ };
12
+ }
13
+ return context;
5
14
  }
@@ -1,3 +1,10 @@
1
+ type AnalyticsContextType = {
2
+ track: (event: string, data?: Record<string, any>) => void;
3
+ identify: (userId: string, properties?: Record<string, any>) => void;
4
+ } | null;
5
+ export declare const AnalyticsContext: import("react").Context<AnalyticsContextType>;
1
6
  export declare function useAnalytics(): {
2
- track: (event: string, data?: any) => void;
7
+ track: (event: string, data?: Record<string, any>) => void;
8
+ identify: (userId: string, properties?: Record<string, any>) => void;
3
9
  };
10
+ export {};
@@ -1,5 +1,13 @@
1
- // Shared analytics hook placeholder
1
+ import { useContext, createContext } from 'react';
2
+ export const AnalyticsContext = createContext(null);
2
3
  export function useAnalytics() {
3
- // TODO: Implement shared analytics logic or delegate to project-specific context
4
- return { track: (event, data) => { } };
4
+ const context = useContext(AnalyticsContext);
5
+ if (!context) {
6
+ // Fallback for projects that don't use AnalyticsProvider
7
+ return {
8
+ track: (event, data) => { },
9
+ identify: (userId, properties) => { },
10
+ };
11
+ }
12
+ return context;
5
13
  }
@@ -1,3 +1,12 @@
1
+ type I18nContextType = {
2
+ t: (key: string, ...args: any[]) => string;
3
+ language: string;
4
+ setLanguage: (lang: string) => void;
5
+ } | null;
6
+ export declare const I18nContext: import("react").Context<I18nContextType>;
1
7
  export declare function useI18n(): {
2
- t: (key: string) => string;
8
+ t: (key: string, ...args: any[]) => string;
9
+ language: string;
10
+ setLanguage: (lang: string) => void;
3
11
  };
12
+ export {};
@@ -1,5 +1,14 @@
1
- // Shared i18n hook placeholder
1
+ import { useContext, createContext } from 'react';
2
+ export const I18nContext = createContext(null);
2
3
  export function useI18n() {
3
- // TODO: Implement shared i18n logic or delegate to project-specific context
4
- return { t: (key) => key };
4
+ const context = useContext(I18nContext);
5
+ if (!context) {
6
+ // Fallback for projects that don't use I18nProvider
7
+ return {
8
+ t: (key) => key,
9
+ language: 'en',
10
+ setLanguage: () => { },
11
+ };
12
+ }
13
+ return context;
5
14
  }
@@ -1 +1 @@
1
- export declare function useIsMobile(breakpoint?: number): boolean;
1
+ export declare function useIsMobile(): boolean;
@@ -1,12 +1,15 @@
1
1
  import * as React from "react";
2
- export function useIsMobile(breakpoint = 768) {
3
- const [isMobile, setIsMobile] = React.useState(typeof window !== "undefined" ? window.innerWidth < breakpoint : false);
2
+ const MOBILE_BREAKPOINT = 768;
3
+ export function useIsMobile() {
4
+ const [isMobile, setIsMobile] = React.useState(undefined);
4
5
  React.useEffect(() => {
5
- function handleResize() {
6
- setIsMobile(window.innerWidth < breakpoint);
7
- }
8
- window.addEventListener("resize", handleResize);
9
- return () => window.removeEventListener("resize", handleResize);
10
- }, [breakpoint]);
11
- return isMobile;
6
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
7
+ const onChange = () => {
8
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
9
+ };
10
+ mql.addEventListener("change", onChange);
11
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
12
+ return () => mql.removeEventListener("change", onChange);
13
+ }, []);
14
+ return !!isMobile;
12
15
  }
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './components/Navbar';
7
7
  export * from './components/Footer';
8
8
  export * from './hooks/useI18n';
9
9
  export * from './hooks/useAnalytics';
10
+ export * from './hooks/useAICompletion';
10
11
  export * from './utils/i18n';
11
12
  export * from './utils/analytics';
12
13
  export * from './utils/shared';
@@ -39,4 +40,6 @@ export * from './components/Skeleton';
39
40
  export * from './components/Table';
40
41
  export * from './components/Toast';
41
42
  export * from './components/Accordion';
42
- export { useToast } from './hooks/useToast';
43
+ export { useIsMobile } from './hooks/useIsMobile';
44
+ export { useToast } from './hooks/use-toast';
45
+ export { cn } from './lib/utils';
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ export * from './components/Navbar';
7
7
  export * from './components/Footer';
8
8
  export * from './hooks/useI18n';
9
9
  export * from './hooks/useAnalytics';
10
+ export * from './hooks/useAICompletion';
10
11
  export * from './utils/i18n';
11
12
  export * from './utils/analytics';
12
13
  export * from './utils/shared';
@@ -41,5 +42,7 @@ export * from './components/Table';
41
42
  export * from './components/Toast';
42
43
  // Newly added
43
44
  export * from './components/Accordion';
44
- // Export hooks
45
- export { useToast } from './hooks/useToast';
45
+ // Export shared hooks and utilities
46
+ export { useIsMobile } from './hooks/useIsMobile';
47
+ export { useToast } from './hooks/use-toast';
48
+ export { cn } from './lib/utils';
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): any;
@@ -0,0 +1,5 @@
1
+ import { clsx } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+ export function cn(...inputs) {
4
+ return twMerge(clsx(inputs));
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holie-vkit",
3
- "version": "1.1.12",
3
+ "version": "1.2.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -13,9 +13,11 @@
13
13
  "dependencies": {
14
14
  "@radix-ui/react-dropdown-menu": "^2.1.16",
15
15
  "@radix-ui/react-accordion": "^1.0.3",
16
+ "clsx": "^2.1.1",
16
17
  "lucide-react": "^0.563.0",
17
18
  "react": "^19.2.4",
18
19
  "react-dom": "^19.2.4",
20
+ "tailwind-merge": "^2.6.0",
19
21
  "zod": "^4.3.6"
20
22
  },
21
23
  "devDependencies": {