flowbite-svelte 2.0.0-next.11 → 2.0.0-next.13

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.
@@ -1,111 +0,0 @@
1
- <script module lang="ts">
2
- /**
3
- * A Svelte 5 rune-based media query hook
4
- * @param query - CSS media query string (e.g., '(min-width: 768px)')
5
- * @returns A function that returns the current match state
6
- */
7
- export function useMediaQuery(query: string): () => boolean {
8
- let matches = $state<boolean>(false);
9
-
10
- $effect(() => {
11
- if (typeof window === "undefined") return;
12
-
13
- const mediaQuery: MediaQueryList = window.matchMedia(query);
14
- matches = mediaQuery.matches;
15
-
16
- const handler = (e: MediaQueryListEvent): void => {
17
- matches = e.matches;
18
- };
19
-
20
- mediaQuery.addEventListener("change", handler);
21
-
22
- return (): void => {
23
- mediaQuery.removeEventListener("change", handler);
24
- };
25
- });
26
-
27
- return (): boolean => matches;
28
- }
29
-
30
- /**
31
- * Hook for common Tailwind CSS breakpoints
32
- * @returns Object with boolean values for each breakpoint
33
- */
34
- export function useBreakpoints() {
35
- const sm = useMediaQuery("(min-width: 640px)");
36
- const md = useMediaQuery("(min-width: 768px)");
37
- const lg = useMediaQuery("(min-width: 1024px)");
38
- const xl = useMediaQuery("(min-width: 1280px)");
39
- const xxl = useMediaQuery("(min-width: 1536px)");
40
-
41
- return {
42
- get sm() {
43
- return sm();
44
- },
45
- get md() {
46
- return md();
47
- },
48
- get lg() {
49
- return lg();
50
- },
51
- get xl() {
52
- return xl();
53
- },
54
- get "2xl"() {
55
- return xxl();
56
- },
57
- get isMobile() {
58
- return !sm();
59
- },
60
- get isTablet() {
61
- return sm() && !lg();
62
- },
63
- get isDesktop() {
64
- return lg();
65
- }
66
- };
67
- }
68
-
69
- /**
70
- * Get current breakpoint name
71
- * @returns Current breakpoint as string
72
- */
73
- export function useCurrentBreakpoint(): () => "xs" | "sm" | "md" | "lg" | "xl" | "2xl" {
74
- let currentBreakpoint = $state<"xs" | "sm" | "md" | "lg" | "xl" | "2xl">("xs");
75
-
76
- $effect(() => {
77
- if (typeof window === "undefined") return;
78
-
79
- const updateBreakpoint = (): void => {
80
- const width = window.innerWidth;
81
- if (width >= 1536) currentBreakpoint = "2xl";
82
- else if (width >= 1280) currentBreakpoint = "xl";
83
- else if (width >= 1024) currentBreakpoint = "lg";
84
- else if (width >= 768) currentBreakpoint = "md";
85
- else if (width >= 640) currentBreakpoint = "sm";
86
- else currentBreakpoint = "xs";
87
- };
88
-
89
- updateBreakpoint();
90
- window.addEventListener("resize", updateBreakpoint);
91
-
92
- return (): void => {
93
- window.removeEventListener("resize", updateBreakpoint);
94
- };
95
- });
96
-
97
- return (): "xs" | "sm" | "md" | "lg" | "xl" | "2xl" => currentBreakpoint;
98
- }
99
-
100
- // Type definitions for common breakpoint values
101
- export type BreakpointKey = "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
102
-
103
- export const BREAKPOINTS: Record<BreakpointKey, number> = {
104
- xs: 0,
105
- sm: 640,
106
- md: 768,
107
- lg: 1024,
108
- xl: 1280,
109
- "2xl": 1536
110
- } as const;
111
- </script>