flowbite-svelte 1.12.1 → 1.12.2
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/utils/index.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export { default as CloseButton } from "./CloseButton.svelte";
|
|
|
3
3
|
export { closeButton } from "./theme";
|
|
4
4
|
export { trapFocus } from "./actions";
|
|
5
5
|
export { default as Popper } from "./Popper.svelte";
|
|
6
|
+
export * from "./responsive.svelte";
|
|
6
7
|
export declare function cn(...inputs: ClassValue[]): string;
|
|
7
8
|
export declare function idGenerator(): string;
|
package/dist/utils/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { default as CloseButton } from "./CloseButton.svelte";
|
|
|
4
4
|
export { closeButton } from "./theme";
|
|
5
5
|
export { trapFocus } from "./actions";
|
|
6
6
|
export { default as Popper } from "./Popper.svelte";
|
|
7
|
+
export * from "./responsive.svelte";
|
|
7
8
|
export function cn(...inputs) {
|
|
8
9
|
return twMerge(clsx(inputs));
|
|
9
10
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Svelte 5 rune-based media query hook
|
|
3
|
+
* @param query - CSS media query string (e.g., '(min-width: 768px)')
|
|
4
|
+
* @returns A function that returns the current match state
|
|
5
|
+
*/
|
|
6
|
+
export declare function useMediaQuery(query: string): () => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Hook for common Tailwind CSS breakpoints
|
|
9
|
+
* @returns Object with boolean values for each breakpoint
|
|
10
|
+
*/
|
|
11
|
+
export declare function useBreakpoints(): {
|
|
12
|
+
readonly sm: boolean;
|
|
13
|
+
readonly md: boolean;
|
|
14
|
+
readonly lg: boolean;
|
|
15
|
+
readonly xl: boolean;
|
|
16
|
+
readonly "2xl": boolean;
|
|
17
|
+
readonly isMobile: boolean;
|
|
18
|
+
readonly isTablet: boolean;
|
|
19
|
+
readonly isDesktop: boolean;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Get current breakpoint name
|
|
23
|
+
* @returns Current breakpoint as string
|
|
24
|
+
*/
|
|
25
|
+
export declare function useCurrentBreakpoint(): () => "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
|
|
26
|
+
export type BreakpointKey = "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
|
|
27
|
+
export declare const BREAKPOINTS: Record<BreakpointKey, number>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { browser } from "$app/environment";
|
|
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) {
|
|
8
|
+
let matches = $state(false);
|
|
9
|
+
$effect(() => {
|
|
10
|
+
if (!browser)
|
|
11
|
+
return;
|
|
12
|
+
const mediaQuery = window.matchMedia(query);
|
|
13
|
+
matches = mediaQuery.matches;
|
|
14
|
+
const handler = (e) => {
|
|
15
|
+
matches = e.matches;
|
|
16
|
+
};
|
|
17
|
+
mediaQuery.addEventListener("change", handler);
|
|
18
|
+
return () => {
|
|
19
|
+
mediaQuery.removeEventListener("change", handler);
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
return () => matches;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Hook for common Tailwind CSS breakpoints
|
|
26
|
+
* @returns Object with boolean values for each breakpoint
|
|
27
|
+
*/
|
|
28
|
+
export function useBreakpoints() {
|
|
29
|
+
const sm = useMediaQuery("(min-width: 640px)");
|
|
30
|
+
const md = useMediaQuery("(min-width: 768px)");
|
|
31
|
+
const lg = useMediaQuery("(min-width: 1024px)");
|
|
32
|
+
const xl = useMediaQuery("(min-width: 1280px)");
|
|
33
|
+
const xxl = useMediaQuery("(min-width: 1536px)");
|
|
34
|
+
return {
|
|
35
|
+
get sm() {
|
|
36
|
+
return sm();
|
|
37
|
+
},
|
|
38
|
+
get md() {
|
|
39
|
+
return md();
|
|
40
|
+
},
|
|
41
|
+
get lg() {
|
|
42
|
+
return lg();
|
|
43
|
+
},
|
|
44
|
+
get xl() {
|
|
45
|
+
return xl();
|
|
46
|
+
},
|
|
47
|
+
get "2xl"() {
|
|
48
|
+
return xxl();
|
|
49
|
+
},
|
|
50
|
+
get isMobile() {
|
|
51
|
+
return !sm();
|
|
52
|
+
},
|
|
53
|
+
get isTablet() {
|
|
54
|
+
return sm() && !lg();
|
|
55
|
+
},
|
|
56
|
+
get isDesktop() {
|
|
57
|
+
return lg();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get current breakpoint name
|
|
63
|
+
* @returns Current breakpoint as string
|
|
64
|
+
*/
|
|
65
|
+
export function useCurrentBreakpoint() {
|
|
66
|
+
let currentBreakpoint = $state("xs");
|
|
67
|
+
$effect(() => {
|
|
68
|
+
if (!browser)
|
|
69
|
+
return;
|
|
70
|
+
const updateBreakpoint = () => {
|
|
71
|
+
const width = window.innerWidth;
|
|
72
|
+
if (width >= 1536)
|
|
73
|
+
currentBreakpoint = "2xl";
|
|
74
|
+
else if (width >= 1280)
|
|
75
|
+
currentBreakpoint = "xl";
|
|
76
|
+
else if (width >= 1024)
|
|
77
|
+
currentBreakpoint = "lg";
|
|
78
|
+
else if (width >= 768)
|
|
79
|
+
currentBreakpoint = "md";
|
|
80
|
+
else if (width >= 640)
|
|
81
|
+
currentBreakpoint = "sm";
|
|
82
|
+
else
|
|
83
|
+
currentBreakpoint = "xs";
|
|
84
|
+
};
|
|
85
|
+
updateBreakpoint();
|
|
86
|
+
window.addEventListener("resize", updateBreakpoint);
|
|
87
|
+
return () => {
|
|
88
|
+
window.removeEventListener("resize", updateBreakpoint);
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
return () => currentBreakpoint;
|
|
92
|
+
}
|
|
93
|
+
export const BREAKPOINTS = {
|
|
94
|
+
xs: 0,
|
|
95
|
+
sm: 640,
|
|
96
|
+
md: 768,
|
|
97
|
+
lg: 1024,
|
|
98
|
+
xl: 1280,
|
|
99
|
+
"2xl": 1536
|
|
100
|
+
};
|