@kumix/ui 0.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.
@@ -0,0 +1,931 @@
1
+ import * as React$1 from "react";
2
+ import React, { ChangeEvent, ComponentType, DragEvent, InputHTMLAttributes, RefObject, SVGProps } from "react";
3
+ import { META_THEME_COLORS } from "@kumix/utils";
4
+
5
+ //#region src/hooks/use-body-classes.d.ts
6
+ /**
7
+ * Body class management hook for React components.
8
+ */
9
+ /**
10
+ * Adds classes to `document.body` while the component is mounted.
11
+ * Shared classes are reference-counted, so one component unmounting does not
12
+ * remove a class that another mounted component still owns.
13
+ *
14
+ * @param className - Space-separated string of CSS class names to apply to body
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * // Single class
19
+ * useBodyClasses('dark-theme');
20
+ *
21
+ * // Multiple classes
22
+ * useBodyClasses('modal-open overflow-hidden');
23
+ *
24
+ * // Conditional classes
25
+ * useBodyClasses(isModalOpen ? 'modal-open' : '');
26
+ * ```
27
+ */
28
+ declare const useBodyClasses: (className: string) => void;
29
+ //#endregion
30
+ //#region src/hooks/use-copy-to-clipboard.d.ts
31
+ /**
32
+ * Clipboard copy functionality hook for React components.
33
+ */
34
+ /**
35
+ * Configuration options for the copy to clipboard hook
36
+ */
37
+ interface UseCopyToClipboardOptions {
38
+ /** Duration in milliseconds to show the copied state (default: 2000ms) */
39
+ timeout?: number;
40
+ /** Callback function executed after successful copy operation */
41
+ onCopy?: () => void;
42
+ }
43
+ /**
44
+ * Copies text to the clipboard and exposes temporary copied state.
45
+ *
46
+ * @param options - Configuration options for the hook
47
+ * @returns Object containing copied state and an async copy function. The copy
48
+ * function resolves to `true` when text is copied and `false` otherwise.
49
+ *
50
+ * @example
51
+ * ```tsx
52
+ * const { copied, copy } = useCopyToClipboard({
53
+ * timeout: 3000,
54
+ * onCopy: () => toast.success('Copied to clipboard!')
55
+ * });
56
+ *
57
+ * return (
58
+ * <button onClick={() => copy('Hello World')}>
59
+ * {copied ? 'Copied!' : 'Copy Text'}
60
+ * </button>
61
+ * );
62
+ * ```
63
+ */
64
+ declare function useCopyToClipboard({
65
+ timeout,
66
+ onCopy
67
+ }?: UseCopyToClipboardOptions): {
68
+ /** Whether text was recently copied (true for timeout duration) */copied: boolean; /** Function to copy text to clipboard */
69
+ copy: (value: string) => Promise<boolean>;
70
+ };
71
+ //#endregion
72
+ //#region src/hooks/use-file-upload.d.ts
73
+ /**
74
+ * Metadata structure for uploaded files
75
+ */
76
+ type FileMetadata = {
77
+ /** The name of the file */name: string; /** The size of the file in bytes */
78
+ size: number; /** The MIME type of the file */
79
+ type: string; /** The URL where the file can be accessed */
80
+ url: string; /** Unique identifier for the file */
81
+ id: string;
82
+ };
83
+ /**
84
+ * File object with preview capabilities
85
+ */
86
+ type FileWithPreview = {
87
+ /** The actual file object or metadata */file: File | FileMetadata; /** Unique identifier for the file */
88
+ id: string; /** Optional preview URL for the file (typically for images) */
89
+ preview?: string;
90
+ };
91
+ /**
92
+ * Configuration options for the file upload hook
93
+ */
94
+ type FileUploadOptions = {
95
+ /** Maximum number of files allowed (only used when multiple is true, defaults to Infinity) */maxFiles?: number; /** Maximum file size in bytes (defaults to Infinity) */
96
+ maxSize?: number; /** Accepted file types (MIME types or extensions, defaults to '*') */
97
+ accept?: string; /** Whether multiple files can be selected (defaults to false) */
98
+ multiple?: boolean; /** Initial files to populate the upload state */
99
+ initialFiles?: FileMetadata[]; /** Callback function executed when files change */
100
+ onFilesChange?: (files: FileWithPreview[]) => void; /** Callback function executed when new files are added */
101
+ onFilesAdded?: (addedFiles: FileWithPreview[]) => void; /** Callback function executed when validation errors occur */
102
+ onError?: (errors: string[]) => void;
103
+ };
104
+ /**
105
+ * Current state of the file upload component
106
+ */
107
+ type FileUploadState = {
108
+ /** Array of files currently selected/uploaded */files: FileWithPreview[]; /** Whether the user is currently dragging files over the drop zone */
109
+ isDragging: boolean; /** Array of validation error messages */
110
+ errors: string[];
111
+ };
112
+ /**
113
+ * Actions available for file upload management
114
+ */
115
+ type FileUploadActions = {
116
+ /** Add new files to the upload state */addFiles: (files: FileList | File[]) => void; /** Remove a specific file by its ID */
117
+ removeFile: (id: string) => void; /** Clear all files from the upload state */
118
+ clearFiles: () => void; /** Clear all error messages */
119
+ clearErrors: () => void; /** Handle drag enter event for drop zone */
120
+ handleDragEnter: (e: DragEvent<HTMLElement>) => void; /** Handle drag leave event for drop zone */
121
+ handleDragLeave: (e: DragEvent<HTMLElement>) => void; /** Handle drag over event for drop zone */
122
+ handleDragOver: (e: DragEvent<HTMLElement>) => void; /** Handle drop event for drop zone */
123
+ handleDrop: (e: DragEvent<HTMLElement>) => void; /** Handle file input change event */
124
+ handleFileChange: (e: ChangeEvent<HTMLInputElement>) => void; /** Programmatically open the file dialog */
125
+ openFileDialog: () => void; /** Get props for the file input element */
126
+ getInputProps: (props?: InputHTMLAttributes<HTMLInputElement>) => InputHTMLAttributes<HTMLInputElement> & {
127
+ ref: React.Ref<HTMLInputElement>;
128
+ };
129
+ };
130
+ /**
131
+ * Hook for comprehensive file upload functionality with drag & drop support
132
+ *
133
+ * Features:
134
+ * - Single and multiple file upload support
135
+ * - Drag and drop functionality
136
+ * - File validation (size, type, count)
137
+ * - Preview generation for images
138
+ * - Error handling and state management
139
+ * - Duplicate file detection
140
+ * - Memory cleanup for object URLs
141
+ *
142
+ * @param options - Configuration options for the file upload hook
143
+ * @returns Tuple containing current state and available actions
144
+ *
145
+ * @example
146
+ * ```tsx
147
+ * const [state, actions] = useFileUpload({
148
+ * maxFiles: 5,
149
+ * maxSize: 10 * 1024 * 1024, // 10MB
150
+ * accept: 'image/*',
151
+ * multiple: true,
152
+ * onFilesChange: (files) => console.log('Files changed:', files),
153
+ * onFilesAdded: (newFiles) => console.log('New files added:', newFiles)
154
+ * });
155
+ *
156
+ * return (
157
+ * <div
158
+ * onDragEnter={actions.handleDragEnter}
159
+ * onDragLeave={actions.handleDragLeave}
160
+ * onDragOver={actions.handleDragOver}
161
+ * onDrop={actions.handleDrop}
162
+ * >
163
+ * <input {...actions.getInputProps()} />
164
+ * <button onClick={actions.openFileDialog}>
165
+ * Upload Files
166
+ * </button>
167
+ * {state.files.map(file => (
168
+ * <div key={file.id}>
169
+ * {file.file.name}
170
+ * <button onClick={() => actions.removeFile(file.id)}>
171
+ * Remove
172
+ * </button>
173
+ * </div>
174
+ * ))}
175
+ * </div>
176
+ * );
177
+ * ```
178
+ */
179
+ declare const useFileUpload: (options?: FileUploadOptions) => [FileUploadState, FileUploadActions];
180
+ /**
181
+ * Helper function to format bytes to human-readable format
182
+ *
183
+ * @param bytes - The number of bytes to format
184
+ * @param decimals - Number of decimal places to show (default: 2)
185
+ * @returns Formatted string with appropriate unit (e.g., "1.5 MB")
186
+ *
187
+ * @example
188
+ * ```tsx
189
+ * formatBytes(1024); // "1 KB"
190
+ * formatBytes(1536, 1); // "1.5 KB"
191
+ * formatBytes(1048576); // "1 MB"
192
+ * ```
193
+ */
194
+ declare const formatBytes: (bytes: number, decimals?: number) => string;
195
+ //#endregion
196
+ //#region src/hooks/use-hydrated.d.ts
197
+ /**
198
+ * Hook that indicates whether code is executing on the client after hydration
199
+ *
200
+ * Features:
201
+ * - SSR-safe: returns `false` on the server to avoid hydration mismatches
202
+ * - Client-stable: returns `true` after hydration and remains stable
203
+ * - Minimal overhead: uses a no-op external store subscription
204
+ *
205
+ * @returns Boolean indicating hydration state (`true` on client, `false` on server)
206
+ *
207
+ * @example
208
+ * ```tsx
209
+ * // Conditionally render client-only components safely
210
+ * function ClientOnly() {
211
+ * const hydrated = useHydrated();
212
+ * if (!hydrated) return null;
213
+ * return <InteractiveChart />;
214
+ * }
215
+ * ```
216
+ *
217
+ * @since 1.0.0
218
+ */
219
+ declare function useHydrated(): boolean;
220
+ //#endregion
221
+ //#region src/hooks/use-intersection-observer.d.ts
222
+ /**
223
+ * Configuration options for the `useIntersectionObserver` hook.
224
+ *
225
+ * Extends the native `IntersectionObserverInit` options with an additional
226
+ * convenience flag for freezing the observer state.
227
+ */
228
+ interface IntersectionObserverOptions extends IntersectionObserverInit {
229
+ /**
230
+ * When `true`, the hook stops observing once the element becomes visible
231
+ * and keeps returning `true` for subsequent renders.
232
+ *
233
+ * This is useful for one-time animations or lazy loading where you only
234
+ * care about the first time an element enters the viewport.
235
+ */
236
+ freezeOnceVisible?: boolean;
237
+ }
238
+ /**
239
+ * React hook that tracks whether a DOM element is currently intersecting the viewport.
240
+ *
241
+ * Features:
242
+ * - Uses a shared `IntersectionObserver` instance for better performance.
243
+ * - Supports custom `threshold`, `root`, and `rootMargin` options.
244
+ * - Optional `freezeOnceVisible` flag to stop observing after first intersection.
245
+ *
246
+ * @param elementRef - React ref pointing to the DOM element to observe.
247
+ * @param options - Optional observer configuration and behavior flags.
248
+ * @param options.threshold - Intersection threshold(s) for triggering visibility changes.
249
+ * @param options.root - Scrollable ancestor element to use as the viewport (defaults to browser viewport).
250
+ * @param options.rootMargin - Margin around the root, expressed in CSS units (e.g. `"0px 0px -20% 0px"`).
251
+ * @param options.freezeOnceVisible - When `true`, stops observing after the element first becomes visible.
252
+ *
253
+ * @returns `true` when the element is intersecting based on the given options, otherwise `false`.
254
+ *
255
+ * @example
256
+ * ```tsx
257
+ * const ref = React.useRef<HTMLDivElement | null>(null);
258
+ * const isVisible = useIntersectionObserver(ref, {
259
+ * threshold: 0.2,
260
+ * rootMargin: "0px 0px -10% 0px",
261
+ * freezeOnceVisible: true,
262
+ * });
263
+ *
264
+ * return (
265
+ * <div ref={ref} className={isVisible ? "animate-in" : "opacity-0"}>
266
+ * I will animate when I enter the viewport.
267
+ * </div>
268
+ * );
269
+ * ```
270
+ */
271
+ declare function useIntersectionObserver(elementRef: React$1.RefObject<Element | null>, {
272
+ threshold,
273
+ root,
274
+ rootMargin,
275
+ freezeOnceVisible
276
+ }?: IntersectionObserverOptions): boolean;
277
+ //#endregion
278
+ //#region src/hooks/use-is-mac.d.ts
279
+ /**
280
+ * Platform detection hook for React components
281
+ * Determines whether the current user agent is running on a macOS device.
282
+ * Useful for rendering platform-specific keyboard shortcuts or UI variations.
283
+ */
284
+ /**
285
+ * React hook that returns whether the current browser reports a macOS platform.
286
+ * It prefers `navigator.userAgentData.platform` when available and falls back
287
+ * to `navigator.userAgent`.
288
+ *
289
+ * @returns `true` if the current platform is macOS, otherwise `false`.
290
+ *
291
+ * @example
292
+ * ```tsx
293
+ * const isMac = useIsMac();
294
+ *
295
+ * return (
296
+ * <kbd>
297
+ * {isMac ? "⌘" : "Ctrl"} + K
298
+ * </kbd>
299
+ * );
300
+ * ```
301
+ */
302
+ declare function useIsMac(): boolean;
303
+ //#endregion
304
+ //#region src/hooks/use-media-query.d.ts
305
+ /**
306
+ * Media query hook for responsive React components
307
+ * Provides real-time tracking of CSS media query matches
308
+ * with SSR-safe implementation and automatic cleanup
309
+ */
310
+ /**
311
+ * Hook for tracking CSS media query matches in React components
312
+ *
313
+ * Features:
314
+ * - Real-time updates when media query state changes
315
+ * - SSR-safe implementation
316
+ * - Automatic event listener cleanup
317
+ * - Supports all standard CSS media queries
318
+ *
319
+ * @param query - CSS media query string (e.g., '(min-width: 768px)')
320
+ * @returns Boolean indicating whether the media query currently matches
321
+ *
322
+ * @example
323
+ * ```tsx
324
+ * // Basic responsive behavior
325
+ * const isMobile = useMediaQuery('(max-width: 768px)');
326
+ * const isTablet = useMediaQuery('(min-width: 769px) and (max-width: 1024px)');
327
+ * const isDesktop = useMediaQuery('(min-width: 1025px)');
328
+ *
329
+ * // Dark mode preference
330
+ * const prefersDark = useMediaQuery('(prefers-color-scheme: dark)');
331
+ *
332
+ * // Reduced motion preference
333
+ * const prefersReducedMotion = useMediaQuery('(prefers-reduced-motion: reduce)');
334
+ *
335
+ * return (
336
+ * <div>
337
+ * {isMobile && <MobileLayout />}
338
+ * {isTablet && <TabletLayout />}
339
+ * {isDesktop && <DesktopLayout />}
340
+ * </div>
341
+ * );
342
+ * ```
343
+ */
344
+ declare const useMediaQuery: (query: string) => boolean;
345
+ //#endregion
346
+ //#region src/hooks/use-menu.d.ts
347
+ /**
348
+ * Menu item interface
349
+ */
350
+ interface MenuItem {
351
+ /** Heading text */
352
+ heading?: string;
353
+ /** Menu item title */
354
+ title?: string;
355
+ /** Navigation path */
356
+ path?: string;
357
+ /** Menu item icon component */
358
+ icon?: ComponentType<SVGProps<SVGSVGElement>>;
359
+ /** Whether to show separator */
360
+ separator?: boolean;
361
+ /** Root path for active state matching */
362
+ rootPath?: string;
363
+ /** Child menu items */
364
+ children?: MenuConfig;
365
+ /** Children index for nested items */
366
+ childrenIndex?: number;
367
+ /** Whether the item is external */
368
+ external?: boolean;
369
+ /** Whether the item is disabled */
370
+ disabled?: boolean;
371
+ /** Disable text */
372
+ disabledText?: string;
373
+ /** Badge text */
374
+ badge?: string;
375
+ /** Badge variant */
376
+ badgeVariant?: "primary" | "destructive" | "success" | "info" | "warning" | "secondary" | "outline";
377
+ /** Collapse configuration */
378
+ collapse?: boolean;
379
+ /** Title when collapsed */
380
+ collapseTitle?: string;
381
+ /** Title when expanded */
382
+ expandTitle?: string;
383
+ }
384
+ /**
385
+ * Type aliases for backward compatibility
386
+ */
387
+ type MenuConfig = MenuItem[];
388
+ /** Return type interface for useMenu hook */
389
+ interface UseMenuReturn {
390
+ /** Check if a specific path is currently active */
391
+ isActive: (path: string | undefined) => boolean;
392
+ /** Check if any child menu item is currently active */
393
+ hasActiveChild: (children: MenuItem[] | undefined) => boolean;
394
+ /** Check if a menu item (including its children) is currently active */
395
+ isItemActive: (item: MenuItem) => boolean;
396
+ /** Get the currently active menu item from the menu configuration */
397
+ getCurrentItem: (items: MenuConfig) => MenuItem | undefined;
398
+ /** Generate breadcrumb trail for the current active path */
399
+ getBreadcrumb: (items: MenuConfig) => MenuItem[];
400
+ /** Get child menu items at a specific level for the current active path */
401
+ getChildren: (items: MenuConfig, level: number) => MenuConfig | null;
402
+ }
403
+ /**
404
+ * Hook for managing menu navigation state and utilities
405
+ *
406
+ * This hook provides comprehensive menu management functionality including:
407
+ * - Active state detection for menu items and paths
408
+ * - Hierarchical menu navigation support
409
+ * - Breadcrumb generation for current navigation path
410
+ * - Child menu extraction at specific levels
411
+ * - Support for nested menu structures
412
+ *
413
+ * @param pathname - Current pathname from router or location
414
+ * @returns Object containing menu utility functions
415
+ *
416
+ * @example
417
+ * ```tsx
418
+ * const { isActive, getBreadcrumb, getCurrentItem } = useMenu(pathname);
419
+ *
420
+ * // Check if path is active
421
+ * const isHomeActive = isActive('/dashboard');
422
+ *
423
+ * // Get breadcrumb for current path
424
+ * const breadcrumb = getBreadcrumb(menuItems);
425
+ *
426
+ * // Get current active menu item
427
+ * const currentItem = getCurrentItem(menuItems);
428
+ * ```
429
+ */
430
+ declare const useMenu: (pathname: string) => UseMenuReturn;
431
+ //#endregion
432
+ //#region src/hooks/use-meta-color.d.ts
433
+ /**
434
+ * Calculates and applies the HTML `theme-color` meta tag from `next-themes`.
435
+ * The returned setter can be used for temporary manual overrides.
436
+ *
437
+ * @param defaultColors - Optional custom color configuration (defaults to META_THEME_COLORS)
438
+ * @returns Object containing current meta color and setter function.
439
+ *
440
+ * @example
441
+ * ```tsx
442
+ * // Basic usage with default colors (supports light, dark, and system)
443
+ * function App() {
444
+ * const { metaColor, setMetaColor } = useMetaColor();
445
+ *
446
+ * // metaColor automatically updates based on theme (light/dark/system)
447
+ * useEffect(() => {
448
+ * console.log('Current meta color:', metaColor);
449
+ * }, [metaColor]);
450
+ *
451
+ * return <div>App content</div>;
452
+ * }
453
+ *
454
+ * // Custom colors with system theme support
455
+ * function CustomThemeApp() {
456
+ * const customColors = {
457
+ * light: '#f0f0f0',
458
+ * dark: '#1a1a1a',
459
+ * system: 'auto' // Will resolve to light or dark based on OS preference
460
+ * };
461
+ * const { metaColor } = useMetaColor(customColors);
462
+ *
463
+ * return <div style={{ backgroundColor: metaColor }}>Custom themed app</div>;
464
+ * }
465
+ *
466
+ * // Manual meta color override for special pages
467
+ * function SpecialPage() {
468
+ * const { setMetaColor } = useMetaColor();
469
+ *
470
+ * useEffect(() => {
471
+ * // Override meta color for this page
472
+ * setMetaColor('#ff0000');
473
+ *
474
+ * // Cleanup: reset to theme color when leaving page
475
+ * return () => {
476
+ * setMetaColor(''); // This will revert to theme-based color
477
+ * };
478
+ * }, [setMetaColor]);
479
+ *
480
+ * return <div>Special page with red theme color</div>;
481
+ * }
482
+ *
483
+ * // Integration with theme switcher
484
+ * function ThemeAwareComponent() {
485
+ * const { theme, setTheme } = useTheme();
486
+ * const { metaColor } = useMetaColor();
487
+ *
488
+ * return (
489
+ * <div>
490
+ * <p>Current theme: {theme}</p>
491
+ * <p>Meta color: {metaColor}</p>
492
+ * <button onClick={() => setTheme('light')}>Light</button>
493
+ * <button onClick={() => setTheme('dark')}>Dark</button>
494
+ * <button onClick={() => setTheme('system')}>System</button>
495
+ * </div>
496
+ * );
497
+ * }
498
+ * ```
499
+ */
500
+ declare function useMetaColor(defaultColors?: typeof META_THEME_COLORS): {
501
+ /** Current meta theme color based on resolved theme */metaColor: "#09090b" | "#ffffff"; /** Function to manually set meta theme color */
502
+ setMetaColor: (color: string) => void;
503
+ };
504
+ //#endregion
505
+ //#region src/hooks/use-is-mobile.d.ts
506
+ /**
507
+ * Mobile device detection hook for React components
508
+ * Provides real-time mobile/desktop state based on configurable viewport width breakpoint
509
+ * Uses customizable mobile breakpoint with proper SSR handling and hydration safety
510
+ */
511
+ /**
512
+ * Hook to detect if the current viewport is mobile-sized based on configurable breakpoint
513
+ *
514
+ * This hook provides real-time detection of mobile vs desktop viewports with a customizable
515
+ * breakpoint threshold. It handles SSR properly by starting with undefined state and updating
516
+ * on client-side hydration to prevent hydration mismatches.
517
+ *
518
+ * The hook uses both `matchMedia` API for efficient media query listening and `window.innerWidth`
519
+ * for consistent viewport width detection across different browsers and devices.
520
+ *
521
+ * Features:
522
+ * - Real-time viewport size tracking with media query listeners
523
+ * - SSR-safe implementation preventing hydration mismatches
524
+ * - Automatic event listener cleanup on unmount
525
+ * - Configurable mobile breakpoint with sensible default (1024px)
526
+ * - Performance optimized with proper dependency management
527
+ * - TypeScript support with proper type definitions
528
+ *
529
+ * @param breakpoint - Custom breakpoint in pixels. Viewports smaller than this value are considered mobile. Defaults to 1024px if not provided.
530
+ * @returns Boolean indicating if current viewport width is smaller than the specified breakpoint (mobile-sized)
531
+ *
532
+ * @example
533
+ * ```tsx
534
+ * // Basic usage with default breakpoint (1024px)
535
+ * function ResponsiveComponent() {
536
+ * const isMobile = useIsMobile();
537
+ *
538
+ * return (
539
+ * <div>
540
+ * {isMobile ? (
541
+ * <MobileNavigation />
542
+ * ) : (
543
+ * <DesktopNavigation />
544
+ * )}
545
+ * </div>
546
+ * );
547
+ * }
548
+ *
549
+ * // Custom breakpoint for tablet detection
550
+ * function TabletResponsiveComponent() {
551
+ * const isMobile = useIsMobile(768); // Use 768px breakpoint
552
+ * const isTablet = useIsMobile(1024); // Use 1024px for tablet detection
553
+ *
554
+ * return (
555
+ * <div className={isMobile ? 'mobile-layout' : isTablet ? 'tablet-layout' : 'desktop-layout'}>
556
+ * <Content />
557
+ * </div>
558
+ * );
559
+ * }
560
+ *
561
+ * // Conditional rendering with custom breakpoint
562
+ * function AdaptiveLayout() {
563
+ * const isSmallScreen = useIsMobile(640); // Custom small screen breakpoint
564
+ *
565
+ * return (
566
+ * <div className="container">
567
+ * {isSmallScreen ? (
568
+ * <div className="flex flex-col space-y-4">
569
+ * <MobileHeader />
570
+ * <MobileContent />
571
+ * </div>
572
+ * ) : (
573
+ * <div className="grid grid-cols-12 gap-6">
574
+ * <aside className="col-span-3">
575
+ * <Sidebar />
576
+ * </aside>
577
+ * <main className="col-span-9">
578
+ * <DesktopContent />
579
+ * </main>
580
+ * </div>
581
+ * )}
582
+ * </div>
583
+ * );
584
+ * }
585
+ *
586
+ * // Multiple breakpoints for different layouts
587
+ * function MultiBreakpointLayout() {
588
+ * const isMobile = useIsMobile(640); // Mobile: < 640px
589
+ * const isTablet = useIsMobile(1024); // Tablet: < 1024px
590
+ * const isDesktop = !isTablet; // Desktop: >= 1024px
591
+ *
592
+ * if (isMobile) {
593
+ * return <MobileLayout />;
594
+ * }
595
+ *
596
+ * if (isTablet) {
597
+ * return <TabletLayout />;
598
+ * }
599
+ *
600
+ * return <DesktopLayout />;
601
+ * }
602
+ * ```
603
+ *
604
+ * @since 1.0.0
605
+ */
606
+ declare function useIsMobile(breakpoint?: number): boolean;
607
+ //#endregion
608
+ //#region src/hooks/use-mutation-observer.d.ts
609
+ /**
610
+ * Hook to observe DOM mutations on a referenced element
611
+ *
612
+ * This hook provides a React-friendly way to use the MutationObserver API.
613
+ * It automatically handles observer creation, cleanup, and ref management.
614
+ * Useful for detecting DOM changes that occur outside of React's control.
615
+ *
616
+ * Features:
617
+ * - Automatic observer lifecycle management
618
+ * - Configurable observation options
619
+ * - Ref-based element targeting
620
+ * - Automatic cleanup on unmount
621
+ *
622
+ * @param ref - React ref pointing to the element to observe
623
+ * @param callback - Function called when mutations are detected
624
+ * @param options - MutationObserver configuration options
625
+ *
626
+ * @example
627
+ * ```tsx
628
+ * function DynamicContent() {
629
+ * const contentRef = useRef<HTMLDivElement>(null);
630
+ *
631
+ * // Watch for any changes to the content div
632
+ * useMutationObserver(
633
+ * contentRef,
634
+ * (mutations) => {
635
+ * mutations.forEach((mutation) => {
636
+ * console.log('DOM changed:', mutation.type);
637
+ * });
638
+ * }
639
+ * );
640
+ *
641
+ * return <div ref={contentRef}>Dynamic content here</div>;
642
+ * }
643
+ *
644
+ * // Watch only for attribute changes
645
+ * function AttributeWatcher() {
646
+ * const elementRef = useRef<HTMLElement>(null);
647
+ *
648
+ * useMutationObserver(
649
+ * elementRef,
650
+ * (mutations) => {
651
+ * mutations.forEach((mutation) => {
652
+ * if (mutation.type === 'attributes') {
653
+ * console.log('Attribute changed:', mutation.attributeName);
654
+ * }
655
+ * });
656
+ * },
657
+ * { attributes: true, childList: false, subtree: false }
658
+ * );
659
+ *
660
+ * return <div ref={elementRef}>Watched element</div>;
661
+ * }
662
+ * ```
663
+ */
664
+ declare const useMutationObserver: (ref: React$1.RefObject<HTMLElement | null>, callback: MutationCallback, options?: MutationObserverInit) => void;
665
+ //#endregion
666
+ //#region src/hooks/use-remove-ga-params.d.ts
667
+ /**
668
+ * Google Analytics linker parameter cleanup hook for React
669
+ * Safely removes the GA `_gl` query parameter from the URL after GA initialization.
670
+ */
671
+ /**
672
+ * Hook to remove the Google Analytics `_gl` query parameter from the current URL.
673
+ *
674
+ * GA's cross-domain linker temporarily appends `_gl` to URLs for attribution.
675
+ * Removing it *too early* can break attribution, so this hook waits briefly
676
+ * (≈2 seconds) to allow GA to read it, then strips the param using
677
+ * `history.replaceState` without causing a page reload or React re-render.
678
+ *
679
+ * Behavior:
680
+ * - Runs once on mount.
681
+ * - If `_gl` is present, schedules its removal after ~2000ms.
682
+ * - Uses `window.history.replaceState` to avoid navigation/re-render.
683
+ *
684
+ * @example
685
+ * ```tsx
686
+ * // app/layout.tsx or a top-level client component
687
+ * import { useRemoveGAParams } from '@/hooks/use-remove-ga-params';
688
+ *
689
+ * export default function RootLayout({ children }: { children: React.ReactNode }) {
690
+ * useRemoveGAParams();
691
+ * return <>{children}</>;
692
+ * }
693
+ * ```
694
+ */
695
+ declare function useRemoveGAParams(): void;
696
+ //#endregion
697
+ //#region src/hooks/use-scroll-position.d.ts
698
+ /**
699
+ * Configuration options for the scroll position hook
700
+ */
701
+ interface UseScrollPositionProps {
702
+ /** Optional ref to a specific scrollable element (defaults to document) */
703
+ targetRef?: RefObject<HTMLElement | Document | undefined>;
704
+ }
705
+ /**
706
+ * Hook to track scroll position of window or specific elements
707
+ *
708
+ * This hook provides real-time tracking of scroll position with support
709
+ * for both window scrolling and element-specific scrolling. It automatically
710
+ * handles event listener management and cleanup.
711
+ *
712
+ * Features:
713
+ * - Real-time scroll position tracking
714
+ * - Support for window and element scrolling
715
+ * - Automatic event listener cleanup
716
+ * - SSR-safe implementation
717
+ * - Performance optimized
718
+ *
719
+ * @param options - Configuration options for the hook
720
+ * @returns Current scroll position in pixels
721
+ *
722
+ * @example
723
+ * ```tsx
724
+ * // Track window scroll position
725
+ * function ScrollIndicator() {
726
+ * const scrollPosition = useScrollPosition();
727
+ *
728
+ * return (
729
+ * <div className="scroll-indicator">
730
+ * Scrolled: {scrollPosition}px
731
+ * </div>
732
+ * );
733
+ * }
734
+ *
735
+ * // Track specific element scroll position
736
+ * function ScrollableContent() {
737
+ * const contentRef = useRef<HTMLDivElement>(null);
738
+ * const scrollPosition = useScrollPosition({ targetRef: contentRef });
739
+ *
740
+ * return (
741
+ * <div
742
+ * ref={contentRef}
743
+ * className="h-96 overflow-y-auto"
744
+ * >
745
+ * <div className="h-[1000px]">
746
+ * <p>Scroll position: {scrollPosition}px</p>
747
+ * <p>Long content here...</p>
748
+ * </div>
749
+ * </div>
750
+ * );
751
+ * }
752
+ *
753
+ * // Show/hide header based on scroll
754
+ * function StickyHeader() {
755
+ * const scrollPosition = useScrollPosition();
756
+ * const isVisible = scrollPosition < 100;
757
+ *
758
+ * return (
759
+ * <header className={`transition-transform ${
760
+ * isVisible ? 'translate-y-0' : '-translate-y-full'
761
+ * }`}>
762
+ * Header content
763
+ * </header>
764
+ * );
765
+ * }
766
+ * ```
767
+ */
768
+ declare const useScrollPosition: ({
769
+ targetRef
770
+ }?: UseScrollPositionProps) => number;
771
+ //#endregion
772
+ //#region src/hooks/use-slider-input.d.ts
773
+ /**
774
+ * Configuration options for the slider input hook
775
+ */
776
+ interface UseSliderInputProps {
777
+ /** Minimum allowed value for the range */
778
+ minValue: number;
779
+ /** Maximum allowed value for the range */
780
+ maxValue: number;
781
+ /** Initial values for the range [min, max] */
782
+ initialValue: [number, number];
783
+ }
784
+ /**
785
+ * Hook for managing dual slider input with synchronized state
786
+ *
787
+ * This hook provides state management for components that need both
788
+ * a range slider and corresponding number inputs. It handles synchronization
789
+ * between the two input types, validation, and boundary enforcement.
790
+ *
791
+ * Features:
792
+ * - Synchronized slider and input values
793
+ * - Automatic validation and boundary enforcement
794
+ * - Prevents invalid range configurations (min > max)
795
+ * - Optimized with useCallback for performance
796
+ *
797
+ * @param props - Configuration options for the hook
798
+ * @returns Object containing state and handlers for slider and inputs
799
+ *
800
+ * @example
801
+ * ```tsx
802
+ * function PriceRangeFilter() {
803
+ * const {
804
+ * sliderValues,
805
+ * inputValues,
806
+ * handleSliderChange,
807
+ * handleInputChange,
808
+ * validateAndUpdateValue
809
+ * } = useSliderInput({
810
+ * minValue: 0,
811
+ * maxValue: 1000,
812
+ * initialValue: [100, 500]
813
+ * });
814
+ *
815
+ * return (
816
+ * <div className="price-range">
817
+ * <div className="inputs">
818
+ * <input
819
+ * type="number"
820
+ * value={inputValues[0]}
821
+ * onChange={(e) => handleInputChange(e, 0)}
822
+ * onBlur={() => validateAndUpdateValue(inputValues[0], 0)}
823
+ * placeholder="Min price"
824
+ * />
825
+ * <input
826
+ * type="number"
827
+ * value={inputValues[1]}
828
+ * onChange={(e) => handleInputChange(e, 1)}
829
+ * onBlur={() => validateAndUpdateValue(inputValues[1], 1)}
830
+ * placeholder="Max price"
831
+ * />
832
+ * </div>
833
+ *
834
+ * <Slider
835
+ * value={sliderValues}
836
+ * onValueChange={handleSliderChange}
837
+ * min={0}
838
+ * max={1000}
839
+ * step={10}
840
+ * />
841
+ * </div>
842
+ * );
843
+ * }
844
+ * ```
845
+ */
846
+ declare function useSliderInput({
847
+ minValue,
848
+ maxValue,
849
+ initialValue
850
+ }: UseSliderInputProps): {
851
+ /** Function to manually set slider values */setSliderValues: React$1.Dispatch<React$1.SetStateAction<[number, number]>>; /** Function to manually set input values */
852
+ setInputValues: React$1.Dispatch<React$1.SetStateAction<[number, number]>>; /** Current slider values [min, max] */
853
+ sliderValues: [number, number]; /** Current input values [min, max] */
854
+ inputValues: [number, number]; /** Handler for slider value changes */
855
+ handleSliderChange: (values: [number, number]) => void; /** Handler for input field changes */
856
+ handleInputChange: (e: React$1.ChangeEvent<HTMLInputElement>, index: 0 | 1) => void; /** Function to validate and update values from inputs */
857
+ validateAndUpdateValue: (value: number, index: 0 | 1) => void;
858
+ };
859
+ //#endregion
860
+ //#region src/hooks/use-viewport.d.ts
861
+ /**
862
+ * Viewport dimensions tracking hook for React components
863
+ * Provides real-time viewport width and height with automatic updates
864
+ * on window resize events with SSR-safe implementation
865
+ */
866
+ /**
867
+ * Type definition for viewport dimensions
868
+ * Returns tuple of [width, height] in pixels
869
+ */
870
+ type ViewportDimensions = [number, number];
871
+ /**
872
+ * Hook to track viewport dimensions with real-time updates
873
+ *
874
+ * This hook provides the current viewport dimensions and automatically
875
+ * updates when the window is resized. It's useful for responsive layouts,
876
+ * conditional rendering based on screen size, and dynamic calculations.
877
+ *
878
+ * Features:
879
+ * - Real-time viewport dimension tracking
880
+ * - Automatic updates on window resize
881
+ * - Performance optimized with passive event listeners
882
+ * - SSR-safe implementation
883
+ * - Returns both width and height
884
+ *
885
+ * @returns Tuple containing [width, height] in pixels
886
+ *
887
+ * @example
888
+ * ```tsx
889
+ * // Basic usage
890
+ * function ResponsiveComponent() {
891
+ * const [width, height] = useViewport();
892
+ *
893
+ * return (
894
+ * <div>
895
+ * <p>Viewport: {width}x{height}</p>
896
+ * {width > 768 ? <DesktopLayout /> : <MobileLayout />}
897
+ * </div>
898
+ * );
899
+ * }
900
+ *
901
+ * // Destructured usage
902
+ * function ViewportInfo() {
903
+ * const [width, height] = useViewport();
904
+ * const aspectRatio = (width / height).toFixed(2);
905
+ *
906
+ * return (
907
+ * <div className="viewport-info">
908
+ * <p>Width: {width}px</p>
909
+ * <p>Height: {height}px</p>
910
+ * <p>Aspect Ratio: {aspectRatio}</p>
911
+ * </div>
912
+ * );
913
+ * }
914
+ *
915
+ * // Conditional rendering based on viewport
916
+ * function AdaptiveGrid() {
917
+ * const [width] = useViewport();
918
+ * const columns = width > 1200 ? 4 : width > 768 ? 3 : width > 480 ? 2 : 1;
919
+ *
920
+ * return (
921
+ * <div className={`grid grid-cols-${columns} gap-4`}>
922
+ * {items.map(item => <GridItem key={item.id} {...item} />)}
923
+ * </div>
924
+ * );
925
+ * }
926
+ * ```
927
+ */
928
+ declare const useViewport: () => ViewportDimensions;
929
+ //#endregion
930
+ export { FileMetadata, FileUploadActions, FileUploadOptions, FileUploadState, FileWithPreview, formatBytes, useBodyClasses, useCopyToClipboard, useFileUpload, useHydrated, useIntersectionObserver, useIsMac, useIsMobile, useMediaQuery, useMenu, useMetaColor, useMutationObserver, useRemoveGAParams, useScrollPosition, useSliderInput, useViewport };
931
+ //# sourceMappingURL=hooks.d.ts.map