@kumix/ui 0.1.0 → 0.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/dist/hooks.d.ts +103 -103
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +6 -24
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +74 -58
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +313 -249
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/hooks.d.ts
CHANGED
|
@@ -301,6 +301,109 @@ declare function useIntersectionObserver(elementRef: React$1.RefObject<Element |
|
|
|
301
301
|
*/
|
|
302
302
|
declare function useIsMac(): boolean;
|
|
303
303
|
//#endregion
|
|
304
|
+
//#region src/hooks/use-is-mobile.d.ts
|
|
305
|
+
/**
|
|
306
|
+
* Mobile device detection hook for React components
|
|
307
|
+
* Provides real-time mobile/desktop state based on configurable viewport width breakpoint
|
|
308
|
+
* Uses customizable mobile breakpoint with proper SSR handling and hydration safety
|
|
309
|
+
*/
|
|
310
|
+
/**
|
|
311
|
+
* Hook to detect if the current viewport is mobile-sized based on configurable breakpoint
|
|
312
|
+
*
|
|
313
|
+
* This hook provides real-time detection of mobile vs desktop viewports with a customizable
|
|
314
|
+
* breakpoint threshold. It handles SSR properly by starting with undefined state and updating
|
|
315
|
+
* on client-side hydration to prevent hydration mismatches.
|
|
316
|
+
*
|
|
317
|
+
* The hook uses both `matchMedia` API for efficient media query listening and `window.innerWidth`
|
|
318
|
+
* for consistent viewport width detection across different browsers and devices.
|
|
319
|
+
*
|
|
320
|
+
* Features:
|
|
321
|
+
* - Real-time viewport size tracking with media query listeners
|
|
322
|
+
* - SSR-safe implementation preventing hydration mismatches
|
|
323
|
+
* - Automatic event listener cleanup on unmount
|
|
324
|
+
* - Configurable mobile breakpoint with sensible default (1024px)
|
|
325
|
+
* - Performance optimized with proper dependency management
|
|
326
|
+
* - TypeScript support with proper type definitions
|
|
327
|
+
*
|
|
328
|
+
* @param breakpoint - Custom breakpoint in pixels. Viewports smaller than this value are considered mobile. Defaults to 1024px if not provided.
|
|
329
|
+
* @returns Boolean indicating if current viewport width is smaller than the specified breakpoint (mobile-sized)
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```tsx
|
|
333
|
+
* // Basic usage with default breakpoint (1024px)
|
|
334
|
+
* function ResponsiveComponent() {
|
|
335
|
+
* const isMobile = useIsMobile();
|
|
336
|
+
*
|
|
337
|
+
* return (
|
|
338
|
+
* <div>
|
|
339
|
+
* {isMobile ? (
|
|
340
|
+
* <MobileNavigation />
|
|
341
|
+
* ) : (
|
|
342
|
+
* <DesktopNavigation />
|
|
343
|
+
* )}
|
|
344
|
+
* </div>
|
|
345
|
+
* );
|
|
346
|
+
* }
|
|
347
|
+
*
|
|
348
|
+
* // Custom breakpoint for tablet detection
|
|
349
|
+
* function TabletResponsiveComponent() {
|
|
350
|
+
* const isMobile = useIsMobile(768); // Use 768px breakpoint
|
|
351
|
+
* const isTablet = useIsMobile(1024); // Use 1024px for tablet detection
|
|
352
|
+
*
|
|
353
|
+
* return (
|
|
354
|
+
* <div className={isMobile ? 'mobile-layout' : isTablet ? 'tablet-layout' : 'desktop-layout'}>
|
|
355
|
+
* <Content />
|
|
356
|
+
* </div>
|
|
357
|
+
* );
|
|
358
|
+
* }
|
|
359
|
+
*
|
|
360
|
+
* // Conditional rendering with custom breakpoint
|
|
361
|
+
* function AdaptiveLayout() {
|
|
362
|
+
* const isSmallScreen = useIsMobile(640); // Custom small screen breakpoint
|
|
363
|
+
*
|
|
364
|
+
* return (
|
|
365
|
+
* <div className="container">
|
|
366
|
+
* {isSmallScreen ? (
|
|
367
|
+
* <div className="flex flex-col space-y-4">
|
|
368
|
+
* <MobileHeader />
|
|
369
|
+
* <MobileContent />
|
|
370
|
+
* </div>
|
|
371
|
+
* ) : (
|
|
372
|
+
* <div className="grid grid-cols-12 gap-6">
|
|
373
|
+
* <aside className="col-span-3">
|
|
374
|
+
* <Sidebar />
|
|
375
|
+
* </aside>
|
|
376
|
+
* <main className="col-span-9">
|
|
377
|
+
* <DesktopContent />
|
|
378
|
+
* </main>
|
|
379
|
+
* </div>
|
|
380
|
+
* )}
|
|
381
|
+
* </div>
|
|
382
|
+
* );
|
|
383
|
+
* }
|
|
384
|
+
*
|
|
385
|
+
* // Multiple breakpoints for different layouts
|
|
386
|
+
* function MultiBreakpointLayout() {
|
|
387
|
+
* const isMobile = useIsMobile(640); // Mobile: < 640px
|
|
388
|
+
* const isTablet = useIsMobile(1024); // Tablet: < 1024px
|
|
389
|
+
* const isDesktop = !isTablet; // Desktop: >= 1024px
|
|
390
|
+
*
|
|
391
|
+
* if (isMobile) {
|
|
392
|
+
* return <MobileLayout />;
|
|
393
|
+
* }
|
|
394
|
+
*
|
|
395
|
+
* if (isTablet) {
|
|
396
|
+
* return <TabletLayout />;
|
|
397
|
+
* }
|
|
398
|
+
*
|
|
399
|
+
* return <DesktopLayout />;
|
|
400
|
+
* }
|
|
401
|
+
* ```
|
|
402
|
+
*
|
|
403
|
+
* @since 1.0.0
|
|
404
|
+
*/
|
|
405
|
+
declare function useIsMobile(breakpoint?: number): boolean;
|
|
406
|
+
//#endregion
|
|
304
407
|
//#region src/hooks/use-media-query.d.ts
|
|
305
408
|
/**
|
|
306
409
|
* Media query hook for responsive React components
|
|
@@ -502,109 +605,6 @@ declare function useMetaColor(defaultColors?: typeof META_THEME_COLORS): {
|
|
|
502
605
|
setMetaColor: (color: string) => void;
|
|
503
606
|
};
|
|
504
607
|
//#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
608
|
//#region src/hooks/use-mutation-observer.d.ts
|
|
609
609
|
/**
|
|
610
610
|
* Hook to observe DOM mutations on a referenced element
|
package/dist/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","names":[],"sources":["../src/hooks/use-body-classes.ts","../src/hooks/use-copy-to-clipboard.ts","../src/hooks/use-file-upload.ts","../src/hooks/use-hydrated.ts","../src/hooks/use-intersection-observer.ts","../src/hooks/use-is-mac.ts","../src/hooks/use-
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","names":[],"sources":["../src/hooks/use-body-classes.ts","../src/hooks/use-copy-to-clipboard.ts","../src/hooks/use-file-upload.ts","../src/hooks/use-hydrated.ts","../src/hooks/use-intersection-observer.ts","../src/hooks/use-is-mac.ts","../src/hooks/use-is-mobile.ts","../src/hooks/use-media-query.ts","../src/hooks/use-menu.ts","../src/hooks/use-meta-color.ts","../src/hooks/use-mutation-observer.ts","../src/hooks/use-remove-ga-params.ts","../src/hooks/use-scroll-position.ts","../src/hooks/use-slider-input.ts","../src/hooks/use-viewport.ts"],"mappings":";;;;;;;;;;AA2BA;;;;AAAgD;;;;;;;;ACVxC;AAwBR;;;;cDda,cAAA,GAAkB,SAAiB;;;;;;;;AAAhD;UCdU,yBAAA;;EAER,OAAA;EDY8C;ECV9C,MAAM;AAAA;;;;;;AAAA;AAwBR;;;;;;;;;;;;;;;iBAAgB,kBAAA;EAAqB,OAAA;EAAgB;AAAA,IAAU,yBAAA;sFAWvC;2BAAA,OAAA;AAAA;;;;;ADzBwB;KELpC,YAAA;6BAEV,IAAA,UDXQ;ECaR,IAAA;EAEA,IAAA,UDXM;ECaN,GAAA,UDWgC;ECThC,EAAA;AAAA;;;;KAMU,eAAA;EDcY,yCCZtB,IAAA,EAAM,IAAA,GAAO,YAAY,EDCU;ECCnC,EAAA,UDDmD;ECGnD,OAAA;AAAA;;;;KAMU,iBAAA;EDEY,8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U;AAAA,GAAgB,mBAAA;EXrBnE,0HAAgB;8EAEL;kCAAgB;iCAMF;0DAEH;yBWqChB,OAAA,CAAM,WAAA,CAAY,gBAAA,GAAiB,KAAA,kBXrClC;0CW2DS,KAAA;AAAA;;;;;;;;Ab1GlB;;;;AAAA,KcbK,kBAAA;;;;;;;;AbGG;AAwBR;;;;;;;;;;;;;;;;;;;AAWwB;;;;AC9BxB;;;;;;;;;;AAUI;AAMJ;;;;;;;;;;AAMS;AAMT;;;;cYuBa,WAAA,QAAkB,kBA6B9B"}
|
package/dist/hooks.js
CHANGED
|
@@ -644,17 +644,6 @@ function useIsMac() {
|
|
|
644
644
|
* with SSR-safe implementation and automatic cleanup
|
|
645
645
|
*/
|
|
646
646
|
/**
|
|
647
|
-
* Helper function to safely check media query matches
|
|
648
|
-
* Prevents SSR hydration issues by checking for window availability
|
|
649
|
-
*
|
|
650
|
-
* @param query - CSS media query string to evaluate
|
|
651
|
-
* @returns Boolean indicating if the media query matches
|
|
652
|
-
*/
|
|
653
|
-
const getMatches = (query) => {
|
|
654
|
-
if (typeof window !== "undefined") return window.matchMedia(query).matches;
|
|
655
|
-
return false;
|
|
656
|
-
};
|
|
657
|
-
/**
|
|
658
647
|
* Hook for tracking CSS media query matches in React components
|
|
659
648
|
*
|
|
660
649
|
* Features:
|
|
@@ -689,23 +678,16 @@ const getMatches = (query) => {
|
|
|
689
678
|
* ```
|
|
690
679
|
*/
|
|
691
680
|
const useMediaQuery = (query) => {
|
|
692
|
-
|
|
693
|
-
const [matches, setMatches] = useState(false);
|
|
694
|
-
useEffect(() => {
|
|
695
|
-
/**
|
|
696
|
-
* Handler function to update matches state when media query changes
|
|
697
|
-
*/
|
|
698
|
-
function handleChange() {
|
|
699
|
-
setMatches(getMatches(query));
|
|
700
|
-
}
|
|
681
|
+
const subscribe = useCallback((onChange) => {
|
|
701
682
|
const matchMedia = window.matchMedia(query);
|
|
702
|
-
|
|
703
|
-
matchMedia.addEventListener("change", handleChange);
|
|
683
|
+
matchMedia.addEventListener("change", onChange);
|
|
704
684
|
return () => {
|
|
705
|
-
matchMedia.removeEventListener("change",
|
|
685
|
+
matchMedia.removeEventListener("change", onChange);
|
|
706
686
|
};
|
|
707
687
|
}, [query]);
|
|
708
|
-
|
|
688
|
+
const getSnapshot = useCallback(() => window.matchMedia(query).matches, [query]);
|
|
689
|
+
const getServerSnapshot = () => false;
|
|
690
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
709
691
|
};
|
|
710
692
|
//#endregion
|
|
711
693
|
//#region src/hooks/use-menu.ts
|