@yenio-pld/blocks 1.2.0-rc.1 → 1.2.0-rc.3
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/consent.cjs +2 -2
- package/dist/consent.cjs.map +1 -1
- package/dist/consent.js +2 -2
- package/dist/consent.js.map +1 -1
- package/dist/index.cjs +249 -252
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -69
- package/dist/index.d.ts +65 -69
- package/dist/index.js +252 -255
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createContext, useContext, useState,
|
|
2
|
+
import { createContext, useContext, cloneElement, useState, useRef, useEffect, useId, useCallback, useLayoutEffect } from 'react';
|
|
3
3
|
import { Skeleton } from './ui/skeleton.js';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import { Loader2, AlertTriangle, Inbox,
|
|
5
|
+
import { Loader2, AlertTriangle, Inbox, ChevronsUpDown, UserRound, LogOut, Bell, Moon, Sun, Monitor, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Pause, Play, BarChart3 } from 'lucide-react';
|
|
6
6
|
import { clsx } from 'clsx';
|
|
7
7
|
import { twMerge } from 'tailwind-merge';
|
|
8
8
|
import { Avatar, AvatarImage, AvatarFallback } from './ui/avatar.js';
|
|
9
9
|
import { Button } from './ui/button.js';
|
|
10
|
-
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent,
|
|
10
|
+
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuItem, miniMenuContentClassName, miniMenuContentDefaults } from './ui/dropdown-menu.js';
|
|
11
11
|
import { Empty, EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription, EmptyContent } from './ui/empty.js';
|
|
12
|
-
import { useTheme } from 'next-themes';
|
|
13
12
|
import { Separator } from './ui/separator.js';
|
|
14
13
|
import { SidebarProvider, Sidebar, SidebarHeader, SidebarContent, SidebarFooter, SidebarRail, SidebarInset, SidebarTrigger, useSidebar, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarGroup, SidebarGroupLabel, SidebarGroupContent } from './ui/sidebar.js';
|
|
15
14
|
import { Table, TableHeader, TableRow, TableHead, TableBody, TableCell } from './ui/table.js';
|
|
@@ -17,6 +16,7 @@ import { TooltipProvider } from './ui/tooltip.js';
|
|
|
17
16
|
import { Card, CardHeader, CardContent } from './ui/card.js';
|
|
18
17
|
import { cva } from 'class-variance-authority';
|
|
19
18
|
import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from './ui/alert-dialog.js';
|
|
19
|
+
import { useTheme } from 'next-themes';
|
|
20
20
|
import { Slider } from './ui/slider.js';
|
|
21
21
|
import { Toggle } from './ui/toggle.js';
|
|
22
22
|
import { DialogClose, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from './ui/dialog.js';
|
|
@@ -244,206 +244,6 @@ function EmptyState({
|
|
|
244
244
|
}
|
|
245
245
|
);
|
|
246
246
|
}
|
|
247
|
-
var defaultLanguages = [
|
|
248
|
-
{ key: "es-MX", label: "ES", nativeName: "Espa\xF1ol (M\xE9xico)" },
|
|
249
|
-
{ key: "en", label: "EN", nativeName: "English" }
|
|
250
|
-
];
|
|
251
|
-
var sizeClasses = {
|
|
252
|
-
sm: { button: "size-8", icon: "size-4" },
|
|
253
|
-
md: { button: "size-8", icon: "size-4" },
|
|
254
|
-
lg: { button: "size-9", icon: "size-4" }
|
|
255
|
-
};
|
|
256
|
-
var shapeClasses = {
|
|
257
|
-
rounded: "rounded-md",
|
|
258
|
-
squared: "rounded-sm",
|
|
259
|
-
pill: "rounded-full"
|
|
260
|
-
};
|
|
261
|
-
var iconTriggerClassName = "border border-border bg-transparent text-muted-foreground shadow-none hover:bg-accent hover:text-foreground dark:border-border dark:bg-transparent dark:text-muted-foreground dark:hover:bg-accent/50";
|
|
262
|
-
function LanguageSwitcher({
|
|
263
|
-
languages: propLanguages,
|
|
264
|
-
currentLanguage: propCurrentLanguage,
|
|
265
|
-
onLanguageChange: propOnLanguageChange,
|
|
266
|
-
labels = {},
|
|
267
|
-
className,
|
|
268
|
-
size = "sm",
|
|
269
|
-
shape = "rounded",
|
|
270
|
-
align = "end",
|
|
271
|
-
side = "bottom"
|
|
272
|
-
}) {
|
|
273
|
-
const context = useLanguageContext();
|
|
274
|
-
const contextLanguages = context?.languages?.map((lang) => ({
|
|
275
|
-
key: lang.code,
|
|
276
|
-
label: lang.code.toUpperCase(),
|
|
277
|
-
nativeName: lang.name
|
|
278
|
-
}));
|
|
279
|
-
const languages = propLanguages ?? contextLanguages ?? defaultLanguages;
|
|
280
|
-
const currentLanguage = propCurrentLanguage ?? context?.language ?? "en";
|
|
281
|
-
const onLanguageChange = propOnLanguageChange ?? context?.setLanguage;
|
|
282
|
-
const sizes = sizeClasses[size];
|
|
283
|
-
const shapeClass = shapeClasses[shape];
|
|
284
|
-
const accessibleName = labels.language ?? "Language";
|
|
285
|
-
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
286
|
-
/* @__PURE__ */ jsx(
|
|
287
|
-
DropdownMenuTrigger,
|
|
288
|
-
{
|
|
289
|
-
render: /* @__PURE__ */ jsx(
|
|
290
|
-
Button,
|
|
291
|
-
{
|
|
292
|
-
variant: "outline",
|
|
293
|
-
size: "icon",
|
|
294
|
-
"aria-label": accessibleName,
|
|
295
|
-
className: cn(
|
|
296
|
-
sizes.button,
|
|
297
|
-
shapeClass,
|
|
298
|
-
iconTriggerClassName,
|
|
299
|
-
className
|
|
300
|
-
)
|
|
301
|
-
}
|
|
302
|
-
),
|
|
303
|
-
children: /* @__PURE__ */ jsx(Languages, { className: sizes.icon })
|
|
304
|
-
}
|
|
305
|
-
),
|
|
306
|
-
/* @__PURE__ */ jsx(
|
|
307
|
-
DropdownMenuContent,
|
|
308
|
-
{
|
|
309
|
-
side,
|
|
310
|
-
align,
|
|
311
|
-
sideOffset: miniMenuContentDefaults.sideOffset,
|
|
312
|
-
collisionPadding: miniMenuContentDefaults.collisionPadding,
|
|
313
|
-
className: cn(miniMenuContentClassName, "min-w-0 w-auto"),
|
|
314
|
-
children: languages.map(({ key, nativeName }) => /* @__PURE__ */ jsx(
|
|
315
|
-
DropdownMenuItem,
|
|
316
|
-
{
|
|
317
|
-
onClick: () => onLanguageChange?.(key),
|
|
318
|
-
className: cn(
|
|
319
|
-
"justify-center text-xs font-semibold cursor-pointer px-3",
|
|
320
|
-
currentLanguage === key && "bg-accent text-accent-foreground"
|
|
321
|
-
),
|
|
322
|
-
children: nativeName
|
|
323
|
-
},
|
|
324
|
-
key
|
|
325
|
-
))
|
|
326
|
-
}
|
|
327
|
-
)
|
|
328
|
-
] });
|
|
329
|
-
}
|
|
330
|
-
var defaultLabels = {
|
|
331
|
-
theme: "Theme",
|
|
332
|
-
system: "System",
|
|
333
|
-
light: "Light",
|
|
334
|
-
dark: "Dark"
|
|
335
|
-
};
|
|
336
|
-
var sizeClasses2 = {
|
|
337
|
-
sm: { button: "size-8", icon: "size-4" },
|
|
338
|
-
md: { button: "size-8", icon: "size-4" },
|
|
339
|
-
lg: { button: "size-9", icon: "size-4" }
|
|
340
|
-
};
|
|
341
|
-
var shapeClasses2 = {
|
|
342
|
-
rounded: "rounded-md",
|
|
343
|
-
pill: "rounded-full"
|
|
344
|
-
};
|
|
345
|
-
var iconTriggerClassName2 = "border border-border bg-transparent text-muted-foreground shadow-none hover:bg-accent hover:text-foreground dark:border-border dark:bg-transparent dark:text-muted-foreground dark:hover:bg-accent/50";
|
|
346
|
-
var themeIcons = {
|
|
347
|
-
system: Monitor,
|
|
348
|
-
light: Sun,
|
|
349
|
-
dark: Moon
|
|
350
|
-
};
|
|
351
|
-
var themes = [
|
|
352
|
-
{ key: "system", icon: themeIcons.system },
|
|
353
|
-
{ key: "light", icon: themeIcons.light },
|
|
354
|
-
{ key: "dark", icon: themeIcons.dark }
|
|
355
|
-
];
|
|
356
|
-
function storedTheme(value) {
|
|
357
|
-
if (value === "system" || value === "light" || value === "dark") return value;
|
|
358
|
-
return void 0;
|
|
359
|
-
}
|
|
360
|
-
function ThemeSwitcher({
|
|
361
|
-
className,
|
|
362
|
-
size = "sm",
|
|
363
|
-
shape = "rounded",
|
|
364
|
-
align = "end",
|
|
365
|
-
side = "bottom",
|
|
366
|
-
labels: userLabels
|
|
367
|
-
}) {
|
|
368
|
-
const { theme, setTheme } = useTheme();
|
|
369
|
-
const [mounted, setMounted] = useState(false);
|
|
370
|
-
const sizes = sizeClasses2[size];
|
|
371
|
-
const shapeClass = shapeClasses2[shape];
|
|
372
|
-
const labels = { ...defaultLabels, ...userLabels };
|
|
373
|
-
const handleThemeClick = useCallback(
|
|
374
|
-
(themeKey) => {
|
|
375
|
-
setTheme(themeKey);
|
|
376
|
-
},
|
|
377
|
-
[setTheme]
|
|
378
|
-
);
|
|
379
|
-
useEffect(() => {
|
|
380
|
-
setMounted(true);
|
|
381
|
-
}, []);
|
|
382
|
-
if (!mounted) {
|
|
383
|
-
return /* @__PURE__ */ jsx(
|
|
384
|
-
"div",
|
|
385
|
-
{
|
|
386
|
-
"aria-hidden": true,
|
|
387
|
-
className: cn(
|
|
388
|
-
sizes.button,
|
|
389
|
-
shapeClass,
|
|
390
|
-
iconTriggerClassName2,
|
|
391
|
-
className
|
|
392
|
-
)
|
|
393
|
-
}
|
|
394
|
-
);
|
|
395
|
-
}
|
|
396
|
-
const currentTheme = storedTheme(theme);
|
|
397
|
-
const TriggerIcon = currentTheme ? themeIcons[currentTheme] : Monitor;
|
|
398
|
-
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
399
|
-
/* @__PURE__ */ jsx(
|
|
400
|
-
DropdownMenuTrigger,
|
|
401
|
-
{
|
|
402
|
-
render: /* @__PURE__ */ jsx(
|
|
403
|
-
Button,
|
|
404
|
-
{
|
|
405
|
-
"data-testid": "theme-switcher",
|
|
406
|
-
variant: "outline",
|
|
407
|
-
size: "icon",
|
|
408
|
-
"aria-label": labels.theme,
|
|
409
|
-
className: cn(
|
|
410
|
-
sizes.button,
|
|
411
|
-
shapeClass,
|
|
412
|
-
iconTriggerClassName2,
|
|
413
|
-
className
|
|
414
|
-
)
|
|
415
|
-
}
|
|
416
|
-
),
|
|
417
|
-
children: /* @__PURE__ */ jsx(TriggerIcon, { className: sizes.icon })
|
|
418
|
-
}
|
|
419
|
-
),
|
|
420
|
-
/* @__PURE__ */ jsx(
|
|
421
|
-
DropdownMenuContent,
|
|
422
|
-
{
|
|
423
|
-
side,
|
|
424
|
-
align,
|
|
425
|
-
sideOffset: miniMenuContentDefaults.sideOffset,
|
|
426
|
-
collisionPadding: miniMenuContentDefaults.collisionPadding,
|
|
427
|
-
className: miniMenuContentClassName,
|
|
428
|
-
children: themes.map(({ key, icon: Icon }) => /* @__PURE__ */ jsxs(
|
|
429
|
-
DropdownMenuItem,
|
|
430
|
-
{
|
|
431
|
-
onClick: () => handleThemeClick(key),
|
|
432
|
-
className: cn(
|
|
433
|
-
"gap-2 cursor-pointer",
|
|
434
|
-
currentTheme === key && "bg-accent text-accent-foreground [&_svg]:text-accent-foreground"
|
|
435
|
-
),
|
|
436
|
-
children: [
|
|
437
|
-
/* @__PURE__ */ jsx(Icon, { className: "size-4" }),
|
|
438
|
-
/* @__PURE__ */ jsx("span", { children: labels[key] })
|
|
439
|
-
]
|
|
440
|
-
},
|
|
441
|
-
key
|
|
442
|
-
))
|
|
443
|
-
}
|
|
444
|
-
)
|
|
445
|
-
] });
|
|
446
|
-
}
|
|
447
247
|
var DATA_TABLE_ROW_CLASS = "h-14";
|
|
448
248
|
function renderShellLink({
|
|
449
249
|
href,
|
|
@@ -581,35 +381,40 @@ function NavTabs({
|
|
|
581
381
|
}
|
|
582
382
|
var accountMenuDefaults = {
|
|
583
383
|
menu: "Account menu",
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
language: "Language",
|
|
587
|
-
system: "System",
|
|
588
|
-
light: "Light",
|
|
589
|
-
dark: "Dark"
|
|
384
|
+
account: "Account",
|
|
385
|
+
signOut: "Sign out"
|
|
590
386
|
};
|
|
387
|
+
function AccountAvatar({
|
|
388
|
+
name,
|
|
389
|
+
imageSrc,
|
|
390
|
+
imageAlt
|
|
391
|
+
}) {
|
|
392
|
+
return /* @__PURE__ */ jsxs(Avatar, { className: "size-8", children: [
|
|
393
|
+
imageSrc ? /* @__PURE__ */ jsx(
|
|
394
|
+
AvatarImage,
|
|
395
|
+
{
|
|
396
|
+
src: imageSrc,
|
|
397
|
+
alt: imageAlt,
|
|
398
|
+
width: 32,
|
|
399
|
+
height: 32,
|
|
400
|
+
keepMounted: true
|
|
401
|
+
}
|
|
402
|
+
) : null,
|
|
403
|
+
/* @__PURE__ */ jsx(AvatarFallback, { style: avatarFallbackStyle(name), children: getInitials(name) })
|
|
404
|
+
] });
|
|
405
|
+
}
|
|
591
406
|
function AccountMenu({
|
|
592
407
|
name,
|
|
593
408
|
email,
|
|
594
|
-
organization,
|
|
595
409
|
imageSrc,
|
|
596
410
|
imageAlt = "",
|
|
597
411
|
labels: userLabels,
|
|
598
|
-
|
|
599
|
-
currentLanguage,
|
|
600
|
-
onLanguageChange,
|
|
412
|
+
onAccount,
|
|
601
413
|
onSignOut
|
|
602
414
|
}) {
|
|
603
415
|
const labels = { ...accountMenuDefaults, ...userLabels };
|
|
604
416
|
const { isMobile } = useSidebar();
|
|
605
417
|
const side = isMobile ? "bottom" : "right";
|
|
606
|
-
const themeLabels = {
|
|
607
|
-
theme: labels.theme,
|
|
608
|
-
system: labels.system,
|
|
609
|
-
light: labels.light,
|
|
610
|
-
dark: labels.dark
|
|
611
|
-
};
|
|
612
|
-
const languageLabels = { language: labels.language };
|
|
613
418
|
return /* @__PURE__ */ jsx(SidebarMenu, { children: /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
614
419
|
/* @__PURE__ */ jsxs(
|
|
615
420
|
DropdownMenuTrigger,
|
|
@@ -623,23 +428,17 @@ function AccountMenu({
|
|
|
623
428
|
}
|
|
624
429
|
),
|
|
625
430
|
children: [
|
|
626
|
-
/* @__PURE__ */
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
keepMounted: true
|
|
635
|
-
}
|
|
636
|
-
) : null,
|
|
637
|
-
/* @__PURE__ */ jsx(AvatarFallback, { style: avatarFallbackStyle(name), children: getInitials(name) })
|
|
638
|
-
] }),
|
|
431
|
+
/* @__PURE__ */ jsx(
|
|
432
|
+
AccountAvatar,
|
|
433
|
+
{
|
|
434
|
+
name,
|
|
435
|
+
imageSrc,
|
|
436
|
+
imageAlt
|
|
437
|
+
}
|
|
438
|
+
),
|
|
639
439
|
/* @__PURE__ */ jsxs("span", { className: "grid min-w-0 flex-1 text-left text-sm leading-tight group-data-[collapsible=icon]:hidden", children: [
|
|
640
440
|
/* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: name }),
|
|
641
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: email })
|
|
642
|
-
organization ? /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: organization }) : null
|
|
441
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: email })
|
|
643
442
|
] }),
|
|
644
443
|
/* @__PURE__ */ jsx(ChevronsUpDown, { className: "ml-auto size-4 group-data-[collapsible=icon]:hidden" })
|
|
645
444
|
]
|
|
@@ -652,27 +451,25 @@ function AccountMenu({
|
|
|
652
451
|
align: "end",
|
|
653
452
|
className: "w-56 min-w-56",
|
|
654
453
|
children: [
|
|
655
|
-
/* @__PURE__ */
|
|
656
|
-
/* @__PURE__ */ jsx("span", { className: "block truncate font-medium", children: name }),
|
|
657
|
-
/* @__PURE__ */ jsx("span", { className: "block truncate text-xs text-muted-foreground", children: email }),
|
|
658
|
-
organization ? /* @__PURE__ */ jsx("span", { className: "block truncate text-xs text-muted-foreground", children: organization }) : null
|
|
659
|
-
] }),
|
|
660
|
-
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
661
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-1 px-1.5 py-1", children: [
|
|
662
|
-
/* @__PURE__ */ jsx(ThemeSwitcher, { labels: themeLabels, side, align: "end" }),
|
|
454
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { className: "p-0 font-normal", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-1 py-1.5 text-left text-sm", children: [
|
|
663
455
|
/* @__PURE__ */ jsx(
|
|
664
|
-
|
|
456
|
+
AccountAvatar,
|
|
665
457
|
{
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
onLanguageChange,
|
|
670
|
-
side,
|
|
671
|
-
align: "end"
|
|
458
|
+
name,
|
|
459
|
+
imageSrc,
|
|
460
|
+
imageAlt
|
|
672
461
|
}
|
|
673
|
-
)
|
|
674
|
-
|
|
462
|
+
),
|
|
463
|
+
/* @__PURE__ */ jsxs("span", { className: "grid min-w-0 flex-1 text-sm leading-tight", children: [
|
|
464
|
+
/* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: name }),
|
|
465
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: email })
|
|
466
|
+
] })
|
|
467
|
+
] }) }),
|
|
675
468
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
469
|
+
onAccount ? /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: onAccount, children: [
|
|
470
|
+
/* @__PURE__ */ jsx(UserRound, {}),
|
|
471
|
+
labels.account
|
|
472
|
+
] }) : null,
|
|
676
473
|
/* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: onSignOut, children: [
|
|
677
474
|
/* @__PURE__ */ jsx(LogOut, {}),
|
|
678
475
|
labels.signOut
|
|
@@ -1699,6 +1496,206 @@ function SafeImage({
|
|
|
1699
1496
|
}
|
|
1700
1497
|
);
|
|
1701
1498
|
}
|
|
1499
|
+
var defaultLabels = {
|
|
1500
|
+
theme: "Theme",
|
|
1501
|
+
system: "System",
|
|
1502
|
+
light: "Light",
|
|
1503
|
+
dark: "Dark"
|
|
1504
|
+
};
|
|
1505
|
+
var sizeClasses = {
|
|
1506
|
+
sm: { button: "size-8", icon: "size-4" },
|
|
1507
|
+
md: { button: "size-8", icon: "size-4" },
|
|
1508
|
+
lg: { button: "size-9", icon: "size-4" }
|
|
1509
|
+
};
|
|
1510
|
+
var shapeClasses = {
|
|
1511
|
+
rounded: "rounded-md",
|
|
1512
|
+
pill: "rounded-full"
|
|
1513
|
+
};
|
|
1514
|
+
var iconTriggerClassName = "border border-border bg-transparent text-muted-foreground shadow-none hover:bg-accent hover:text-foreground dark:border-border dark:bg-transparent dark:text-muted-foreground dark:hover:bg-accent/50";
|
|
1515
|
+
var themeIcons = {
|
|
1516
|
+
system: Monitor,
|
|
1517
|
+
light: Sun,
|
|
1518
|
+
dark: Moon
|
|
1519
|
+
};
|
|
1520
|
+
var themes = [
|
|
1521
|
+
{ key: "system", icon: themeIcons.system },
|
|
1522
|
+
{ key: "light", icon: themeIcons.light },
|
|
1523
|
+
{ key: "dark", icon: themeIcons.dark }
|
|
1524
|
+
];
|
|
1525
|
+
function storedTheme(value) {
|
|
1526
|
+
if (value === "system" || value === "light" || value === "dark") return value;
|
|
1527
|
+
return void 0;
|
|
1528
|
+
}
|
|
1529
|
+
function ThemeSwitcher({
|
|
1530
|
+
className,
|
|
1531
|
+
size = "sm",
|
|
1532
|
+
shape = "rounded",
|
|
1533
|
+
align = "end",
|
|
1534
|
+
side = "bottom",
|
|
1535
|
+
labels: userLabels
|
|
1536
|
+
}) {
|
|
1537
|
+
const { theme, setTheme } = useTheme();
|
|
1538
|
+
const [mounted, setMounted] = useState(false);
|
|
1539
|
+
const sizes = sizeClasses[size];
|
|
1540
|
+
const shapeClass = shapeClasses[shape];
|
|
1541
|
+
const labels = { ...defaultLabels, ...userLabels };
|
|
1542
|
+
const handleThemeClick = useCallback(
|
|
1543
|
+
(themeKey) => {
|
|
1544
|
+
setTheme(themeKey);
|
|
1545
|
+
},
|
|
1546
|
+
[setTheme]
|
|
1547
|
+
);
|
|
1548
|
+
useEffect(() => {
|
|
1549
|
+
setMounted(true);
|
|
1550
|
+
}, []);
|
|
1551
|
+
if (!mounted) {
|
|
1552
|
+
return /* @__PURE__ */ jsx(
|
|
1553
|
+
"div",
|
|
1554
|
+
{
|
|
1555
|
+
"aria-hidden": true,
|
|
1556
|
+
className: cn(
|
|
1557
|
+
sizes.button,
|
|
1558
|
+
shapeClass,
|
|
1559
|
+
iconTriggerClassName,
|
|
1560
|
+
className
|
|
1561
|
+
)
|
|
1562
|
+
}
|
|
1563
|
+
);
|
|
1564
|
+
}
|
|
1565
|
+
const currentTheme = storedTheme(theme);
|
|
1566
|
+
const TriggerIcon = currentTheme ? themeIcons[currentTheme] : Monitor;
|
|
1567
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
1568
|
+
/* @__PURE__ */ jsx(
|
|
1569
|
+
DropdownMenuTrigger,
|
|
1570
|
+
{
|
|
1571
|
+
render: /* @__PURE__ */ jsx(
|
|
1572
|
+
Button,
|
|
1573
|
+
{
|
|
1574
|
+
"data-testid": "theme-switcher",
|
|
1575
|
+
variant: "outline",
|
|
1576
|
+
size: "icon",
|
|
1577
|
+
"aria-label": labels.theme,
|
|
1578
|
+
className: cn(
|
|
1579
|
+
sizes.button,
|
|
1580
|
+
shapeClass,
|
|
1581
|
+
iconTriggerClassName,
|
|
1582
|
+
className
|
|
1583
|
+
)
|
|
1584
|
+
}
|
|
1585
|
+
),
|
|
1586
|
+
children: /* @__PURE__ */ jsx(TriggerIcon, { className: sizes.icon })
|
|
1587
|
+
}
|
|
1588
|
+
),
|
|
1589
|
+
/* @__PURE__ */ jsx(
|
|
1590
|
+
DropdownMenuContent,
|
|
1591
|
+
{
|
|
1592
|
+
side,
|
|
1593
|
+
align,
|
|
1594
|
+
sideOffset: miniMenuContentDefaults.sideOffset,
|
|
1595
|
+
collisionPadding: miniMenuContentDefaults.collisionPadding,
|
|
1596
|
+
className: miniMenuContentClassName,
|
|
1597
|
+
children: themes.map(({ key, icon: Icon }) => /* @__PURE__ */ jsxs(
|
|
1598
|
+
DropdownMenuItem,
|
|
1599
|
+
{
|
|
1600
|
+
onClick: () => handleThemeClick(key),
|
|
1601
|
+
className: cn(
|
|
1602
|
+
"gap-2 cursor-pointer",
|
|
1603
|
+
currentTheme === key && "bg-accent text-accent-foreground [&_svg]:text-accent-foreground"
|
|
1604
|
+
),
|
|
1605
|
+
children: [
|
|
1606
|
+
/* @__PURE__ */ jsx(Icon, { className: "size-4" }),
|
|
1607
|
+
/* @__PURE__ */ jsx("span", { children: labels[key] })
|
|
1608
|
+
]
|
|
1609
|
+
},
|
|
1610
|
+
key
|
|
1611
|
+
))
|
|
1612
|
+
}
|
|
1613
|
+
)
|
|
1614
|
+
] });
|
|
1615
|
+
}
|
|
1616
|
+
var defaultLanguages = [
|
|
1617
|
+
{ key: "es-MX", label: "ES", nativeName: "Espa\xF1ol (M\xE9xico)" },
|
|
1618
|
+
{ key: "en", label: "EN", nativeName: "English" }
|
|
1619
|
+
];
|
|
1620
|
+
var sizeClasses2 = {
|
|
1621
|
+
sm: { button: "size-8", icon: "size-4" },
|
|
1622
|
+
md: { button: "size-8", icon: "size-4" },
|
|
1623
|
+
lg: { button: "size-9", icon: "size-4" }
|
|
1624
|
+
};
|
|
1625
|
+
var shapeClasses2 = {
|
|
1626
|
+
rounded: "rounded-md",
|
|
1627
|
+
squared: "rounded-sm",
|
|
1628
|
+
pill: "rounded-full"
|
|
1629
|
+
};
|
|
1630
|
+
var iconTriggerClassName2 = "border border-border bg-transparent text-muted-foreground shadow-none hover:bg-accent hover:text-foreground dark:border-border dark:bg-transparent dark:text-muted-foreground dark:hover:bg-accent/50";
|
|
1631
|
+
function LanguageSwitcher({
|
|
1632
|
+
languages: propLanguages,
|
|
1633
|
+
currentLanguage: propCurrentLanguage,
|
|
1634
|
+
onLanguageChange: propOnLanguageChange,
|
|
1635
|
+
labels = {},
|
|
1636
|
+
className,
|
|
1637
|
+
size = "sm",
|
|
1638
|
+
shape = "rounded",
|
|
1639
|
+
align = "end",
|
|
1640
|
+
side = "bottom"
|
|
1641
|
+
}) {
|
|
1642
|
+
const context = useLanguageContext();
|
|
1643
|
+
const contextLanguages = context?.languages?.map((lang) => ({
|
|
1644
|
+
key: lang.code,
|
|
1645
|
+
label: lang.code.toUpperCase(),
|
|
1646
|
+
nativeName: lang.name
|
|
1647
|
+
}));
|
|
1648
|
+
const languages = propLanguages ?? contextLanguages ?? defaultLanguages;
|
|
1649
|
+
const currentLanguage = propCurrentLanguage ?? context?.language ?? "en";
|
|
1650
|
+
const onLanguageChange = propOnLanguageChange ?? context?.setLanguage;
|
|
1651
|
+
const sizes = sizeClasses2[size];
|
|
1652
|
+
const shapeClass = shapeClasses2[shape];
|
|
1653
|
+
const accessibleName = labels.language ?? "Language";
|
|
1654
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
1655
|
+
/* @__PURE__ */ jsx(
|
|
1656
|
+
DropdownMenuTrigger,
|
|
1657
|
+
{
|
|
1658
|
+
render: /* @__PURE__ */ jsx(
|
|
1659
|
+
Button,
|
|
1660
|
+
{
|
|
1661
|
+
variant: "outline",
|
|
1662
|
+
size: "icon",
|
|
1663
|
+
"aria-label": accessibleName,
|
|
1664
|
+
className: cn(
|
|
1665
|
+
sizes.button,
|
|
1666
|
+
shapeClass,
|
|
1667
|
+
iconTriggerClassName2,
|
|
1668
|
+
className
|
|
1669
|
+
)
|
|
1670
|
+
}
|
|
1671
|
+
),
|
|
1672
|
+
children: /* @__PURE__ */ jsx(Languages, { className: sizes.icon })
|
|
1673
|
+
}
|
|
1674
|
+
),
|
|
1675
|
+
/* @__PURE__ */ jsx(
|
|
1676
|
+
DropdownMenuContent,
|
|
1677
|
+
{
|
|
1678
|
+
side,
|
|
1679
|
+
align,
|
|
1680
|
+
sideOffset: miniMenuContentDefaults.sideOffset,
|
|
1681
|
+
collisionPadding: miniMenuContentDefaults.collisionPadding,
|
|
1682
|
+
className: cn(miniMenuContentClassName, "min-w-0 w-auto"),
|
|
1683
|
+
children: languages.map(({ key, nativeName }) => /* @__PURE__ */ jsx(
|
|
1684
|
+
DropdownMenuItem,
|
|
1685
|
+
{
|
|
1686
|
+
onClick: () => onLanguageChange?.(key),
|
|
1687
|
+
className: cn(
|
|
1688
|
+
"justify-center text-xs font-semibold cursor-pointer px-3",
|
|
1689
|
+
currentLanguage === key && "bg-accent text-accent-foreground"
|
|
1690
|
+
),
|
|
1691
|
+
children: nativeName
|
|
1692
|
+
},
|
|
1693
|
+
key
|
|
1694
|
+
))
|
|
1695
|
+
}
|
|
1696
|
+
)
|
|
1697
|
+
] });
|
|
1698
|
+
}
|
|
1702
1699
|
var DEFAULT_LABELS = {
|
|
1703
1700
|
uploadAria: "Upload image",
|
|
1704
1701
|
uploadHint: "Click to upload",
|
|
@@ -3353,8 +3350,8 @@ function cookieDomainFromHostname(hostname) {
|
|
|
3353
3350
|
const host = hostname.toLowerCase();
|
|
3354
3351
|
if (host === "localhost" || host === "127.0.0.1") return void 0;
|
|
3355
3352
|
if (host.endsWith(".yenio.mx") || host === "yenio.mx") return ".yenio.mx";
|
|
3356
|
-
if (host.endsWith(".yenio
|
|
3357
|
-
return ".yenio
|
|
3353
|
+
if (host.endsWith(".yenio.workers.dev") || host === "yenio.workers.dev") {
|
|
3354
|
+
return ".yenio.workers.dev";
|
|
3358
3355
|
}
|
|
3359
3356
|
return void 0;
|
|
3360
3357
|
}
|