@brightlocal/ui-components 2.4.0 → 2.6.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/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.js +23 -23
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +77 -3
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +403 -283
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +65 -21
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +128 -66
- package/dist/hooks/use-mobile.cjs +1 -1
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -1
- package/dist/hooks/use-mobile.js +17 -12
- package/dist/index.cjs +1 -1
- package/dist/index.js +356 -347
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +6 -6
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +37 -34
- package/package.json +1 -1
- package/src/blocks/data-table.tsx +2 -2
- package/src/blocks/sidebar.tsx +259 -21
- package/src/components/global-layout.tsx +190 -42
- package/src/components/table.tsx +75 -27
- package/src/hooks/use-mobile.ts +7 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
3
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
4
|
-
|
|
5
|
-
// Matches Tailwind's max-w-7xl (1280px) and aligns with Figma design
|
|
6
|
-
const MAX_WIDTH = "1280px";
|
|
4
|
+
import { Header } from "./header";
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* - Mobile (< 768px): Full width content, no sidebar
|
|
14
|
-
* - Tablet (768px - 1023px): Full width content, no sidebar
|
|
15
|
-
* - Desktop (≥ 1024px): Sidebar + content with max-width container
|
|
16
|
-
*
|
|
17
|
-
* @see https://ui.shadcn.com/docs/components/sidebar for sidebar patterns
|
|
7
|
+
* Container width variants for GlobalLayout, matching Figma GlobalContainer `width` property.
|
|
8
|
+
* - "xl": 1280px max-width
|
|
9
|
+
* - "lg": 1024px max-width
|
|
10
|
+
* - "sm": 640px max-width
|
|
18
11
|
*/
|
|
12
|
+
type ContainerVariant = "xl" | "lg" | "sm";
|
|
13
|
+
|
|
14
|
+
const containerMaxWidth: Record<ContainerVariant, string> = {
|
|
15
|
+
xl: "var(--ds-breakpoint-xl)",
|
|
16
|
+
lg: "var(--ds-breakpoint-lg)",
|
|
17
|
+
sm: "var(--ds-breakpoint-sm)",
|
|
18
|
+
};
|
|
19
19
|
|
|
20
20
|
interface GlobalLayoutProps extends React.ComponentProps<"div"> {
|
|
21
21
|
/**
|
|
@@ -31,7 +31,12 @@ interface GlobalLayoutProps extends React.ComponentProps<"div"> {
|
|
|
31
31
|
*/
|
|
32
32
|
trackingLabel?: string;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Container max-width variant, matching Figma GlobalContainer `width` property.
|
|
35
|
+
* @default "xl"
|
|
36
|
+
*/
|
|
37
|
+
variant?: ContainerVariant;
|
|
38
|
+
/**
|
|
39
|
+
* Custom maximum width for the global container. Overrides `variant` when set.
|
|
35
40
|
*/
|
|
36
41
|
maxWidth?: string | number;
|
|
37
42
|
}
|
|
@@ -40,7 +45,8 @@ const GlobalLayout = React.forwardRef<HTMLDivElement, GlobalLayoutProps>(
|
|
|
40
45
|
(
|
|
41
46
|
{
|
|
42
47
|
className,
|
|
43
|
-
|
|
48
|
+
variant = "xl",
|
|
49
|
+
maxWidth,
|
|
44
50
|
dataHook,
|
|
45
51
|
trackingEl,
|
|
46
52
|
trackingLabel,
|
|
@@ -49,14 +55,18 @@ const GlobalLayout = React.forwardRef<HTMLDivElement, GlobalLayoutProps>(
|
|
|
49
55
|
},
|
|
50
56
|
ref
|
|
51
57
|
) => {
|
|
52
|
-
const
|
|
53
|
-
|
|
58
|
+
const resolvedMaxWidth =
|
|
59
|
+
maxWidth != null
|
|
60
|
+
? typeof maxWidth === "number"
|
|
61
|
+
? `${maxWidth}px`
|
|
62
|
+
: maxWidth
|
|
63
|
+
: containerMaxWidth[variant];
|
|
54
64
|
|
|
55
65
|
return (
|
|
56
66
|
<div
|
|
57
67
|
ref={ref}
|
|
58
68
|
className={cn(
|
|
59
|
-
"flex
|
|
69
|
+
"py-section-sm pl-section-sm flex h-dvh w-full flex-col overflow-hidden",
|
|
60
70
|
className
|
|
61
71
|
)}
|
|
62
72
|
data-hook={dataHook}
|
|
@@ -66,9 +76,9 @@ const GlobalLayout = React.forwardRef<HTMLDivElement, GlobalLayoutProps>(
|
|
|
66
76
|
{...props}
|
|
67
77
|
>
|
|
68
78
|
<div
|
|
69
|
-
className="mx-auto flex
|
|
79
|
+
className="mx-auto flex h-full w-full"
|
|
70
80
|
data-slot="global-container"
|
|
71
|
-
style={{ maxWidth:
|
|
81
|
+
style={{ maxWidth: resolvedMaxWidth }}
|
|
72
82
|
>
|
|
73
83
|
{children}
|
|
74
84
|
</div>
|
|
@@ -102,10 +112,14 @@ const GlobalLayoutSidebar = React.forwardRef<
|
|
|
102
112
|
return (
|
|
103
113
|
<aside
|
|
104
114
|
ref={ref}
|
|
105
|
-
className={cn(
|
|
115
|
+
className={cn(
|
|
116
|
+
"focus-visible:shadow-default hidden h-full shrink-0 overflow-y-auto outline-none lg:block",
|
|
117
|
+
className
|
|
118
|
+
)}
|
|
106
119
|
data-hook={dataHook}
|
|
107
120
|
data-slot="sidebar-container"
|
|
108
121
|
style={{ width: widthStyle }}
|
|
122
|
+
tabIndex={0}
|
|
109
123
|
{...props}
|
|
110
124
|
>
|
|
111
125
|
{children}
|
|
@@ -116,12 +130,18 @@ const GlobalLayoutSidebar = React.forwardRef<
|
|
|
116
130
|
GlobalLayoutSidebar.displayName = "GlobalLayoutSidebar";
|
|
117
131
|
|
|
118
132
|
/**
|
|
119
|
-
* Content width variants for GlobalLayoutContent
|
|
120
|
-
* - "
|
|
121
|
-
* - "md":
|
|
122
|
-
* - "sm":
|
|
133
|
+
* Content width variants for GlobalLayoutContent, matching Figma Content `width` property.
|
|
134
|
+
* - "lg": 1024px max-width
|
|
135
|
+
* - "md": 768px max-width
|
|
136
|
+
* - "sm": 640px max-width
|
|
123
137
|
*/
|
|
124
|
-
type ContentVariant = "
|
|
138
|
+
type ContentVariant = "lg" | "md" | "sm";
|
|
139
|
+
|
|
140
|
+
const contentMaxWidth: Record<ContentVariant, string> = {
|
|
141
|
+
lg: "var(--ds-breakpoint-lg)",
|
|
142
|
+
md: "var(--ds-breakpoint-md)",
|
|
143
|
+
sm: "var(--ds-breakpoint-sm)",
|
|
144
|
+
};
|
|
125
145
|
|
|
126
146
|
interface GlobalLayoutContentProps extends React.ComponentProps<"div"> {
|
|
127
147
|
/**
|
|
@@ -129,10 +149,8 @@ interface GlobalLayoutContentProps extends React.ComponentProps<"div"> {
|
|
|
129
149
|
*/
|
|
130
150
|
dataHook?: string;
|
|
131
151
|
/**
|
|
132
|
-
* Content width variant
|
|
133
|
-
*
|
|
134
|
-
* - "md": 768px max-width (medium)
|
|
135
|
-
* - "sm": 374px max-width (small)
|
|
152
|
+
* Content max-width variant, matching Figma Content `width` property.
|
|
153
|
+
* @default "lg"
|
|
136
154
|
*/
|
|
137
155
|
variant?: ContentVariant;
|
|
138
156
|
/**
|
|
@@ -146,28 +164,23 @@ const GlobalLayoutContent = React.forwardRef<
|
|
|
146
164
|
GlobalLayoutContentProps
|
|
147
165
|
>(
|
|
148
166
|
(
|
|
149
|
-
{ className, variant = "
|
|
167
|
+
{ className, variant = "lg", padding, dataHook, children, ...props },
|
|
150
168
|
ref
|
|
151
169
|
) => {
|
|
152
|
-
// Aligned with Figma design and Tailwind breakpoints
|
|
153
|
-
// md: 768px - matches Tailwind's max-w-3xl
|
|
154
|
-
// sm: 374px - optimized for mobile content
|
|
155
|
-
const contentMaxWidth: Record<ContentVariant, string> = {
|
|
156
|
-
full: "100%",
|
|
157
|
-
md: "768px",
|
|
158
|
-
sm: "374px",
|
|
159
|
-
};
|
|
160
|
-
|
|
161
170
|
return (
|
|
162
171
|
<div
|
|
163
172
|
ref={ref}
|
|
164
|
-
className={cn(
|
|
173
|
+
className={cn(
|
|
174
|
+
"focus-visible:shadow-default flex h-full min-h-0 min-w-0 flex-1 overflow-y-auto outline-none",
|
|
175
|
+
className
|
|
176
|
+
)}
|
|
165
177
|
data-hook={dataHook}
|
|
166
178
|
data-slot="content-wrapper"
|
|
179
|
+
tabIndex={0}
|
|
167
180
|
{...props}
|
|
168
181
|
>
|
|
169
182
|
<div
|
|
170
|
-
className=
|
|
183
|
+
className="pr-section-sm mx-auto w-full"
|
|
171
184
|
data-slot="content-container"
|
|
172
185
|
style={{
|
|
173
186
|
maxWidth: contentMaxWidth[variant],
|
|
@@ -183,10 +196,145 @@ const GlobalLayoutContent = React.forwardRef<
|
|
|
183
196
|
|
|
184
197
|
GlobalLayoutContent.displayName = "GlobalLayoutContent";
|
|
185
198
|
|
|
186
|
-
|
|
199
|
+
interface GlobalLayoutContentHeaderProps extends React.ComponentProps<"header"> {
|
|
200
|
+
/**
|
|
201
|
+
* Data hook for automated testing (required)
|
|
202
|
+
*/
|
|
203
|
+
dataHook: string;
|
|
204
|
+
/**
|
|
205
|
+
* Tracking element identifier for analytics
|
|
206
|
+
*/
|
|
207
|
+
trackingEl?: string;
|
|
208
|
+
/**
|
|
209
|
+
* Tracking label for analytics context
|
|
210
|
+
*/
|
|
211
|
+
trackingLabel?: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const GlobalLayoutContentHeader = React.forwardRef<
|
|
215
|
+
HTMLElement,
|
|
216
|
+
GlobalLayoutContentHeaderProps
|
|
217
|
+
>(
|
|
218
|
+
(
|
|
219
|
+
{ className, dataHook, trackingEl, trackingLabel, children, ...props },
|
|
220
|
+
ref
|
|
221
|
+
) => {
|
|
222
|
+
return (
|
|
223
|
+
<Header
|
|
224
|
+
ref={ref}
|
|
225
|
+
className={cn("px-content justify-between gap-6 pb-9", className)}
|
|
226
|
+
data-slot="content-header"
|
|
227
|
+
dataHook={dataHook}
|
|
228
|
+
trackingEl={trackingEl}
|
|
229
|
+
trackingLabel={trackingLabel}
|
|
230
|
+
{...props}
|
|
231
|
+
>
|
|
232
|
+
{children}
|
|
233
|
+
</Header>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
GlobalLayoutContentHeader.displayName = "GlobalLayoutContentHeader";
|
|
239
|
+
|
|
240
|
+
interface GlobalLayoutContentBodyProps extends React.ComponentProps<"div"> {
|
|
241
|
+
/**
|
|
242
|
+
* Data hook for automated testing
|
|
243
|
+
*/
|
|
244
|
+
dataHook?: string;
|
|
245
|
+
/**
|
|
246
|
+
* Tracking element identifier for analytics
|
|
247
|
+
*/
|
|
248
|
+
trackingEl?: string;
|
|
249
|
+
/**
|
|
250
|
+
* Tracking label for analytics context
|
|
251
|
+
*/
|
|
252
|
+
trackingLabel?: string;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const GlobalLayoutContentBody = React.forwardRef<
|
|
256
|
+
HTMLDivElement,
|
|
257
|
+
GlobalLayoutContentBodyProps
|
|
258
|
+
>(
|
|
259
|
+
(
|
|
260
|
+
{ className, dataHook, trackingEl, trackingLabel, children, ...props },
|
|
261
|
+
ref
|
|
262
|
+
) => {
|
|
263
|
+
return (
|
|
264
|
+
<div
|
|
265
|
+
ref={ref}
|
|
266
|
+
className={cn("px-content flex flex-col gap-6", className)}
|
|
267
|
+
data-hook={dataHook}
|
|
268
|
+
data-slot="content-body"
|
|
269
|
+
data-tracking-el={trackingEl}
|
|
270
|
+
data-tracking-label={trackingLabel}
|
|
271
|
+
{...props}
|
|
272
|
+
>
|
|
273
|
+
{children}
|
|
274
|
+
</div>
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
GlobalLayoutContentBody.displayName = "GlobalLayoutContentBody";
|
|
280
|
+
|
|
281
|
+
interface GlobalLayoutMobileHeaderProps extends React.ComponentProps<"header"> {
|
|
282
|
+
/**
|
|
283
|
+
* Data hook for automated testing (required)
|
|
284
|
+
*/
|
|
285
|
+
dataHook: string;
|
|
286
|
+
/**
|
|
287
|
+
* Tracking element identifier for analytics
|
|
288
|
+
*/
|
|
289
|
+
trackingEl?: string;
|
|
290
|
+
/**
|
|
291
|
+
* Tracking label for analytics context
|
|
292
|
+
*/
|
|
293
|
+
trackingLabel?: string;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const GlobalLayoutMobileHeader = React.forwardRef<
|
|
297
|
+
HTMLElement,
|
|
298
|
+
GlobalLayoutMobileHeaderProps
|
|
299
|
+
>(
|
|
300
|
+
(
|
|
301
|
+
{ className, dataHook, trackingEl, trackingLabel, children, ...props },
|
|
302
|
+
ref
|
|
303
|
+
) => {
|
|
304
|
+
return (
|
|
305
|
+
<Header
|
|
306
|
+
ref={ref}
|
|
307
|
+
className={cn("gap-2.5 px-2.5 py-2 lg:hidden", className)}
|
|
308
|
+
data-slot="mobile-header"
|
|
309
|
+
dataHook={dataHook}
|
|
310
|
+
trackingEl={trackingEl}
|
|
311
|
+
trackingLabel={trackingLabel}
|
|
312
|
+
{...props}
|
|
313
|
+
>
|
|
314
|
+
{children}
|
|
315
|
+
</Header>
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
GlobalLayoutMobileHeader.displayName = "GlobalLayoutMobileHeader";
|
|
321
|
+
|
|
322
|
+
export {
|
|
323
|
+
GlobalLayout,
|
|
324
|
+
GlobalLayoutSidebar,
|
|
325
|
+
GlobalLayoutContent,
|
|
326
|
+
GlobalLayoutContentHeader,
|
|
327
|
+
GlobalLayoutContentBody,
|
|
328
|
+
GlobalLayoutMobileHeader,
|
|
329
|
+
};
|
|
187
330
|
|
|
188
331
|
export type {
|
|
332
|
+
ContainerVariant,
|
|
333
|
+
ContentVariant,
|
|
189
334
|
GlobalLayoutProps,
|
|
190
335
|
GlobalLayoutSidebarProps,
|
|
191
336
|
GlobalLayoutContentProps,
|
|
337
|
+
GlobalLayoutContentHeaderProps,
|
|
338
|
+
GlobalLayoutContentBodyProps,
|
|
339
|
+
GlobalLayoutMobileHeaderProps,
|
|
192
340
|
};
|
package/src/components/table.tsx
CHANGED
|
@@ -5,6 +5,10 @@ import { cva, type VariantProps } from "class-variance-authority";
|
|
|
5
5
|
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
7
|
|
|
8
|
+
/* -------------------------------------------------------------------------------------------------
|
|
9
|
+
* CVA Variants
|
|
10
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
11
|
+
|
|
8
12
|
const tableCellVariants = cva(
|
|
9
13
|
"align-middle bg-transparent text-foreground text-sm font-normal leading-normal break-words",
|
|
10
14
|
{
|
|
@@ -17,6 +21,7 @@ const tableCellVariants = cva(
|
|
|
17
21
|
align: {
|
|
18
22
|
left: "text-left",
|
|
19
23
|
right: "text-right",
|
|
24
|
+
center: "text-center",
|
|
20
25
|
},
|
|
21
26
|
},
|
|
22
27
|
defaultVariants: {
|
|
@@ -27,12 +32,13 @@ const tableCellVariants = cva(
|
|
|
27
32
|
);
|
|
28
33
|
|
|
29
34
|
const tableHeadVariants = cva(
|
|
30
|
-
"h-10 p-2
|
|
35
|
+
"h-10 p-2 align-middle text-muted-foreground text-sm font-medium leading-normal hover:bg-muted break-words outline-none focus-visible:shadow-default transition-[background-color,box-shadow] duration-150 ease-in-out",
|
|
31
36
|
{
|
|
32
37
|
variants: {
|
|
33
38
|
align: {
|
|
34
39
|
left: "text-left",
|
|
35
40
|
right: "text-right",
|
|
41
|
+
center: "text-center",
|
|
36
42
|
},
|
|
37
43
|
},
|
|
38
44
|
defaultVariants: {
|
|
@@ -41,6 +47,10 @@ const tableHeadVariants = cva(
|
|
|
41
47
|
}
|
|
42
48
|
);
|
|
43
49
|
|
|
50
|
+
/* -------------------------------------------------------------------------------------------------
|
|
51
|
+
* Table
|
|
52
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
53
|
+
|
|
44
54
|
interface TableProps extends React.ComponentProps<"table"> {
|
|
45
55
|
/**
|
|
46
56
|
* Data hook for automated testing (REQUIRED)
|
|
@@ -57,26 +67,32 @@ interface TableProps extends React.ComponentProps<"table"> {
|
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
const Table = React.forwardRef<HTMLTableElement, TableProps>(
|
|
60
|
-
({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) =>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
|
|
71
|
+
return (
|
|
72
|
+
<div
|
|
73
|
+
className="relative w-full overflow-x-auto"
|
|
74
|
+
data-slot="table-container"
|
|
75
|
+
>
|
|
76
|
+
<table
|
|
77
|
+
ref={ref}
|
|
78
|
+
className={cn("w-full caption-bottom text-sm", className)}
|
|
79
|
+
data-hook={dataHook}
|
|
80
|
+
data-slot="table"
|
|
81
|
+
data-tracking-el={trackingEl}
|
|
82
|
+
data-tracking-label={trackingLabel}
|
|
83
|
+
{...props}
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
76
88
|
);
|
|
77
89
|
|
|
78
90
|
Table.displayName = "Table";
|
|
79
91
|
|
|
92
|
+
/* -------------------------------------------------------------------------------------------------
|
|
93
|
+
* TableHeader
|
|
94
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
95
|
+
|
|
80
96
|
interface TableHeaderProps extends React.ComponentProps<"thead"> {
|
|
81
97
|
/**
|
|
82
98
|
* Data hook for automated testing
|
|
@@ -88,7 +104,7 @@ const TableHeader = React.forwardRef<HTMLTableSectionElement, TableHeaderProps>(
|
|
|
88
104
|
({ className, dataHook, ...props }, ref) => (
|
|
89
105
|
<thead
|
|
90
106
|
ref={ref}
|
|
91
|
-
className={cn(
|
|
107
|
+
className={cn(className)}
|
|
92
108
|
data-hook={dataHook}
|
|
93
109
|
data-slot="table-header"
|
|
94
110
|
{...props}
|
|
@@ -98,6 +114,10 @@ const TableHeader = React.forwardRef<HTMLTableSectionElement, TableHeaderProps>(
|
|
|
98
114
|
|
|
99
115
|
TableHeader.displayName = "TableHeader";
|
|
100
116
|
|
|
117
|
+
/* -------------------------------------------------------------------------------------------------
|
|
118
|
+
* TableBody
|
|
119
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
120
|
+
|
|
101
121
|
interface TableBodyProps extends React.ComponentProps<"tbody"> {
|
|
102
122
|
/**
|
|
103
123
|
* Data hook for automated testing
|
|
@@ -109,7 +129,7 @@ const TableBody = React.forwardRef<HTMLTableSectionElement, TableBodyProps>(
|
|
|
109
129
|
({ className, dataHook, ...props }, ref) => (
|
|
110
130
|
<tbody
|
|
111
131
|
ref={ref}
|
|
112
|
-
className={cn(
|
|
132
|
+
className={cn(className)}
|
|
113
133
|
data-hook={dataHook}
|
|
114
134
|
data-slot="table-body"
|
|
115
135
|
{...props}
|
|
@@ -119,6 +139,10 @@ const TableBody = React.forwardRef<HTMLTableSectionElement, TableBodyProps>(
|
|
|
119
139
|
|
|
120
140
|
TableBody.displayName = "TableBody";
|
|
121
141
|
|
|
142
|
+
/* -------------------------------------------------------------------------------------------------
|
|
143
|
+
* TableFooter
|
|
144
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
145
|
+
|
|
122
146
|
interface TableFooterProps extends React.ComponentProps<"tfoot"> {
|
|
123
147
|
/**
|
|
124
148
|
* Data hook for automated testing
|
|
@@ -130,7 +154,7 @@ const TableFooter = React.forwardRef<HTMLTableSectionElement, TableFooterProps>(
|
|
|
130
154
|
({ className, dataHook, ...props }, ref) => (
|
|
131
155
|
<tfoot
|
|
132
156
|
ref={ref}
|
|
133
|
-
className={cn("bg-muted/50
|
|
157
|
+
className={cn("bg-muted/50", className)}
|
|
134
158
|
data-hook={dataHook}
|
|
135
159
|
data-slot="table-footer"
|
|
136
160
|
{...props}
|
|
@@ -140,6 +164,10 @@ const TableFooter = React.forwardRef<HTMLTableSectionElement, TableFooterProps>(
|
|
|
140
164
|
|
|
141
165
|
TableFooter.displayName = "TableFooter";
|
|
142
166
|
|
|
167
|
+
/* -------------------------------------------------------------------------------------------------
|
|
168
|
+
* TableRow
|
|
169
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
170
|
+
|
|
143
171
|
interface TableRowProps extends React.ComponentProps<"tr"> {
|
|
144
172
|
/**
|
|
145
173
|
* Data hook for automated testing
|
|
@@ -152,7 +180,7 @@ const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(
|
|
|
152
180
|
<tr
|
|
153
181
|
ref={ref}
|
|
154
182
|
className={cn(
|
|
155
|
-
"data-[state=selected]:bg-muted
|
|
183
|
+
"data-[state=selected]:bg-muted transition-colors duration-150 ease-in-out",
|
|
156
184
|
className
|
|
157
185
|
)}
|
|
158
186
|
data-hook={dataHook}
|
|
@@ -164,6 +192,10 @@ const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(
|
|
|
164
192
|
|
|
165
193
|
TableRow.displayName = "TableRow";
|
|
166
194
|
|
|
195
|
+
/* -------------------------------------------------------------------------------------------------
|
|
196
|
+
* TableHead
|
|
197
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
198
|
+
|
|
167
199
|
interface TableHeadProps
|
|
168
200
|
extends
|
|
169
201
|
Omit<React.ComponentProps<"th">, "align">,
|
|
@@ -177,19 +209,23 @@ interface TableHeadProps
|
|
|
177
209
|
*/
|
|
178
210
|
minWidth?: string;
|
|
179
211
|
/**
|
|
180
|
-
* Text alignment for the header cell
|
|
212
|
+
* Text alignment for the header cell.
|
|
181
213
|
* @default "left"
|
|
182
214
|
*/
|
|
183
|
-
align?: "left" | "right";
|
|
215
|
+
align?: "left" | "right" | "center";
|
|
184
216
|
}
|
|
185
217
|
|
|
186
218
|
const TableHead = React.forwardRef<HTMLTableCellElement, TableHeadProps>(
|
|
187
|
-
(
|
|
219
|
+
(
|
|
220
|
+
{ className, dataHook, align, minWidth, style, scope = "col", ...props },
|
|
221
|
+
ref
|
|
222
|
+
) => (
|
|
188
223
|
<th
|
|
189
224
|
ref={ref}
|
|
190
225
|
className={cn(tableHeadVariants({ align }), className)}
|
|
191
226
|
data-hook={dataHook}
|
|
192
227
|
data-slot="table-head"
|
|
228
|
+
scope={scope}
|
|
193
229
|
style={{ minWidth, ...style }}
|
|
194
230
|
{...props}
|
|
195
231
|
/>
|
|
@@ -198,6 +234,10 @@ const TableHead = React.forwardRef<HTMLTableCellElement, TableHeadProps>(
|
|
|
198
234
|
|
|
199
235
|
TableHead.displayName = "TableHead";
|
|
200
236
|
|
|
237
|
+
/* -------------------------------------------------------------------------------------------------
|
|
238
|
+
* TableCell
|
|
239
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
240
|
+
|
|
201
241
|
interface TableCellProps
|
|
202
242
|
extends
|
|
203
243
|
Omit<React.ComponentProps<"td">, "align">,
|
|
@@ -216,10 +256,10 @@ interface TableCellProps
|
|
|
216
256
|
*/
|
|
217
257
|
size?: "default" | "md" | "lg";
|
|
218
258
|
/**
|
|
219
|
-
* Text alignment for the cell
|
|
259
|
+
* Text alignment for the cell.
|
|
220
260
|
* @default "left"
|
|
221
261
|
*/
|
|
222
|
-
align?: "left" | "right";
|
|
262
|
+
align?: "left" | "right" | "center";
|
|
223
263
|
}
|
|
224
264
|
|
|
225
265
|
const TableCell = React.forwardRef<HTMLTableCellElement, TableCellProps>(
|
|
@@ -237,6 +277,10 @@ const TableCell = React.forwardRef<HTMLTableCellElement, TableCellProps>(
|
|
|
237
277
|
|
|
238
278
|
TableCell.displayName = "TableCell";
|
|
239
279
|
|
|
280
|
+
/* -------------------------------------------------------------------------------------------------
|
|
281
|
+
* TableCaption
|
|
282
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
283
|
+
|
|
240
284
|
interface TableCaptionProps extends React.ComponentProps<"caption"> {
|
|
241
285
|
/**
|
|
242
286
|
* Data hook for automated testing
|
|
@@ -250,7 +294,7 @@ const TableCaption = React.forwardRef<
|
|
|
250
294
|
>(({ className, dataHook, ...props }, ref) => (
|
|
251
295
|
<caption
|
|
252
296
|
ref={ref}
|
|
253
|
-
className={cn("text-muted-foreground mt-4 text-sm", className)}
|
|
297
|
+
className={cn("text-muted-foreground mt-4 text-center text-sm", className)}
|
|
254
298
|
data-hook={dataHook}
|
|
255
299
|
data-slot="table-caption"
|
|
256
300
|
{...props}
|
|
@@ -259,6 +303,10 @@ const TableCaption = React.forwardRef<
|
|
|
259
303
|
|
|
260
304
|
TableCaption.displayName = "TableCaption";
|
|
261
305
|
|
|
306
|
+
/* -------------------------------------------------------------------------------------------------
|
|
307
|
+
* Exports
|
|
308
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
309
|
+
|
|
262
310
|
export {
|
|
263
311
|
Table,
|
|
264
312
|
TableHeader,
|
package/src/hooks/use-mobile.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
/** Fallback used when the CSS variable is not available (e.g. SSR) */
|
|
4
4
|
const MOBILE_BREAKPOINT_FALLBACK = 640;
|
|
5
5
|
|
|
6
|
-
function getMobileBreakpoint(): number {
|
|
6
|
+
export function getMobileBreakpoint(): number {
|
|
7
7
|
if (typeof document === "undefined") return MOBILE_BREAKPOINT_FALLBACK;
|
|
8
8
|
|
|
9
9
|
const raw = getComputedStyle(document.documentElement)
|
|
@@ -14,6 +14,12 @@ function getMobileBreakpoint(): number {
|
|
|
14
14
|
return Number.isNaN(parsed) ? MOBILE_BREAKPOINT_FALLBACK : parsed;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export function isMobileViewport(): boolean {
|
|
18
|
+
return (
|
|
19
|
+
typeof window !== "undefined" && window.innerWidth < getMobileBreakpoint()
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
export function useIsMobile() {
|
|
18
24
|
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
|
|
19
25
|
undefined
|