@dilipod/ui 0.4.27 → 0.4.28
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/components/expandable-section.d.ts +37 -0
- package/dist/components/expandable-section.d.ts.map +1 -0
- package/dist/hooks/use-service-worker.d.ts +2 -0
- package/dist/hooks/use-service-worker.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +122 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +116 -1
- package/dist/index.mjs.map +1 -1
- package/dist/lib/formatting.d.ts +27 -0
- package/dist/lib/formatting.d.ts.map +1 -0
- package/package.json +2 -1
- package/src/components/expandable-section.tsx +106 -0
- package/src/hooks/use-service-worker.ts +23 -0
- package/src/index.ts +10 -0
- package/src/lib/formatting.ts +51 -0
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,
|
|
@@ -492,6 +494,10 @@ __export(index_exports, {
|
|
|
492
494
|
badgeVariants: () => badgeVariants,
|
|
493
495
|
buttonVariants: () => buttonVariants,
|
|
494
496
|
cn: () => cn,
|
|
497
|
+
formatCentsToEuros: () => formatCentsToEuros,
|
|
498
|
+
formatDuration: () => formatDuration,
|
|
499
|
+
formatEuros: () => formatEuros,
|
|
500
|
+
formatRelativeTime: () => formatRelativeTime,
|
|
495
501
|
getDateRangeFromPreset: () => getDateRangeFromPreset,
|
|
496
502
|
iconBoxVariants: () => iconBoxVariants,
|
|
497
503
|
metricCardVariants: () => metricCardVariants,
|
|
@@ -501,6 +507,8 @@ __export(index_exports, {
|
|
|
501
507
|
tagVariants: () => tagVariants,
|
|
502
508
|
toast: () => toast,
|
|
503
509
|
usageBarVariants: () => usageBarVariants,
|
|
510
|
+
useExpandedSections: () => useExpandedSections,
|
|
511
|
+
useServiceWorker: () => useServiceWorker,
|
|
504
512
|
useToast: () => useToast,
|
|
505
513
|
valueVariants: () => valueVariants
|
|
506
514
|
});
|
|
@@ -6736,10 +6744,117 @@ function WorkerSpec({ documentation, className }) {
|
|
|
6736
6744
|
] })
|
|
6737
6745
|
] }) });
|
|
6738
6746
|
}
|
|
6747
|
+
function ExpandableSection({
|
|
6748
|
+
sectionKey,
|
|
6749
|
+
label,
|
|
6750
|
+
icon,
|
|
6751
|
+
count: count2,
|
|
6752
|
+
expanded,
|
|
6753
|
+
onToggle,
|
|
6754
|
+
children,
|
|
6755
|
+
className,
|
|
6756
|
+
contentClassName,
|
|
6757
|
+
show = true
|
|
6758
|
+
}) {
|
|
6759
|
+
if (!show) return null;
|
|
6760
|
+
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
6761
|
+
/* @__PURE__ */ jsxs(
|
|
6762
|
+
"button",
|
|
6763
|
+
{
|
|
6764
|
+
onClick: () => onToggle(sectionKey),
|
|
6765
|
+
className: "flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors w-full text-left",
|
|
6766
|
+
type: "button",
|
|
6767
|
+
children: [
|
|
6768
|
+
/* @__PURE__ */ jsx(
|
|
6769
|
+
"svg",
|
|
6770
|
+
{
|
|
6771
|
+
width: "12",
|
|
6772
|
+
height: "12",
|
|
6773
|
+
viewBox: "0 0 12 12",
|
|
6774
|
+
fill: "none",
|
|
6775
|
+
className: cn(
|
|
6776
|
+
"shrink-0 transition-transform",
|
|
6777
|
+
expanded ? "rotate-0" : "-rotate-90"
|
|
6778
|
+
),
|
|
6779
|
+
children: /* @__PURE__ */ jsx("path", { d: "M2.5 4.5L6 8L9.5 4.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
6780
|
+
}
|
|
6781
|
+
),
|
|
6782
|
+
icon,
|
|
6783
|
+
/* @__PURE__ */ jsx("span", { children: label }),
|
|
6784
|
+
count2 !== void 0 && /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground/60", children: [
|
|
6785
|
+
"(",
|
|
6786
|
+
count2,
|
|
6787
|
+
")"
|
|
6788
|
+
] })
|
|
6789
|
+
]
|
|
6790
|
+
}
|
|
6791
|
+
),
|
|
6792
|
+
expanded && /* @__PURE__ */ jsx("div", { className: cn("mt-2 pl-4", contentClassName), children })
|
|
6793
|
+
] });
|
|
6794
|
+
}
|
|
6795
|
+
function useExpandedSections(initialExpanded = []) {
|
|
6796
|
+
const [expanded, setExpanded] = React51.useState(
|
|
6797
|
+
() => new Set(initialExpanded)
|
|
6798
|
+
);
|
|
6799
|
+
const toggle = React51.useCallback((key) => {
|
|
6800
|
+
setExpanded((prev) => {
|
|
6801
|
+
const next = new Set(prev);
|
|
6802
|
+
if (next.has(key)) {
|
|
6803
|
+
next.delete(key);
|
|
6804
|
+
} else {
|
|
6805
|
+
next.add(key);
|
|
6806
|
+
}
|
|
6807
|
+
return next;
|
|
6808
|
+
});
|
|
6809
|
+
}, []);
|
|
6810
|
+
const isExpanded = React51.useCallback(
|
|
6811
|
+
(key) => expanded.has(key),
|
|
6812
|
+
[expanded]
|
|
6813
|
+
);
|
|
6814
|
+
return { expanded, toggle, isExpanded };
|
|
6815
|
+
}
|
|
6816
|
+
ExpandableSection.displayName = "ExpandableSection";
|
|
6817
|
+
function useServiceWorker() {
|
|
6818
|
+
useEffect(() => {
|
|
6819
|
+
if ("serviceWorker" in navigator) {
|
|
6820
|
+
navigator.serviceWorker.register("/sw.js").then((registration) => {
|
|
6821
|
+
console.log("Service Worker registered:", registration.scope);
|
|
6822
|
+
setInterval(() => {
|
|
6823
|
+
registration.update();
|
|
6824
|
+
}, 60 * 60 * 1e3);
|
|
6825
|
+
}).catch((error) => {
|
|
6826
|
+
console.error("Service Worker registration failed:", error);
|
|
6827
|
+
});
|
|
6828
|
+
}
|
|
6829
|
+
}, []);
|
|
6830
|
+
}
|
|
6831
|
+
function formatCentsToEuros(cents) {
|
|
6832
|
+
return `\u20AC${(cents / 100).toLocaleString()}`;
|
|
6833
|
+
}
|
|
6834
|
+
function formatEuros(euros, decimals) {
|
|
6835
|
+
if (decimals !== void 0) {
|
|
6836
|
+
return `\u20AC${euros.toFixed(decimals)}`;
|
|
6837
|
+
}
|
|
6838
|
+
return `\u20AC${euros.toLocaleString()}`;
|
|
6839
|
+
}
|
|
6840
|
+
function formatDuration(ms) {
|
|
6841
|
+
return `${(ms / 1e3).toFixed(1)}s`;
|
|
6842
|
+
}
|
|
6843
|
+
function formatRelativeTime(date) {
|
|
6844
|
+
if (!date) return "\u2014";
|
|
6845
|
+
const d = typeof date === "string" ? new Date(date) : date;
|
|
6846
|
+
const hours = differenceInHours(/* @__PURE__ */ new Date(), d);
|
|
6847
|
+
if (hours < 1) {
|
|
6848
|
+
const mins = differenceInMinutes(/* @__PURE__ */ new Date(), d);
|
|
6849
|
+
return `${mins}m`;
|
|
6850
|
+
}
|
|
6851
|
+
if (hours < 48) return `${hours}h`;
|
|
6852
|
+
return formatDistanceToNow(d, { addSuffix: false });
|
|
6853
|
+
}
|
|
6739
6854
|
|
|
6740
6855
|
// src/index.ts
|
|
6741
6856
|
__reExport(index_exports, icons_exports);
|
|
6742
6857
|
|
|
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 };
|
|
6858
|
+
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, buttonVariants, cn, formatCentsToEuros, formatDuration, formatEuros, formatRelativeTime, getDateRangeFromPreset, iconBoxVariants, metricCardVariants, navigationMenuTriggerStyle, progressVariants, statVariants, tagVariants, toast, usageBarVariants, useExpandedSections, useServiceWorker, useToast, valueVariants };
|
|
6744
6859
|
//# sourceMappingURL=index.mjs.map
|
|
6745
6860
|
//# sourceMappingURL=index.mjs.map
|