@crmy/web 0.5.5 → 0.5.6
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/assets/index-CskfWp8E.js +560 -0
- package/dist/assets/index-D763l57m.css +1 -0
- package/{index.html → dist/index.html} +2 -1
- package/package.json +4 -1
- package/postcss.config.js +0 -6
- package/src/App.tsx +0 -158
- package/src/api/client.ts +0 -82
- package/src/api/hooks.ts +0 -689
- package/src/components/CustomFields.tsx +0 -240
- package/src/components/NavLink.tsx +0 -28
- package/src/components/crm/AIFab.tsx +0 -37
- package/src/components/crm/AccountDrawer.tsx +0 -372
- package/src/components/crm/ActivityTimeline.tsx +0 -115
- package/src/components/crm/AssignmentDrawer.tsx +0 -396
- package/src/components/crm/BriefingPanel.tsx +0 -217
- package/src/components/crm/CommandPalette.tsx +0 -254
- package/src/components/crm/ContactAvatar.tsx +0 -49
- package/src/components/crm/ContactDrawer.tsx +0 -438
- package/src/components/crm/ContextPanel.tsx +0 -200
- package/src/components/crm/CrmWidgets.tsx +0 -417
- package/src/components/crm/DrawerShell.tsx +0 -77
- package/src/components/crm/ListToolbar.tsx +0 -252
- package/src/components/crm/OpportunityDrawer.tsx +0 -372
- package/src/components/crm/PaginationBar.tsx +0 -111
- package/src/components/crm/QuickAddDrawer.tsx +0 -652
- package/src/components/crm/ShortcutsOverlay.tsx +0 -65
- package/src/components/crm/UseCaseDrawer.tsx +0 -454
- package/src/components/layout/MobileNav.tsx +0 -49
- package/src/components/layout/Sidebar.tsx +0 -157
- package/src/components/layout/TopBar.tsx +0 -54
- package/src/components/settings/ActorsSettings.tsx +0 -1190
- package/src/components/ui/accordion.tsx +0 -52
- package/src/components/ui/alert-dialog.tsx +0 -104
- package/src/components/ui/alert.tsx +0 -43
- package/src/components/ui/aspect-ratio.tsx +0 -5
- package/src/components/ui/avatar.tsx +0 -38
- package/src/components/ui/badge.tsx +0 -29
- package/src/components/ui/breadcrumb.tsx +0 -90
- package/src/components/ui/button.tsx +0 -47
- package/src/components/ui/calendar.tsx +0 -54
- package/src/components/ui/card.tsx +0 -43
- package/src/components/ui/carousel.tsx +0 -224
- package/src/components/ui/chart.tsx +0 -303
- package/src/components/ui/checkbox.tsx +0 -26
- package/src/components/ui/collapsible.tsx +0 -9
- package/src/components/ui/command.tsx +0 -132
- package/src/components/ui/context-menu.tsx +0 -178
- package/src/components/ui/date-picker.tsx +0 -313
- package/src/components/ui/dialog.tsx +0 -95
- package/src/components/ui/drawer.tsx +0 -87
- package/src/components/ui/dropdown-menu.tsx +0 -179
- package/src/components/ui/form.tsx +0 -129
- package/src/components/ui/hover-card.tsx +0 -27
- package/src/components/ui/input-otp.tsx +0 -61
- package/src/components/ui/input.tsx +0 -22
- package/src/components/ui/label.tsx +0 -17
- package/src/components/ui/menubar.tsx +0 -207
- package/src/components/ui/navigation-menu.tsx +0 -120
- package/src/components/ui/pagination.tsx +0 -81
- package/src/components/ui/popover.tsx +0 -29
- package/src/components/ui/progress.tsx +0 -23
- package/src/components/ui/radio-group.tsx +0 -36
- package/src/components/ui/resizable.tsx +0 -37
- package/src/components/ui/scroll-area.tsx +0 -38
- package/src/components/ui/select.tsx +0 -143
- package/src/components/ui/separator.tsx +0 -20
- package/src/components/ui/sheet.tsx +0 -107
- package/src/components/ui/sidebar.tsx +0 -637
- package/src/components/ui/skeleton.tsx +0 -7
- package/src/components/ui/slider.tsx +0 -23
- package/src/components/ui/sonner.tsx +0 -24
- package/src/components/ui/switch.tsx +0 -27
- package/src/components/ui/table.tsx +0 -72
- package/src/components/ui/tabs.tsx +0 -53
- package/src/components/ui/textarea.tsx +0 -21
- package/src/components/ui/toast.tsx +0 -111
- package/src/components/ui/toaster.tsx +0 -24
- package/src/components/ui/toggle-group.tsx +0 -49
- package/src/components/ui/toggle.tsx +0 -37
- package/src/components/ui/tooltip.tsx +0 -28
- package/src/components/ui/use-toast.ts +0 -1
- package/src/components/ui/utils.ts +0 -9
- package/src/contexts/AgentSettingsContext.tsx +0 -24
- package/src/hooks/use-mobile.tsx +0 -19
- package/src/hooks/use-toast.ts +0 -186
- package/src/hooks/useKeyboardShortcuts.ts +0 -95
- package/src/hooks/useTheme.ts +0 -24
- package/src/index.css +0 -245
- package/src/lib/entityColors.ts +0 -18
- package/src/lib/stageConfig.ts +0 -32
- package/src/lib/utils.ts +0 -6
- package/src/main.tsx +0 -25
- package/src/pages/Accounts.tsx +0 -205
- package/src/pages/Activities.tsx +0 -251
- package/src/pages/Agent.tsx +0 -237
- package/src/pages/AgentSettings.tsx +0 -544
- package/src/pages/Assignments.tsx +0 -750
- package/src/pages/Contacts.tsx +0 -200
- package/src/pages/Dashboard.tsx +0 -143
- package/src/pages/Inbox.tsx +0 -615
- package/src/pages/NotFound.tsx +0 -24
- package/src/pages/Opportunities.tsx +0 -386
- package/src/pages/SearchResults.tsx +0 -49
- package/src/pages/Settings.tsx +0 -1884
- package/src/pages/UseCases.tsx +0 -396
- package/src/pages/auth/Login.tsx +0 -261
- package/src/pages/hitl/HITL.tsx +0 -101
- package/src/store/appStore.ts +0 -103
- package/src/vite-env.d.ts +0 -14
- package/tailwind.config.js +0 -121
- package/tsconfig.json +0 -24
- package/vite.config.ts +0 -27
- /package/{public → dist}/android-chrome-192x192.png +0 -0
- /package/{public → dist}/android-chrome-512x512.png +0 -0
- /package/{public → dist}/apple-touch-icon.png +0 -0
- /package/{src/assets/crmy-logo.png → dist/assets/crmy-logo-DWN0xBPW.png} +0 -0
- /package/{public → dist}/favicon-16x16.png +0 -0
- /package/{public → dist}/favicon-32x32.png +0 -0
- /package/{public → dist}/favicon.ico +0 -0
- /package/{public → dist}/favicon.svg +0 -0
- /package/{public → dist}/site.webmanifest +0 -0
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
|
3
|
-
import { Check, ChevronRight, Circle } from "lucide-react";
|
|
4
|
-
|
|
5
|
-
import { cn } from "@/lib/utils";
|
|
6
|
-
|
|
7
|
-
const ContextMenu = ContextMenuPrimitive.Root;
|
|
8
|
-
|
|
9
|
-
const ContextMenuTrigger = ContextMenuPrimitive.Trigger;
|
|
10
|
-
|
|
11
|
-
const ContextMenuGroup = ContextMenuPrimitive.Group;
|
|
12
|
-
|
|
13
|
-
const ContextMenuPortal = ContextMenuPrimitive.Portal;
|
|
14
|
-
|
|
15
|
-
const ContextMenuSub = ContextMenuPrimitive.Sub;
|
|
16
|
-
|
|
17
|
-
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
|
|
18
|
-
|
|
19
|
-
const ContextMenuSubTrigger = React.forwardRef<
|
|
20
|
-
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
|
|
21
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
|
|
22
|
-
inset?: boolean;
|
|
23
|
-
}
|
|
24
|
-
>(({ className, inset, children, ...props }, ref) => (
|
|
25
|
-
<ContextMenuPrimitive.SubTrigger
|
|
26
|
-
ref={ref}
|
|
27
|
-
className={cn(
|
|
28
|
-
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent data-[state=open]:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
|
|
29
|
-
inset && "pl-8",
|
|
30
|
-
className,
|
|
31
|
-
)}
|
|
32
|
-
{...props}
|
|
33
|
-
>
|
|
34
|
-
{children}
|
|
35
|
-
<ChevronRight className="ml-auto h-4 w-4" />
|
|
36
|
-
</ContextMenuPrimitive.SubTrigger>
|
|
37
|
-
));
|
|
38
|
-
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
|
|
39
|
-
|
|
40
|
-
const ContextMenuSubContent = React.forwardRef<
|
|
41
|
-
React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
|
|
42
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
|
|
43
|
-
>(({ className, ...props }, ref) => (
|
|
44
|
-
<ContextMenuPrimitive.SubContent
|
|
45
|
-
ref={ref}
|
|
46
|
-
className={cn(
|
|
47
|
-
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
48
|
-
className,
|
|
49
|
-
)}
|
|
50
|
-
{...props}
|
|
51
|
-
/>
|
|
52
|
-
));
|
|
53
|
-
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
|
|
54
|
-
|
|
55
|
-
const ContextMenuContent = React.forwardRef<
|
|
56
|
-
React.ElementRef<typeof ContextMenuPrimitive.Content>,
|
|
57
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>
|
|
58
|
-
>(({ className, ...props }, ref) => (
|
|
59
|
-
<ContextMenuPrimitive.Portal>
|
|
60
|
-
<ContextMenuPrimitive.Content
|
|
61
|
-
ref={ref}
|
|
62
|
-
className={cn(
|
|
63
|
-
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
64
|
-
className,
|
|
65
|
-
)}
|
|
66
|
-
{...props}
|
|
67
|
-
/>
|
|
68
|
-
</ContextMenuPrimitive.Portal>
|
|
69
|
-
));
|
|
70
|
-
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
|
71
|
-
|
|
72
|
-
const ContextMenuItem = React.forwardRef<
|
|
73
|
-
React.ElementRef<typeof ContextMenuPrimitive.Item>,
|
|
74
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
|
|
75
|
-
inset?: boolean;
|
|
76
|
-
}
|
|
77
|
-
>(({ className, inset, ...props }, ref) => (
|
|
78
|
-
<ContextMenuPrimitive.Item
|
|
79
|
-
ref={ref}
|
|
80
|
-
className={cn(
|
|
81
|
-
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
|
82
|
-
inset && "pl-8",
|
|
83
|
-
className,
|
|
84
|
-
)}
|
|
85
|
-
{...props}
|
|
86
|
-
/>
|
|
87
|
-
));
|
|
88
|
-
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
|
89
|
-
|
|
90
|
-
const ContextMenuCheckboxItem = React.forwardRef<
|
|
91
|
-
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
|
|
92
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
|
|
93
|
-
>(({ className, children, checked, ...props }, ref) => (
|
|
94
|
-
<ContextMenuPrimitive.CheckboxItem
|
|
95
|
-
ref={ref}
|
|
96
|
-
className={cn(
|
|
97
|
-
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
|
98
|
-
className,
|
|
99
|
-
)}
|
|
100
|
-
checked={checked}
|
|
101
|
-
{...props}
|
|
102
|
-
>
|
|
103
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
104
|
-
<ContextMenuPrimitive.ItemIndicator>
|
|
105
|
-
<Check className="h-4 w-4" />
|
|
106
|
-
</ContextMenuPrimitive.ItemIndicator>
|
|
107
|
-
</span>
|
|
108
|
-
{children}
|
|
109
|
-
</ContextMenuPrimitive.CheckboxItem>
|
|
110
|
-
));
|
|
111
|
-
ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName;
|
|
112
|
-
|
|
113
|
-
const ContextMenuRadioItem = React.forwardRef<
|
|
114
|
-
React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
|
|
115
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
|
|
116
|
-
>(({ className, children, ...props }, ref) => (
|
|
117
|
-
<ContextMenuPrimitive.RadioItem
|
|
118
|
-
ref={ref}
|
|
119
|
-
className={cn(
|
|
120
|
-
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
|
|
121
|
-
className,
|
|
122
|
-
)}
|
|
123
|
-
{...props}
|
|
124
|
-
>
|
|
125
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
126
|
-
<ContextMenuPrimitive.ItemIndicator>
|
|
127
|
-
<Circle className="h-2 w-2 fill-current" />
|
|
128
|
-
</ContextMenuPrimitive.ItemIndicator>
|
|
129
|
-
</span>
|
|
130
|
-
{children}
|
|
131
|
-
</ContextMenuPrimitive.RadioItem>
|
|
132
|
-
));
|
|
133
|
-
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;
|
|
134
|
-
|
|
135
|
-
const ContextMenuLabel = React.forwardRef<
|
|
136
|
-
React.ElementRef<typeof ContextMenuPrimitive.Label>,
|
|
137
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
|
|
138
|
-
inset?: boolean;
|
|
139
|
-
}
|
|
140
|
-
>(({ className, inset, ...props }, ref) => (
|
|
141
|
-
<ContextMenuPrimitive.Label
|
|
142
|
-
ref={ref}
|
|
143
|
-
className={cn("px-2 py-1.5 text-sm font-semibold text-foreground", inset && "pl-8", className)}
|
|
144
|
-
{...props}
|
|
145
|
-
/>
|
|
146
|
-
));
|
|
147
|
-
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;
|
|
148
|
-
|
|
149
|
-
const ContextMenuSeparator = React.forwardRef<
|
|
150
|
-
React.ElementRef<typeof ContextMenuPrimitive.Separator>,
|
|
151
|
-
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
|
|
152
|
-
>(({ className, ...props }, ref) => (
|
|
153
|
-
<ContextMenuPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-border", className)} {...props} />
|
|
154
|
-
));
|
|
155
|
-
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;
|
|
156
|
-
|
|
157
|
-
const ContextMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
158
|
-
return <span className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)} {...props} />;
|
|
159
|
-
};
|
|
160
|
-
ContextMenuShortcut.displayName = "ContextMenuShortcut";
|
|
161
|
-
|
|
162
|
-
export {
|
|
163
|
-
ContextMenu,
|
|
164
|
-
ContextMenuTrigger,
|
|
165
|
-
ContextMenuContent,
|
|
166
|
-
ContextMenuItem,
|
|
167
|
-
ContextMenuCheckboxItem,
|
|
168
|
-
ContextMenuRadioItem,
|
|
169
|
-
ContextMenuLabel,
|
|
170
|
-
ContextMenuSeparator,
|
|
171
|
-
ContextMenuShortcut,
|
|
172
|
-
ContextMenuGroup,
|
|
173
|
-
ContextMenuPortal,
|
|
174
|
-
ContextMenuSub,
|
|
175
|
-
ContextMenuSubContent,
|
|
176
|
-
ContextMenuSubTrigger,
|
|
177
|
-
ContextMenuRadioGroup,
|
|
178
|
-
};
|
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 CRMy Contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import { format, parse, isValid, isAfter, isBefore } from 'date-fns';
|
|
6
|
-
import { CalendarIcon, X } from 'lucide-react';
|
|
7
|
-
import { cn } from '@/lib/utils';
|
|
8
|
-
import { Button } from '@/components/ui/button';
|
|
9
|
-
import { Calendar } from '@/components/ui/calendar';
|
|
10
|
-
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
|
11
|
-
|
|
12
|
-
// ─── DatePicker ───────────────────────────────────────────────────────────────
|
|
13
|
-
|
|
14
|
-
export interface DatePickerProps {
|
|
15
|
-
/** Controlled value as "YYYY-MM-DD" string, or "" for empty */
|
|
16
|
-
value: string;
|
|
17
|
-
onChange: (value: string) => void;
|
|
18
|
-
placeholder?: string;
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
/** When true the clear button is hidden and clearing is not allowed */
|
|
21
|
-
required?: boolean;
|
|
22
|
-
/** Reject and disable dates before this date */
|
|
23
|
-
minDate?: Date;
|
|
24
|
-
/** Reject and disable dates after this date */
|
|
25
|
-
maxDate?: Date;
|
|
26
|
-
/**
|
|
27
|
-
* "default" = h-10, matches the inputClass used in drawer edit forms.
|
|
28
|
-
* "sm" = h-8, matches the filter bar compact inputs.
|
|
29
|
-
*/
|
|
30
|
-
size?: 'default' | 'sm';
|
|
31
|
-
/** Extra classes applied to the trigger button (e.g. "w-36" to constrain width) */
|
|
32
|
-
className?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function DatePicker({
|
|
36
|
-
value,
|
|
37
|
-
onChange,
|
|
38
|
-
placeholder = 'Pick a date',
|
|
39
|
-
disabled = false,
|
|
40
|
-
required = false,
|
|
41
|
-
minDate,
|
|
42
|
-
maxDate,
|
|
43
|
-
size = 'default',
|
|
44
|
-
className,
|
|
45
|
-
}: DatePickerProps) {
|
|
46
|
-
const [open, setOpen] = React.useState(false);
|
|
47
|
-
|
|
48
|
-
const selectedDate = React.useMemo<Date | undefined>(() => {
|
|
49
|
-
if (!value) return undefined;
|
|
50
|
-
const d = parse(value, 'yyyy-MM-dd', new Date());
|
|
51
|
-
return isValid(d) ? d : undefined;
|
|
52
|
-
}, [value]);
|
|
53
|
-
|
|
54
|
-
const isDayDisabled = React.useCallback(
|
|
55
|
-
(day: Date) => {
|
|
56
|
-
if (minDate && isBefore(day, minDate)) return true;
|
|
57
|
-
if (maxDate && isAfter(day, maxDate)) return true;
|
|
58
|
-
return false;
|
|
59
|
-
},
|
|
60
|
-
[minDate, maxDate],
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
const handleSelect = (day: Date | undefined) => {
|
|
64
|
-
onChange(day ? format(day, 'yyyy-MM-dd') : '');
|
|
65
|
-
setOpen(false);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const handleClear = (e: React.MouseEvent) => {
|
|
69
|
-
e.stopPropagation();
|
|
70
|
-
onChange('');
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const sm = size === 'sm';
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<Popover open={open} onOpenChange={disabled ? undefined : setOpen}>
|
|
77
|
-
<PopoverTrigger asChild>
|
|
78
|
-
<button
|
|
79
|
-
type="button"
|
|
80
|
-
aria-haspopup="dialog"
|
|
81
|
-
aria-expanded={open}
|
|
82
|
-
aria-required={required}
|
|
83
|
-
disabled={disabled}
|
|
84
|
-
className={cn(
|
|
85
|
-
'inline-flex w-full items-center gap-2 rounded-md border border-border bg-background',
|
|
86
|
-
'text-foreground outline-none transition-colors',
|
|
87
|
-
'hover:border-ring/60 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
88
|
-
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
89
|
-
sm ? 'h-8 px-2 text-xs' : 'h-10 px-3 text-sm',
|
|
90
|
-
className,
|
|
91
|
-
)}
|
|
92
|
-
>
|
|
93
|
-
<CalendarIcon
|
|
94
|
-
className={cn(
|
|
95
|
-
'shrink-0 text-muted-foreground',
|
|
96
|
-
sm ? 'h-3.5 w-3.5' : 'h-4 w-4',
|
|
97
|
-
)}
|
|
98
|
-
/>
|
|
99
|
-
<span className={cn('flex-1 text-left', !selectedDate && 'text-muted-foreground')}>
|
|
100
|
-
{selectedDate ? format(selectedDate, 'MMM d, yyyy') : placeholder}
|
|
101
|
-
</span>
|
|
102
|
-
{selectedDate && !required && (
|
|
103
|
-
<X
|
|
104
|
-
onClick={handleClear}
|
|
105
|
-
aria-label="Clear date"
|
|
106
|
-
className={cn(
|
|
107
|
-
'shrink-0 text-muted-foreground hover:text-foreground',
|
|
108
|
-
sm ? 'h-3 w-3' : 'h-3.5 w-3.5',
|
|
109
|
-
)}
|
|
110
|
-
/>
|
|
111
|
-
)}
|
|
112
|
-
</button>
|
|
113
|
-
</PopoverTrigger>
|
|
114
|
-
<PopoverContent className="w-auto p-0 rounded-xl shadow-xl" align="start">
|
|
115
|
-
<Calendar
|
|
116
|
-
mode="single"
|
|
117
|
-
selected={selectedDate}
|
|
118
|
-
onSelect={handleSelect}
|
|
119
|
-
disabled={isDayDisabled}
|
|
120
|
-
showOutsideDays={false}
|
|
121
|
-
initialFocus
|
|
122
|
-
/>
|
|
123
|
-
</PopoverContent>
|
|
124
|
-
</Popover>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// ─── DateTimePicker ───────────────────────────────────────────────────────────
|
|
129
|
-
|
|
130
|
-
export interface DateTimePickerProps {
|
|
131
|
-
/**
|
|
132
|
-
* Controlled value as a local ISO-like string "YYYY-MM-DDTHH:mm:ss" or "".
|
|
133
|
-
* Compatible with new Date(value).toISOString() conversion in submit handlers.
|
|
134
|
-
*/
|
|
135
|
-
value: string;
|
|
136
|
-
onChange: (value: string) => void;
|
|
137
|
-
placeholder?: string;
|
|
138
|
-
disabled?: boolean;
|
|
139
|
-
required?: boolean;
|
|
140
|
-
minDate?: Date;
|
|
141
|
-
maxDate?: Date;
|
|
142
|
-
size?: 'default' | 'sm';
|
|
143
|
-
className?: string;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const HOURS = Array.from({ length: 12 }, (_, i) => i + 1); // 1–12
|
|
147
|
-
const MINUTES = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55];
|
|
148
|
-
|
|
149
|
-
export function DateTimePicker({
|
|
150
|
-
value,
|
|
151
|
-
onChange,
|
|
152
|
-
placeholder = 'Pick date & time',
|
|
153
|
-
disabled = false,
|
|
154
|
-
required = false,
|
|
155
|
-
minDate,
|
|
156
|
-
maxDate,
|
|
157
|
-
size = 'default',
|
|
158
|
-
className,
|
|
159
|
-
}: DateTimePickerProps) {
|
|
160
|
-
const [open, setOpen] = React.useState(false);
|
|
161
|
-
|
|
162
|
-
const selectedDate = React.useMemo<Date | undefined>(() => {
|
|
163
|
-
if (!value) return undefined;
|
|
164
|
-
const d = new Date(value);
|
|
165
|
-
return isValid(d) ? d : undefined;
|
|
166
|
-
}, [value]);
|
|
167
|
-
|
|
168
|
-
const emit = (date: Date) => {
|
|
169
|
-
onChange(format(date, "yyyy-MM-dd'T'HH:mm:00"));
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// Derived 12-hour time parts (safe defaults when no date selected yet)
|
|
173
|
-
const rawHour = selectedDate?.getHours() ?? 12;
|
|
174
|
-
const hour12 = rawHour % 12 || 12;
|
|
175
|
-
const minute = selectedDate?.getMinutes() ?? 0;
|
|
176
|
-
const ampm: 'AM' | 'PM' = rawHour >= 12 ? 'PM' : 'AM';
|
|
177
|
-
|
|
178
|
-
const handleDaySelect = (day: Date | undefined) => {
|
|
179
|
-
if (!day) { onChange(''); return; }
|
|
180
|
-
const base = selectedDate ? new Date(selectedDate) : new Date();
|
|
181
|
-
base.setFullYear(day.getFullYear(), day.getMonth(), day.getDate());
|
|
182
|
-
if (!selectedDate) base.setHours(12, 0, 0, 0); // default to noon on first pick
|
|
183
|
-
emit(base);
|
|
184
|
-
// Don't close — user still needs to pick time
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const handleTimeChange = (part: 'hour' | 'minute' | 'ampm', val: string) => {
|
|
188
|
-
const base = selectedDate
|
|
189
|
-
? new Date(selectedDate)
|
|
190
|
-
: (() => { const d = new Date(); d.setSeconds(0, 0); return d; })();
|
|
191
|
-
|
|
192
|
-
if (part === 'hour') {
|
|
193
|
-
const h12 = parseInt(val, 10);
|
|
194
|
-
base.setHours(ampm === 'PM' ? (h12 === 12 ? 12 : h12 + 12) : (h12 === 12 ? 0 : h12));
|
|
195
|
-
} else if (part === 'minute') {
|
|
196
|
-
base.setMinutes(parseInt(val, 10));
|
|
197
|
-
} else {
|
|
198
|
-
const h = base.getHours();
|
|
199
|
-
if (val === 'AM' && h >= 12) base.setHours(h - 12);
|
|
200
|
-
if (val === 'PM' && h < 12) base.setHours(h + 12);
|
|
201
|
-
}
|
|
202
|
-
emit(base);
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
const isDayDisabled = React.useCallback(
|
|
206
|
-
(day: Date) => {
|
|
207
|
-
if (minDate && isBefore(day, minDate)) return true;
|
|
208
|
-
if (maxDate && isAfter(day, maxDate)) return true;
|
|
209
|
-
return false;
|
|
210
|
-
},
|
|
211
|
-
[minDate, maxDate],
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
const displayValue = selectedDate
|
|
215
|
-
? format(selectedDate, "MMM d, yyyy 'at' h:mm a")
|
|
216
|
-
: null;
|
|
217
|
-
|
|
218
|
-
const sm = size === 'sm';
|
|
219
|
-
const selectCls =
|
|
220
|
-
'h-8 rounded-md border border-border bg-background text-foreground text-xs px-1.5 outline-none focus:ring-1 focus:ring-ring';
|
|
221
|
-
|
|
222
|
-
return (
|
|
223
|
-
<Popover open={open} onOpenChange={disabled ? undefined : setOpen}>
|
|
224
|
-
<PopoverTrigger asChild>
|
|
225
|
-
<button
|
|
226
|
-
type="button"
|
|
227
|
-
aria-haspopup="dialog"
|
|
228
|
-
aria-expanded={open}
|
|
229
|
-
aria-required={required}
|
|
230
|
-
disabled={disabled}
|
|
231
|
-
className={cn(
|
|
232
|
-
'inline-flex w-full items-center gap-2 rounded-md border border-border bg-background',
|
|
233
|
-
'text-foreground outline-none transition-colors',
|
|
234
|
-
'hover:border-ring/60 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
235
|
-
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
236
|
-
sm ? 'h-8 px-2 text-xs' : 'h-10 px-3 text-sm',
|
|
237
|
-
className,
|
|
238
|
-
)}
|
|
239
|
-
>
|
|
240
|
-
<CalendarIcon
|
|
241
|
-
className={cn(
|
|
242
|
-
'shrink-0 text-muted-foreground',
|
|
243
|
-
sm ? 'h-3.5 w-3.5' : 'h-4 w-4',
|
|
244
|
-
)}
|
|
245
|
-
/>
|
|
246
|
-
<span className={cn('flex-1 text-left', !selectedDate && 'text-muted-foreground')}>
|
|
247
|
-
{displayValue ?? placeholder}
|
|
248
|
-
</span>
|
|
249
|
-
{selectedDate && !required && (
|
|
250
|
-
<X
|
|
251
|
-
onClick={(e) => { e.stopPropagation(); onChange(''); }}
|
|
252
|
-
aria-label="Clear date and time"
|
|
253
|
-
className={cn(
|
|
254
|
-
'shrink-0 text-muted-foreground hover:text-foreground',
|
|
255
|
-
sm ? 'h-3 w-3' : 'h-3.5 w-3.5',
|
|
256
|
-
)}
|
|
257
|
-
/>
|
|
258
|
-
)}
|
|
259
|
-
</button>
|
|
260
|
-
</PopoverTrigger>
|
|
261
|
-
<PopoverContent className="w-auto p-0 rounded-xl shadow-xl" align="start">
|
|
262
|
-
<Calendar
|
|
263
|
-
mode="single"
|
|
264
|
-
selected={selectedDate}
|
|
265
|
-
onSelect={handleDaySelect}
|
|
266
|
-
disabled={isDayDisabled}
|
|
267
|
-
showOutsideDays={false}
|
|
268
|
-
initialFocus
|
|
269
|
-
/>
|
|
270
|
-
{/* Time selector */}
|
|
271
|
-
<div className="flex items-center gap-2 border-t border-border p-3">
|
|
272
|
-
<span className="mr-1 font-mono text-xs text-muted-foreground">Time</span>
|
|
273
|
-
<select
|
|
274
|
-
value={hour12}
|
|
275
|
-
onChange={(e) => handleTimeChange('hour', e.target.value)}
|
|
276
|
-
className={selectCls}
|
|
277
|
-
>
|
|
278
|
-
{HOURS.map((h) => (
|
|
279
|
-
<option key={h} value={h}>
|
|
280
|
-
{String(h).padStart(2, '0')}
|
|
281
|
-
</option>
|
|
282
|
-
))}
|
|
283
|
-
</select>
|
|
284
|
-
<span className="select-none text-sm text-muted-foreground">:</span>
|
|
285
|
-
<select
|
|
286
|
-
value={minute}
|
|
287
|
-
onChange={(e) => handleTimeChange('minute', e.target.value)}
|
|
288
|
-
className={selectCls}
|
|
289
|
-
>
|
|
290
|
-
{MINUTES.map((m) => (
|
|
291
|
-
<option key={m} value={m}>
|
|
292
|
-
{String(m).padStart(2, '0')}
|
|
293
|
-
</option>
|
|
294
|
-
))}
|
|
295
|
-
</select>
|
|
296
|
-
<select
|
|
297
|
-
value={ampm}
|
|
298
|
-
onChange={(e) => handleTimeChange('ampm', e.target.value)}
|
|
299
|
-
className={selectCls}
|
|
300
|
-
>
|
|
301
|
-
<option value="AM">AM</option>
|
|
302
|
-
<option value="PM">PM</option>
|
|
303
|
-
</select>
|
|
304
|
-
</div>
|
|
305
|
-
<div className="px-3 pb-3">
|
|
306
|
-
<Button size="sm" className="w-full" onClick={() => setOpen(false)}>
|
|
307
|
-
Done
|
|
308
|
-
</Button>
|
|
309
|
-
</div>
|
|
310
|
-
</PopoverContent>
|
|
311
|
-
</Popover>
|
|
312
|
-
);
|
|
313
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
3
|
-
import { X } from "lucide-react";
|
|
4
|
-
|
|
5
|
-
import { cn } from "@/lib/utils";
|
|
6
|
-
|
|
7
|
-
const Dialog = DialogPrimitive.Root;
|
|
8
|
-
|
|
9
|
-
const DialogTrigger = DialogPrimitive.Trigger;
|
|
10
|
-
|
|
11
|
-
const DialogPortal = DialogPrimitive.Portal;
|
|
12
|
-
|
|
13
|
-
const DialogClose = DialogPrimitive.Close;
|
|
14
|
-
|
|
15
|
-
const DialogOverlay = React.forwardRef<
|
|
16
|
-
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
17
|
-
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
18
|
-
>(({ className, ...props }, ref) => (
|
|
19
|
-
<DialogPrimitive.Overlay
|
|
20
|
-
ref={ref}
|
|
21
|
-
className={cn(
|
|
22
|
-
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
23
|
-
className,
|
|
24
|
-
)}
|
|
25
|
-
{...props}
|
|
26
|
-
/>
|
|
27
|
-
));
|
|
28
|
-
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
29
|
-
|
|
30
|
-
const DialogContent = React.forwardRef<
|
|
31
|
-
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
32
|
-
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
33
|
-
>(({ className, children, ...props }, ref) => (
|
|
34
|
-
<DialogPortal>
|
|
35
|
-
<DialogOverlay />
|
|
36
|
-
<DialogPrimitive.Content
|
|
37
|
-
ref={ref}
|
|
38
|
-
className={cn(
|
|
39
|
-
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
40
|
-
className,
|
|
41
|
-
)}
|
|
42
|
-
{...props}
|
|
43
|
-
>
|
|
44
|
-
{children}
|
|
45
|
-
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
|
|
46
|
-
<X className="h-4 w-4" />
|
|
47
|
-
<span className="sr-only">Close</span>
|
|
48
|
-
</DialogPrimitive.Close>
|
|
49
|
-
</DialogPrimitive.Content>
|
|
50
|
-
</DialogPortal>
|
|
51
|
-
));
|
|
52
|
-
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
53
|
-
|
|
54
|
-
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
55
|
-
<div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
|
|
56
|
-
);
|
|
57
|
-
DialogHeader.displayName = "DialogHeader";
|
|
58
|
-
|
|
59
|
-
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
60
|
-
<div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} />
|
|
61
|
-
);
|
|
62
|
-
DialogFooter.displayName = "DialogFooter";
|
|
63
|
-
|
|
64
|
-
const DialogTitle = React.forwardRef<
|
|
65
|
-
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
66
|
-
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
67
|
-
>(({ className, ...props }, ref) => (
|
|
68
|
-
<DialogPrimitive.Title
|
|
69
|
-
ref={ref}
|
|
70
|
-
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
|
|
71
|
-
{...props}
|
|
72
|
-
/>
|
|
73
|
-
));
|
|
74
|
-
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
75
|
-
|
|
76
|
-
const DialogDescription = React.forwardRef<
|
|
77
|
-
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
78
|
-
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
79
|
-
>(({ className, ...props }, ref) => (
|
|
80
|
-
<DialogPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
|
81
|
-
));
|
|
82
|
-
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
83
|
-
|
|
84
|
-
export {
|
|
85
|
-
Dialog,
|
|
86
|
-
DialogPortal,
|
|
87
|
-
DialogOverlay,
|
|
88
|
-
DialogClose,
|
|
89
|
-
DialogTrigger,
|
|
90
|
-
DialogContent,
|
|
91
|
-
DialogHeader,
|
|
92
|
-
DialogFooter,
|
|
93
|
-
DialogTitle,
|
|
94
|
-
DialogDescription,
|
|
95
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Drawer as DrawerPrimitive } from "vaul";
|
|
3
|
-
|
|
4
|
-
import { cn } from "@/lib/utils";
|
|
5
|
-
|
|
6
|
-
const Drawer = ({ shouldScaleBackground = true, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
|
|
7
|
-
<DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
|
|
8
|
-
);
|
|
9
|
-
Drawer.displayName = "Drawer";
|
|
10
|
-
|
|
11
|
-
const DrawerTrigger = DrawerPrimitive.Trigger;
|
|
12
|
-
|
|
13
|
-
const DrawerPortal = DrawerPrimitive.Portal;
|
|
14
|
-
|
|
15
|
-
const DrawerClose = DrawerPrimitive.Close;
|
|
16
|
-
|
|
17
|
-
const DrawerOverlay = React.forwardRef<
|
|
18
|
-
React.ElementRef<typeof DrawerPrimitive.Overlay>,
|
|
19
|
-
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
|
|
20
|
-
>(({ className, ...props }, ref) => (
|
|
21
|
-
<DrawerPrimitive.Overlay ref={ref} className={cn("fixed inset-0 z-50 bg-black/80", className)} {...props} />
|
|
22
|
-
));
|
|
23
|
-
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
|
|
24
|
-
|
|
25
|
-
const DrawerContent = React.forwardRef<
|
|
26
|
-
React.ElementRef<typeof DrawerPrimitive.Content>,
|
|
27
|
-
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
|
|
28
|
-
>(({ className, children, ...props }, ref) => (
|
|
29
|
-
<DrawerPortal>
|
|
30
|
-
<DrawerOverlay />
|
|
31
|
-
<DrawerPrimitive.Content
|
|
32
|
-
ref={ref}
|
|
33
|
-
className={cn(
|
|
34
|
-
"fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",
|
|
35
|
-
className,
|
|
36
|
-
)}
|
|
37
|
-
{...props}
|
|
38
|
-
>
|
|
39
|
-
<div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
|
|
40
|
-
{children}
|
|
41
|
-
</DrawerPrimitive.Content>
|
|
42
|
-
</DrawerPortal>
|
|
43
|
-
));
|
|
44
|
-
DrawerContent.displayName = "DrawerContent";
|
|
45
|
-
|
|
46
|
-
const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
47
|
-
<div className={cn("grid gap-1.5 p-4 text-center sm:text-left", className)} {...props} />
|
|
48
|
-
);
|
|
49
|
-
DrawerHeader.displayName = "DrawerHeader";
|
|
50
|
-
|
|
51
|
-
const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
52
|
-
<div className={cn("mt-auto flex flex-col gap-2 p-4", className)} {...props} />
|
|
53
|
-
);
|
|
54
|
-
DrawerFooter.displayName = "DrawerFooter";
|
|
55
|
-
|
|
56
|
-
const DrawerTitle = React.forwardRef<
|
|
57
|
-
React.ElementRef<typeof DrawerPrimitive.Title>,
|
|
58
|
-
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
|
|
59
|
-
>(({ className, ...props }, ref) => (
|
|
60
|
-
<DrawerPrimitive.Title
|
|
61
|
-
ref={ref}
|
|
62
|
-
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
|
|
63
|
-
{...props}
|
|
64
|
-
/>
|
|
65
|
-
));
|
|
66
|
-
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
|
|
67
|
-
|
|
68
|
-
const DrawerDescription = React.forwardRef<
|
|
69
|
-
React.ElementRef<typeof DrawerPrimitive.Description>,
|
|
70
|
-
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
|
|
71
|
-
>(({ className, ...props }, ref) => (
|
|
72
|
-
<DrawerPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
|
73
|
-
));
|
|
74
|
-
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
|
|
75
|
-
|
|
76
|
-
export {
|
|
77
|
-
Drawer,
|
|
78
|
-
DrawerPortal,
|
|
79
|
-
DrawerOverlay,
|
|
80
|
-
DrawerTrigger,
|
|
81
|
-
DrawerClose,
|
|
82
|
-
DrawerContent,
|
|
83
|
-
DrawerHeader,
|
|
84
|
-
DrawerFooter,
|
|
85
|
-
DrawerTitle,
|
|
86
|
-
DrawerDescription,
|
|
87
|
-
};
|