@brightlocal/ui-components 2.7.0 → 2.9.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.
- package/component-meta.json +6 -4
- package/dist/alert.cjs +1 -1
- package/dist/alert.js +1 -1
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.d.ts +74 -26
- package/dist/blocks/data-table.d.ts.map +1 -1
- package/dist/blocks/data-table.js +318 -296
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +39 -21
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +379 -425
- package/dist/callout.cjs +1 -1
- package/dist/callout.js +1 -1
- package/dist/card.cjs +1 -1
- package/dist/card.js +11 -11
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts +24 -3
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +327 -302
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +3 -3
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +90 -82
- package/dist/hooks/use-breakpoint.cjs +1 -0
- package/dist/hooks/use-breakpoint.d.ts +15 -0
- package/dist/hooks/use-breakpoint.d.ts.map +1 -0
- package/dist/hooks/use-breakpoint.js +30 -0
- package/dist/hooks/use-mobile.d.ts +13 -3
- package/dist/hooks/use-mobile.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +220 -215
- package/dist/scroll-area.cjs +1 -1
- package/dist/scroll-area.d.ts +5 -0
- package/dist/scroll-area.d.ts.map +1 -1
- package/dist/scroll-area.js +34 -25
- package/dist/split-layout.cjs +1 -1
- package/dist/split-layout.d.ts +15 -0
- package/dist/split-layout.d.ts.map +1 -1
- package/dist/split-layout.js +40 -38
- package/package.json +3 -3
- package/src/blocks/data-table.tsx +139 -76
- package/src/blocks/sidebar.tsx +134 -148
- package/src/components/alert.tsx +1 -1
- package/src/components/callout.tsx +1 -1
- package/src/components/card.tsx +1 -1
- package/src/components/combobox.tsx +72 -11
- package/src/components/global-layout.tsx +49 -40
- package/src/components/scroll-area.tsx +15 -1
- package/src/components/split-layout.tsx +19 -2
- package/src/hooks/use-breakpoint.ts +58 -0
- package/src/hooks/use-mobile.ts +20 -40
- package/src/index.ts +1 -0
- package/dist/hooks/use-mobile.cjs +0 -1
- package/dist/hooks/use-mobile.js +0 -26
|
@@ -2,6 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
4
4
|
import { Header } from "./header";
|
|
5
|
+
import { ScrollArea } from "./scroll-area";
|
|
5
6
|
|
|
6
7
|
interface GlobalLayoutProps extends React.ComponentProps<"div"> {
|
|
7
8
|
/**
|
|
@@ -40,34 +41,36 @@ const GlobalLayout = React.forwardRef<HTMLDivElement, GlobalLayoutProps>(
|
|
|
40
41
|
typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
|
|
41
42
|
|
|
42
43
|
return (
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
className
|
|
48
|
-
)}
|
|
49
|
-
data-hook={dataHook}
|
|
50
|
-
data-slot="global-layout"
|
|
51
|
-
data-tracking-el={trackingEl}
|
|
52
|
-
data-tracking-label={trackingLabel}
|
|
53
|
-
{...props}
|
|
44
|
+
<ScrollArea
|
|
45
|
+
className={cn("h-dvh w-full", className)}
|
|
46
|
+
dataHook={`${dataHook}-scroll`}
|
|
47
|
+
scrollOrientation="both"
|
|
54
48
|
>
|
|
55
49
|
<div
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
ref={ref}
|
|
51
|
+
className="py-section-sm pl-section-sm flex min-h-dvh w-full flex-col"
|
|
52
|
+
data-hook={dataHook}
|
|
53
|
+
data-slot="global-layout"
|
|
54
|
+
data-tracking-el={trackingEl}
|
|
55
|
+
data-tracking-label={trackingLabel}
|
|
56
|
+
{...props}
|
|
59
57
|
>
|
|
60
|
-
|
|
58
|
+
<div
|
|
59
|
+
className="mx-auto flex w-full flex-1"
|
|
60
|
+
data-slot="global-container"
|
|
61
|
+
style={{ maxWidth: resolvedMaxWidth }}
|
|
62
|
+
>
|
|
63
|
+
{children}
|
|
64
|
+
</div>
|
|
61
65
|
</div>
|
|
62
|
-
</
|
|
66
|
+
</ScrollArea>
|
|
63
67
|
);
|
|
64
68
|
}
|
|
65
69
|
);
|
|
66
70
|
|
|
67
71
|
GlobalLayout.displayName = "GlobalLayout";
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
const SIDEBAR_WIDTH = "256px";
|
|
73
|
+
const SIDEBAR_WIDTH = "224px";
|
|
71
74
|
|
|
72
75
|
interface GlobalLayoutSidebarProps extends React.ComponentProps<"aside"> {
|
|
73
76
|
/**
|
|
@@ -75,7 +78,7 @@ interface GlobalLayoutSidebarProps extends React.ComponentProps<"aside"> {
|
|
|
75
78
|
*/
|
|
76
79
|
dataHook?: string;
|
|
77
80
|
/**
|
|
78
|
-
* Width of the sidebar (default:
|
|
81
|
+
* Width of the sidebar (default: 224px)
|
|
79
82
|
*/
|
|
80
83
|
width?: string | number;
|
|
81
84
|
}
|
|
@@ -145,21 +148,18 @@ const GlobalLayoutContent = React.forwardRef<
|
|
|
145
148
|
return (
|
|
146
149
|
<div
|
|
147
150
|
ref={ref}
|
|
148
|
-
className={cn("flex min-w-0 flex-1", className)}
|
|
151
|
+
className={cn("pr-section-sm flex min-w-0 flex-1 flex-col", className)}
|
|
149
152
|
data-hook={dataHook}
|
|
150
153
|
data-slot="content-wrapper"
|
|
154
|
+
style={
|
|
155
|
+
{
|
|
156
|
+
"--content-max-width": resolvedMaxWidth,
|
|
157
|
+
padding,
|
|
158
|
+
} as React.CSSProperties
|
|
159
|
+
}
|
|
151
160
|
{...props}
|
|
152
161
|
>
|
|
153
|
-
|
|
154
|
-
className="pr-section-sm mx-auto w-full"
|
|
155
|
-
data-slot="content-container"
|
|
156
|
-
style={{
|
|
157
|
-
maxWidth: resolvedMaxWidth,
|
|
158
|
-
padding,
|
|
159
|
-
}}
|
|
160
|
-
>
|
|
161
|
-
{children}
|
|
162
|
-
</div>
|
|
162
|
+
{children}
|
|
163
163
|
</div>
|
|
164
164
|
);
|
|
165
165
|
}
|
|
@@ -193,7 +193,7 @@ const GlobalLayoutContentHeader = React.forwardRef<
|
|
|
193
193
|
return (
|
|
194
194
|
<Header
|
|
195
195
|
ref={ref}
|
|
196
|
-
className={cn("px-
|
|
196
|
+
className={cn("px-section-xs justify-between gap-6 pb-9", className)}
|
|
197
197
|
data-slot="content-header"
|
|
198
198
|
dataHook={dataHook}
|
|
199
199
|
trackingEl={trackingEl}
|
|
@@ -234,11 +234,15 @@ const GlobalLayoutContentBody = React.forwardRef<
|
|
|
234
234
|
return (
|
|
235
235
|
<div
|
|
236
236
|
ref={ref}
|
|
237
|
-
className={cn(
|
|
237
|
+
className={cn(
|
|
238
|
+
"px-section-xs mx-auto flex w-full flex-col gap-6",
|
|
239
|
+
className
|
|
240
|
+
)}
|
|
238
241
|
data-hook={dataHook}
|
|
239
242
|
data-slot="content-body"
|
|
240
243
|
data-tracking-el={trackingEl}
|
|
241
244
|
data-tracking-label={trackingLabel}
|
|
245
|
+
style={{ maxWidth: "var(--content-max-width)" }}
|
|
242
246
|
{...props}
|
|
243
247
|
>
|
|
244
248
|
{children}
|
|
@@ -249,7 +253,7 @@ const GlobalLayoutContentBody = React.forwardRef<
|
|
|
249
253
|
|
|
250
254
|
GlobalLayoutContentBody.displayName = "GlobalLayoutContentBody";
|
|
251
255
|
|
|
252
|
-
interface GlobalLayoutMobileHeaderProps extends React.ComponentProps<"
|
|
256
|
+
interface GlobalLayoutMobileHeaderProps extends React.ComponentProps<"div"> {
|
|
253
257
|
/**
|
|
254
258
|
* Data hook for automated testing (required)
|
|
255
259
|
*/
|
|
@@ -265,7 +269,7 @@ interface GlobalLayoutMobileHeaderProps extends React.ComponentProps<"header"> {
|
|
|
265
269
|
}
|
|
266
270
|
|
|
267
271
|
const GlobalLayoutMobileHeader = React.forwardRef<
|
|
268
|
-
|
|
272
|
+
HTMLDivElement,
|
|
269
273
|
GlobalLayoutMobileHeaderProps
|
|
270
274
|
>(
|
|
271
275
|
(
|
|
@@ -273,17 +277,22 @@ const GlobalLayoutMobileHeader = React.forwardRef<
|
|
|
273
277
|
ref
|
|
274
278
|
) => {
|
|
275
279
|
return (
|
|
276
|
-
<
|
|
280
|
+
<div
|
|
277
281
|
ref={ref}
|
|
278
|
-
|
|
282
|
+
aria-label="Mobile navigation"
|
|
283
|
+
className={cn(
|
|
284
|
+
"px-section-xs flex w-full items-center justify-start gap-2.5 py-2 lg:hidden",
|
|
285
|
+
className
|
|
286
|
+
)}
|
|
287
|
+
data-hook={dataHook}
|
|
279
288
|
data-slot="mobile-header"
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
289
|
+
data-tracking-el={trackingEl}
|
|
290
|
+
data-tracking-label={trackingLabel}
|
|
291
|
+
role="toolbar"
|
|
283
292
|
{...props}
|
|
284
293
|
>
|
|
285
294
|
{children}
|
|
286
|
-
</
|
|
295
|
+
</div>
|
|
287
296
|
);
|
|
288
297
|
}
|
|
289
298
|
);
|
|
@@ -22,6 +22,11 @@ interface ScrollAreaProps extends React.ComponentProps<
|
|
|
22
22
|
* Tracking label for analytics context
|
|
23
23
|
*/
|
|
24
24
|
trackingLabel?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Scrollbar orientation. "vertical" shows only vertical, "both" adds horizontal.
|
|
27
|
+
* @default "vertical"
|
|
28
|
+
*/
|
|
29
|
+
scrollOrientation?: "vertical" | "both";
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
/**
|
|
@@ -33,7 +38,15 @@ const ScrollArea = React.forwardRef<
|
|
|
33
38
|
ScrollAreaProps
|
|
34
39
|
>(
|
|
35
40
|
(
|
|
36
|
-
{
|
|
41
|
+
{
|
|
42
|
+
className,
|
|
43
|
+
children,
|
|
44
|
+
dataHook,
|
|
45
|
+
trackingEl,
|
|
46
|
+
trackingLabel,
|
|
47
|
+
scrollOrientation = "vertical",
|
|
48
|
+
...props
|
|
49
|
+
},
|
|
37
50
|
ref
|
|
38
51
|
) => {
|
|
39
52
|
return (
|
|
@@ -54,6 +67,7 @@ const ScrollArea = React.forwardRef<
|
|
|
54
67
|
{children}
|
|
55
68
|
</ScrollAreaPrimitive.Viewport>
|
|
56
69
|
<ScrollBar />
|
|
70
|
+
{scrollOrientation === "both" && <ScrollBar orientation="horizontal" />}
|
|
57
71
|
<ScrollAreaPrimitive.Corner />
|
|
58
72
|
</ScrollAreaPrimitive.Root>
|
|
59
73
|
);
|
|
@@ -158,6 +158,13 @@ SplitLayoutHeader.displayName = "SplitLayoutHeader";
|
|
|
158
158
|
|
|
159
159
|
interface SplitLayoutContentLeftProps extends React.ComponentProps<"div"> {
|
|
160
160
|
children: React.ReactNode;
|
|
161
|
+
/**
|
|
162
|
+
* Pins the column to the viewport on desktop (≥lg) so it stays visible
|
|
163
|
+
* while the sibling column grows beyond one screen.
|
|
164
|
+
* Applies `sticky top-0 h-screen self-start`.
|
|
165
|
+
* @default false
|
|
166
|
+
*/
|
|
167
|
+
sticky?: boolean;
|
|
161
168
|
}
|
|
162
169
|
|
|
163
170
|
/**
|
|
@@ -170,13 +177,14 @@ interface SplitLayoutContentLeftProps extends React.ComponentProps<"div"> {
|
|
|
170
177
|
const SplitLayoutContentLeft = React.forwardRef<
|
|
171
178
|
HTMLDivElement,
|
|
172
179
|
SplitLayoutContentLeftProps
|
|
173
|
-
>(({ className, children, ...props }, ref) => {
|
|
180
|
+
>(({ className, sticky = false, children, ...props }, ref) => {
|
|
174
181
|
return (
|
|
175
182
|
<div
|
|
176
183
|
ref={ref}
|
|
177
184
|
className={cn(
|
|
178
185
|
"p-section-sm col-start-1 row-start-2 flex min-h-0 items-center justify-center overflow-auto",
|
|
179
186
|
"group-has-[[data-slot=split-layout-header]]/split-layout:pt-2",
|
|
187
|
+
sticky && "lg:sticky lg:top-0 lg:h-screen lg:self-start",
|
|
180
188
|
className
|
|
181
189
|
)}
|
|
182
190
|
data-slot="split-layout-left"
|
|
@@ -201,6 +209,14 @@ interface SplitLayoutContentRightProps extends React.ComponentProps<"div"> {
|
|
|
201
209
|
* @default false
|
|
202
210
|
*/
|
|
203
211
|
flush?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Pins the column to the viewport on desktop (≥lg) so it stays visible
|
|
214
|
+
* while the sibling column grows beyond one screen.
|
|
215
|
+
* Applies `sticky top-0 h-screen self-start`.
|
|
216
|
+
* Can be combined with `flush` for a sticky full-bleed panel.
|
|
217
|
+
* @default false
|
|
218
|
+
*/
|
|
219
|
+
sticky?: boolean;
|
|
204
220
|
}
|
|
205
221
|
|
|
206
222
|
/**
|
|
@@ -215,7 +231,7 @@ interface SplitLayoutContentRightProps extends React.ComponentProps<"div"> {
|
|
|
215
231
|
const SplitLayoutContentRight = React.forwardRef<
|
|
216
232
|
HTMLDivElement,
|
|
217
233
|
SplitLayoutContentRightProps
|
|
218
|
-
>(({ className, flush = false, children, ...props }, ref) => {
|
|
234
|
+
>(({ className, flush = false, sticky = false, children, ...props }, ref) => {
|
|
219
235
|
return (
|
|
220
236
|
<div
|
|
221
237
|
ref={ref}
|
|
@@ -224,6 +240,7 @@ const SplitLayoutContentRight = React.forwardRef<
|
|
|
224
240
|
flush
|
|
225
241
|
? "relative overflow-hidden lg:block"
|
|
226
242
|
: "p-section-sm min-h-0 items-center justify-center overflow-auto lg:flex",
|
|
243
|
+
sticky && "lg:sticky lg:top-0 lg:h-screen lg:self-start",
|
|
227
244
|
className
|
|
228
245
|
)}
|
|
229
246
|
data-slot="split-layout-right"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Breakpoint name matching design token keys from `@brightlocal/tokens/breakpoints`.
|
|
5
|
+
*/
|
|
6
|
+
type Breakpoint = "sm" | "md" | "lg" | "xl" | "2xl";
|
|
7
|
+
|
|
8
|
+
/** Fallback values when CSS variables are not available (e.g. SSR) */
|
|
9
|
+
const BREAKPOINT_FALLBACKS: Record<Breakpoint, number> = {
|
|
10
|
+
sm: 640,
|
|
11
|
+
md: 768,
|
|
12
|
+
lg: 1024,
|
|
13
|
+
xl: 1280,
|
|
14
|
+
"2xl": 1536,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function getBreakpointValue(size: Breakpoint = "sm"): number {
|
|
18
|
+
if (typeof document === "undefined") return BREAKPOINT_FALLBACKS[size];
|
|
19
|
+
|
|
20
|
+
const raw = getComputedStyle(document.documentElement)
|
|
21
|
+
.getPropertyValue(`--ds-breakpoint-${size}`)
|
|
22
|
+
.trim();
|
|
23
|
+
const parsed = parseInt(raw, 10);
|
|
24
|
+
|
|
25
|
+
return Number.isNaN(parsed) ? BREAKPOINT_FALLBACKS[size] : parsed;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function isBelowBreakpoint(size: Breakpoint = "sm"): boolean {
|
|
29
|
+
return (
|
|
30
|
+
typeof window !== "undefined" &&
|
|
31
|
+
window.innerWidth < getBreakpointValue(size)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns `true` when the viewport is below the given breakpoint.
|
|
37
|
+
*
|
|
38
|
+
* @param size - Design token breakpoint name from `@brightlocal/tokens/breakpoints`
|
|
39
|
+
* @default "sm"
|
|
40
|
+
*/
|
|
41
|
+
export function useIsBelowBreakpoint(size: Breakpoint = "sm") {
|
|
42
|
+
const [isBelow, setIsBelow] = React.useState<boolean | undefined>(undefined);
|
|
43
|
+
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
const bp = getBreakpointValue(size);
|
|
46
|
+
const mql = window.matchMedia(`(max-width: ${bp - 1}px)`);
|
|
47
|
+
const onChange = () => {
|
|
48
|
+
setIsBelow(window.innerWidth < bp);
|
|
49
|
+
};
|
|
50
|
+
mql.addEventListener("change", onChange);
|
|
51
|
+
setIsBelow(window.innerWidth < bp);
|
|
52
|
+
return () => mql.removeEventListener("change", onChange);
|
|
53
|
+
}, [size]);
|
|
54
|
+
|
|
55
|
+
return !!isBelow;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type { Breakpoint };
|
package/src/hooks/use-mobile.ts
CHANGED
|
@@ -1,40 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function useIsMobile() {
|
|
24
|
-
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
|
|
25
|
-
undefined
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
React.useEffect(() => {
|
|
29
|
-
const breakpoint = getMobileBreakpoint();
|
|
30
|
-
const mql = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
|
|
31
|
-
const onChange = () => {
|
|
32
|
-
setIsMobile(window.innerWidth < breakpoint);
|
|
33
|
-
};
|
|
34
|
-
mql.addEventListener("change", onChange);
|
|
35
|
-
setIsMobile(window.innerWidth < breakpoint);
|
|
36
|
-
return () => mql.removeEventListener("change", onChange);
|
|
37
|
-
}, []);
|
|
38
|
-
|
|
39
|
-
return !!isMobile;
|
|
40
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Import from `@brightlocal/ui-components/hooks/use-breakpoint` instead.
|
|
3
|
+
* This module re-exports everything from `use-breakpoint` for backward compatibility.
|
|
4
|
+
*/
|
|
5
|
+
export {
|
|
6
|
+
getBreakpointValue,
|
|
7
|
+
isBelowBreakpoint as isMobileViewport,
|
|
8
|
+
useIsBelowBreakpoint,
|
|
9
|
+
type Breakpoint,
|
|
10
|
+
} from "./use-breakpoint";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use `getBreakpointValue()` instead.
|
|
14
|
+
*/
|
|
15
|
+
export { getBreakpointValue as getMobileBreakpoint } from "./use-breakpoint";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `useIsBelowBreakpoint("sm")` instead.
|
|
19
|
+
*/
|
|
20
|
+
export { useIsBelowBreakpoint as useIsMobile } from "./use-breakpoint";
|
package/src/index.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react");function a(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const c=a(u),s=640;function i(){if(typeof document>"u")return s;const e=getComputedStyle(document.documentElement).getPropertyValue("--ds-breakpoint-sm").trim(),t=parseInt(e,10);return Number.isNaN(t)?s:t}function d(){return typeof window<"u"&&window.innerWidth<i()}function l(){const[e,t]=c.useState(void 0);return c.useEffect(()=>{const n=i(),o=window.matchMedia(`(max-width: ${n-1}px)`),r=()=>{t(window.innerWidth<n)};return o.addEventListener("change",r),t(window.innerWidth<n),()=>o.removeEventListener("change",r)},[]),!!e}exports.getMobileBreakpoint=i;exports.isMobileViewport=d;exports.useIsMobile=l;
|
package/dist/hooks/use-mobile.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as r from "react";
|
|
2
|
-
const d = 640;
|
|
3
|
-
function s() {
|
|
4
|
-
if (typeof document > "u") return d;
|
|
5
|
-
const n = getComputedStyle(document.documentElement).getPropertyValue("--ds-breakpoint-sm").trim(), e = parseInt(n, 10);
|
|
6
|
-
return Number.isNaN(e) ? d : e;
|
|
7
|
-
}
|
|
8
|
-
function u() {
|
|
9
|
-
return typeof window < "u" && window.innerWidth < s();
|
|
10
|
-
}
|
|
11
|
-
function a() {
|
|
12
|
-
const [n, e] = r.useState(
|
|
13
|
-
void 0
|
|
14
|
-
);
|
|
15
|
-
return r.useEffect(() => {
|
|
16
|
-
const t = s(), o = window.matchMedia(`(max-width: ${t - 1}px)`), i = () => {
|
|
17
|
-
e(window.innerWidth < t);
|
|
18
|
-
};
|
|
19
|
-
return o.addEventListener("change", i), e(window.innerWidth < t), () => o.removeEventListener("change", i);
|
|
20
|
-
}, []), !!n;
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
s as getMobileBreakpoint,
|
|
24
|
-
u as isMobileViewport,
|
|
25
|
-
a as useIsMobile
|
|
26
|
-
};
|