@dilipod/ui 0.4.27 → 0.4.29

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/index.mjs CHANGED
@@ -24,6 +24,7 @@ import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
24
24
  import * as PopoverPrimitive from '@radix-ui/react-popover';
25
25
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
26
26
  import * as ToastPrimitives from '@radix-ui/react-toast';
27
+ import { differenceInHours, differenceInMinutes, formatDistanceToNow } from 'date-fns';
27
28
 
28
29
  var __defProp = Object.defineProperty;
29
30
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -391,6 +392,7 @@ __export(index_exports, {
391
392
  DropdownMenuTrigger: () => DropdownMenuTrigger,
392
393
  EmptyState: () => EmptyState,
393
394
  ErrorState: () => ErrorState,
395
+ ExpandableSection: () => ExpandableSection,
394
396
  FilePreview: () => FilePreview,
395
397
  FlowchartDiagram: () => FlowchartDiagram,
396
398
  FormField: () => FormField,
@@ -490,17 +492,27 @@ __export(index_exports, {
490
492
  WorkflowViewer: () => WorkflowViewer,
491
493
  alertVariants: () => alertVariants,
492
494
  badgeVariants: () => badgeVariants,
495
+ buttonHtml: () => buttonHtml,
493
496
  buttonVariants: () => buttonVariants,
494
497
  cn: () => cn,
498
+ emailTemplate: () => emailTemplate,
499
+ formatCentsToEuros: () => formatCentsToEuros,
500
+ formatDuration: () => formatDuration,
501
+ formatEuros: () => formatEuros,
502
+ formatRelativeTime: () => formatRelativeTime,
495
503
  getDateRangeFromPreset: () => getDateRangeFromPreset,
496
504
  iconBoxVariants: () => iconBoxVariants,
505
+ infoBoxHtml: () => infoBoxHtml,
497
506
  metricCardVariants: () => metricCardVariants,
498
507
  navigationMenuTriggerStyle: () => navigationMenuTriggerStyle,
508
+ noteBoxHtml: () => noteBoxHtml,
499
509
  progressVariants: () => progressVariants,
500
510
  statVariants: () => statVariants,
501
511
  tagVariants: () => tagVariants,
502
512
  toast: () => toast,
503
513
  usageBarVariants: () => usageBarVariants,
514
+ useExpandedSections: () => useExpandedSections,
515
+ useServiceWorker: () => useServiceWorker,
504
516
  useToast: () => useToast,
505
517
  valueVariants: () => valueVariants
506
518
  });
@@ -6736,10 +6748,218 @@ function WorkerSpec({ documentation, className }) {
6736
6748
  ] })
6737
6749
  ] }) });
6738
6750
  }
6751
+ function ExpandableSection({
6752
+ sectionKey,
6753
+ label,
6754
+ icon,
6755
+ count: count2,
6756
+ expanded,
6757
+ onToggle,
6758
+ children,
6759
+ className,
6760
+ contentClassName,
6761
+ show = true
6762
+ }) {
6763
+ if (!show) return null;
6764
+ return /* @__PURE__ */ jsxs("div", { className, children: [
6765
+ /* @__PURE__ */ jsxs(
6766
+ "button",
6767
+ {
6768
+ onClick: () => onToggle(sectionKey),
6769
+ className: "flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors w-full text-left",
6770
+ type: "button",
6771
+ children: [
6772
+ /* @__PURE__ */ jsx(
6773
+ "svg",
6774
+ {
6775
+ width: "12",
6776
+ height: "12",
6777
+ viewBox: "0 0 12 12",
6778
+ fill: "none",
6779
+ className: cn(
6780
+ "shrink-0 transition-transform",
6781
+ expanded ? "rotate-0" : "-rotate-90"
6782
+ ),
6783
+ children: /* @__PURE__ */ jsx("path", { d: "M2.5 4.5L6 8L9.5 4.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
6784
+ }
6785
+ ),
6786
+ icon,
6787
+ /* @__PURE__ */ jsx("span", { children: label }),
6788
+ count2 !== void 0 && /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground/60", children: [
6789
+ "(",
6790
+ count2,
6791
+ ")"
6792
+ ] })
6793
+ ]
6794
+ }
6795
+ ),
6796
+ expanded && /* @__PURE__ */ jsx("div", { className: cn("mt-2 pl-4", contentClassName), children })
6797
+ ] });
6798
+ }
6799
+ function useExpandedSections(initialExpanded = []) {
6800
+ const [expanded, setExpanded] = React51.useState(
6801
+ () => new Set(initialExpanded)
6802
+ );
6803
+ const toggle = React51.useCallback((key) => {
6804
+ setExpanded((prev) => {
6805
+ const next = new Set(prev);
6806
+ if (next.has(key)) {
6807
+ next.delete(key);
6808
+ } else {
6809
+ next.add(key);
6810
+ }
6811
+ return next;
6812
+ });
6813
+ }, []);
6814
+ const isExpanded = React51.useCallback(
6815
+ (key) => expanded.has(key),
6816
+ [expanded]
6817
+ );
6818
+ return { expanded, toggle, isExpanded };
6819
+ }
6820
+ ExpandableSection.displayName = "ExpandableSection";
6821
+ function useServiceWorker() {
6822
+ useEffect(() => {
6823
+ if ("serviceWorker" in navigator) {
6824
+ navigator.serviceWorker.register("/sw.js").then((registration) => {
6825
+ console.log("Service Worker registered:", registration.scope);
6826
+ setInterval(() => {
6827
+ registration.update();
6828
+ }, 60 * 60 * 1e3);
6829
+ }).catch((error) => {
6830
+ console.error("Service Worker registration failed:", error);
6831
+ });
6832
+ }
6833
+ }, []);
6834
+ }
6835
+ function formatCentsToEuros(cents) {
6836
+ return `\u20AC${(cents / 100).toLocaleString()}`;
6837
+ }
6838
+ function formatEuros(euros, decimals) {
6839
+ if (decimals !== void 0) {
6840
+ return `\u20AC${euros.toFixed(decimals)}`;
6841
+ }
6842
+ return `\u20AC${euros.toLocaleString()}`;
6843
+ }
6844
+ function formatDuration(ms) {
6845
+ return `${(ms / 1e3).toFixed(1)}s`;
6846
+ }
6847
+ function formatRelativeTime(date) {
6848
+ if (!date) return "\u2014";
6849
+ const d = typeof date === "string" ? new Date(date) : date;
6850
+ const hours = differenceInHours(/* @__PURE__ */ new Date(), d);
6851
+ if (hours < 1) {
6852
+ const mins = differenceInMinutes(/* @__PURE__ */ new Date(), d);
6853
+ return `${mins}m`;
6854
+ }
6855
+ if (hours < 48) return `${hours}h`;
6856
+ return formatDistanceToNow(d, { addSuffix: false });
6857
+ }
6858
+
6859
+ // src/lib/email.ts
6860
+ function emailTemplate({ body, preheader }) {
6861
+ const preheaderHtml = preheader ? `<div style="display:none;font-size:1px;color:#ffffff;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden;">${preheader}</div>` : "";
6862
+ return `<!DOCTYPE html>
6863
+ <html lang="en">
6864
+ <head>
6865
+ <meta charset="utf-8" />
6866
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6867
+ <meta name="color-scheme" content="light" />
6868
+ <meta name="supported-color-schemes" content="light" />
6869
+ <title>Dilipod</title>
6870
+ </head>
6871
+ <body style="margin: 0; padding: 0; background-color: #f0f0f0; -webkit-font-smoothing: antialiased;">
6872
+ ${preheaderHtml}
6873
+ <table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color: #f0f0f0;">
6874
+ <tr>
6875
+ <td align="center" style="padding: 40px 16px;">
6876
+ <!-- Main card -->
6877
+ <table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="max-width: 560px;">
6878
+ <!-- Logo header -->
6879
+ <tr>
6880
+ <td style="padding: 0 0 24px 0;">
6881
+ <table role="presentation" cellpadding="0" cellspacing="0">
6882
+ <tr>
6883
+ <td style="width: 32px; height: 32px; background-color: #00e5cc; border-radius: 6px; text-align: center; vertical-align: middle; font-size: 16px; font-weight: 700; color: #111111; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;">
6884
+ D
6885
+ </td>
6886
+ <td style="padding-left: 10px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 17px; font-weight: 600; color: #111111; letter-spacing: -0.2px;">
6887
+ Dilipod
6888
+ </td>
6889
+ </tr>
6890
+ </table>
6891
+ </td>
6892
+ </tr>
6893
+ <!-- Content card -->
6894
+ <tr>
6895
+ <td>
6896
+ <table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 6px; overflow: hidden; border: 1px solid #e2e2e2;">
6897
+ <!-- Accent bar -->
6898
+ <tr>
6899
+ <td style="height: 3px; background: linear-gradient(90deg, #00e5cc 0%, #00c8b5 100%); font-size: 0; line-height: 0;">&nbsp;</td>
6900
+ </tr>
6901
+ <!-- Body content -->
6902
+ <tr>
6903
+ <td style="padding: 36px 40px 40px 40px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 15px; line-height: 1.7; color: #374151;">
6904
+ ${body}
6905
+ </td>
6906
+ </tr>
6907
+ </table>
6908
+ </td>
6909
+ </tr>
6910
+ <!-- Footer -->
6911
+ <tr>
6912
+ <td style="padding: 24px 4px 0 4px;">
6913
+ <table role="presentation" width="100%" cellpadding="0" cellspacing="0">
6914
+ <tr>
6915
+ <td style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 12px; color: #9ca3af;">
6916
+ &copy; ${(/* @__PURE__ */ new Date()).getFullYear()} Dilipod &mdash; Your Digital Workforce
6917
+ </td>
6918
+ <td align="right" style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 12px;">
6919
+ <a href="https://dilipod.com" style="color: #9ca3af; text-decoration: none;">dilipod.com</a>
6920
+ </td>
6921
+ </tr>
6922
+ </table>
6923
+ </td>
6924
+ </tr>
6925
+ </table>
6926
+ </td>
6927
+ </tr>
6928
+ </table>
6929
+ </body>
6930
+ </html>`;
6931
+ }
6932
+ function buttonHtml({
6933
+ text,
6934
+ href,
6935
+ variant = "primary"
6936
+ }) {
6937
+ const bg = variant === "danger" ? "#dc2626" : "#111111";
6938
+ const color = "#ffffff";
6939
+ return `<table role="presentation" cellpadding="0" cellspacing="0" style="margin-top: 24px;">
6940
+ <tr>
6941
+ <td style="background-color: ${bg}; border-radius: 6px;">
6942
+ <a href="${href}" style="display: inline-block; padding: 12px 32px; color: ${color}; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 14px; font-weight: 600; text-decoration: none;">
6943
+ ${text} &rarr;
6944
+ </a>
6945
+ </td>
6946
+ </tr>
6947
+ </table>`;
6948
+ }
6949
+ function infoBoxHtml(innerHtml) {
6950
+ return `<div style="background-color: #f8fafb; padding: 16px 20px; border-radius: 6px; border: 1px solid #e5e7eb; margin: 20px 0; border-left: 3px solid #00e5cc;">
6951
+ ${innerHtml}
6952
+ </div>`;
6953
+ }
6954
+ function noteBoxHtml(text) {
6955
+ return `<div style="background-color: #fffbeb; padding: 14px 18px; border-radius: 6px; border: 1px solid #fde68a; margin: 20px 0; font-size: 13px; color: #92400e; border-left: 3px solid #f59e0b;">
6956
+ ${text}
6957
+ </div>`;
6958
+ }
6739
6959
 
6740
6960
  // src/index.ts
6741
6961
  __reExport(index_exports, icons_exports);
6742
6962
 
6743
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActivityTimeline, Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, Avatar, AvatarFallback, AvatarImage, Badge, BreadcrumbLink, Breadcrumbs, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CodeBlock, ConfirmDialog, DateRangePicker, DateRangeSelect, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Divider, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, ErrorState, FilePreview, FlowchartDiagram, FormField, IconBox, ImpactMetricsForm, Input, Label2 as Label, LabeledSlider, LabeledSwitch, Logo, Metric, MetricCard, MetricLabel, MetricSubtext, MetricValue, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Pagination, Popover, PopoverAnchor, PopoverArrow, PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupCard, RadioGroupItem, RadioGroupOption, ScenariosManager, Select, Separator2 as Separator, SettingsNav, SettingsNavLink, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Sidebar, SimplePagination, SimpleTooltip, Skeleton, SkeletonCard, SkeletonText, Slider, Stat, StepDots, StepProgress, SupportChat, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsListUnderline, TabsTrigger, TabsTriggerUnderline, Tag, Textarea, Toast, ToastAction, ToastClose, ToastDescription, ToastIcon, ToastProvider, ToastTitle, ToastViewport, Toaster, Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, UsageBar, UsageChart, WorkerSpec, WorkflowFlow, WorkflowViewer, alertVariants, badgeVariants, buttonVariants, cn, getDateRangeFromPreset, iconBoxVariants, metricCardVariants, navigationMenuTriggerStyle, progressVariants, statVariants, tagVariants, toast, usageBarVariants, useToast, valueVariants };
6963
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActivityTimeline, Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, Avatar, AvatarFallback, AvatarImage, Badge, BreadcrumbLink, Breadcrumbs, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CodeBlock, ConfirmDialog, DateRangePicker, DateRangeSelect, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Divider, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, ErrorState, ExpandableSection, FilePreview, FlowchartDiagram, FormField, IconBox, ImpactMetricsForm, Input, Label2 as Label, LabeledSlider, LabeledSwitch, Logo, Metric, MetricCard, MetricLabel, MetricSubtext, MetricValue, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Pagination, Popover, PopoverAnchor, PopoverArrow, PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupCard, RadioGroupItem, RadioGroupOption, ScenariosManager, Select, Separator2 as Separator, SettingsNav, SettingsNavLink, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Sidebar, SimplePagination, SimpleTooltip, Skeleton, SkeletonCard, SkeletonText, Slider, Stat, StepDots, StepProgress, SupportChat, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsListUnderline, TabsTrigger, TabsTriggerUnderline, Tag, Textarea, Toast, ToastAction, ToastClose, ToastDescription, ToastIcon, ToastProvider, ToastTitle, ToastViewport, Toaster, Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, UsageBar, UsageChart, WorkerSpec, WorkflowFlow, WorkflowViewer, alertVariants, badgeVariants, buttonHtml, buttonVariants, cn, emailTemplate, formatCentsToEuros, formatDuration, formatEuros, formatRelativeTime, getDateRangeFromPreset, iconBoxVariants, infoBoxHtml, metricCardVariants, navigationMenuTriggerStyle, noteBoxHtml, progressVariants, statVariants, tagVariants, toast, usageBarVariants, useExpandedSections, useServiceWorker, useToast, valueVariants };
6744
6964
  //# sourceMappingURL=index.mjs.map
6745
6965
  //# sourceMappingURL=index.mjs.map