@codapet/design-system 0.4.6 → 0.4.8
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.d.mts +29 -28
- package/dist/index.mjs +30 -94
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -482,7 +482,7 @@ declare function TooltipTrigger({ ...props }: React$1.ComponentProps<typeof Tool
|
|
|
482
482
|
declare function TooltipContent({ className, sideOffset, children, ...props }: React$1.ComponentProps<typeof TooltipPrimitive.Content>): react_jsx_runtime.JSX.Element;
|
|
483
483
|
|
|
484
484
|
type SidebarContextProps = {
|
|
485
|
-
state:
|
|
485
|
+
state: 'expanded' | 'collapsed';
|
|
486
486
|
open: boolean;
|
|
487
487
|
setOpen: (open: boolean) => void;
|
|
488
488
|
openMobile: boolean;
|
|
@@ -491,56 +491,56 @@ type SidebarContextProps = {
|
|
|
491
491
|
toggleSidebar: () => void;
|
|
492
492
|
};
|
|
493
493
|
declare function useSidebar(): SidebarContextProps;
|
|
494
|
-
declare function SidebarProvider({ defaultOpen, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }: React$1.ComponentProps<
|
|
494
|
+
declare function SidebarProvider({ defaultOpen, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }: React$1.ComponentProps<'div'> & {
|
|
495
495
|
defaultOpen?: boolean;
|
|
496
496
|
open?: boolean;
|
|
497
497
|
onOpenChange?: (open: boolean) => void;
|
|
498
498
|
}): react_jsx_runtime.JSX.Element;
|
|
499
|
-
declare function Sidebar({ side, variant, collapsible, className, children, ...props }: React$1.ComponentProps<
|
|
500
|
-
side?:
|
|
501
|
-
variant?:
|
|
502
|
-
collapsible?:
|
|
499
|
+
declare function Sidebar({ side, variant, collapsible, className, children, ...props }: React$1.ComponentProps<'div'> & {
|
|
500
|
+
side?: 'left' | 'right';
|
|
501
|
+
variant?: 'sidebar' | 'floating' | 'inset';
|
|
502
|
+
collapsible?: 'offcanvas' | 'icon' | 'none';
|
|
503
503
|
}): react_jsx_runtime.JSX.Element;
|
|
504
504
|
declare function SidebarTrigger({ className, onClick, ...props }: React$1.ComponentProps<typeof Button>): react_jsx_runtime.JSX.Element;
|
|
505
|
-
declare function SidebarRail({ className, ...props }: React$1.ComponentProps<
|
|
506
|
-
declare function SidebarInset({ className, ...props }: React$1.ComponentProps<
|
|
505
|
+
declare function SidebarRail({ className, ...props }: React$1.ComponentProps<'button'>): react_jsx_runtime.JSX.Element;
|
|
506
|
+
declare function SidebarInset({ className, ...props }: React$1.ComponentProps<'main'>): react_jsx_runtime.JSX.Element;
|
|
507
507
|
declare function SidebarInput({ className, ...props }: React$1.ComponentProps<typeof Input>): react_jsx_runtime.JSX.Element;
|
|
508
|
-
declare function SidebarHeader({ className, ...props }: React$1.ComponentProps<
|
|
509
|
-
declare function SidebarFooter({ className, ...props }: React$1.ComponentProps<
|
|
508
|
+
declare function SidebarHeader({ className, ...props }: React$1.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
509
|
+
declare function SidebarFooter({ className, ...props }: React$1.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
510
510
|
declare function SidebarSeparator({ className, ...props }: React$1.ComponentProps<typeof Separator>): react_jsx_runtime.JSX.Element;
|
|
511
|
-
declare function SidebarContent({ className, ...props }: React$1.ComponentProps<
|
|
512
|
-
declare function SidebarGroup({ className, ...props }: React$1.ComponentProps<
|
|
513
|
-
declare function SidebarGroupLabel({ className, asChild, ...props }: React$1.ComponentProps<
|
|
511
|
+
declare function SidebarContent({ className, ...props }: React$1.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
512
|
+
declare function SidebarGroup({ className, ...props }: React$1.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
513
|
+
declare function SidebarGroupLabel({ className, asChild, ...props }: React$1.ComponentProps<'div'> & {
|
|
514
514
|
asChild?: boolean;
|
|
515
515
|
}): react_jsx_runtime.JSX.Element;
|
|
516
|
-
declare function SidebarGroupAction({ className, asChild, ...props }: React$1.ComponentProps<
|
|
516
|
+
declare function SidebarGroupAction({ className, asChild, ...props }: React$1.ComponentProps<'button'> & {
|
|
517
517
|
asChild?: boolean;
|
|
518
518
|
}): react_jsx_runtime.JSX.Element;
|
|
519
|
-
declare function SidebarGroupContent({ className, ...props }: React$1.ComponentProps<
|
|
520
|
-
declare function SidebarMenu({ className, ...props }: React$1.ComponentProps<
|
|
521
|
-
declare function SidebarMenuItem({ className, ...props }: React$1.ComponentProps<
|
|
519
|
+
declare function SidebarGroupContent({ className, ...props }: React$1.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
520
|
+
declare function SidebarMenu({ className, ...props }: React$1.ComponentProps<'ul'>): react_jsx_runtime.JSX.Element;
|
|
521
|
+
declare function SidebarMenuItem({ className, ...props }: React$1.ComponentProps<'li'>): react_jsx_runtime.JSX.Element;
|
|
522
522
|
declare const sidebarMenuButtonVariants: (props?: ({
|
|
523
523
|
variant?: "default" | "outline" | null | undefined;
|
|
524
524
|
size?: "default" | "sm" | "lg" | null | undefined;
|
|
525
525
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
526
|
-
declare function SidebarMenuButton({ asChild, isActive, variant, size, tooltip, className, ...props }: React$1.ComponentProps<
|
|
526
|
+
declare function SidebarMenuButton({ asChild, isActive, variant, size, tooltip, className, ...props }: React$1.ComponentProps<'button'> & {
|
|
527
527
|
asChild?: boolean;
|
|
528
528
|
isActive?: boolean;
|
|
529
529
|
tooltip?: string | React$1.ComponentProps<typeof TooltipContent>;
|
|
530
530
|
} & VariantProps<typeof sidebarMenuButtonVariants>): react_jsx_runtime.JSX.Element;
|
|
531
|
-
declare function SidebarMenuAction({ className, asChild, showOnHover, ...props }: React$1.ComponentProps<
|
|
531
|
+
declare function SidebarMenuAction({ className, asChild, showOnHover, ...props }: React$1.ComponentProps<'button'> & {
|
|
532
532
|
asChild?: boolean;
|
|
533
533
|
showOnHover?: boolean;
|
|
534
534
|
}): react_jsx_runtime.JSX.Element;
|
|
535
|
-
declare function SidebarMenuBadge({ className, ...props }: React$1.ComponentProps<
|
|
536
|
-
declare function SidebarMenuSkeleton({ className, showIcon, ...props }: React$1.ComponentProps<
|
|
535
|
+
declare function SidebarMenuBadge({ className, ...props }: React$1.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
536
|
+
declare function SidebarMenuSkeleton({ className, showIcon, ...props }: React$1.ComponentProps<'div'> & {
|
|
537
537
|
showIcon?: boolean;
|
|
538
538
|
}): react_jsx_runtime.JSX.Element;
|
|
539
|
-
declare function SidebarMenuSub({ className, ...props }: React$1.ComponentProps<
|
|
540
|
-
declare function SidebarMenuSubItem({ className, ...props }: React$1.ComponentProps<
|
|
541
|
-
declare function SidebarMenuSubButton({ asChild, size, isActive, className, ...props }: React$1.ComponentProps<
|
|
539
|
+
declare function SidebarMenuSub({ className, ...props }: React$1.ComponentProps<'ul'>): react_jsx_runtime.JSX.Element;
|
|
540
|
+
declare function SidebarMenuSubItem({ className, ...props }: React$1.ComponentProps<'li'>): react_jsx_runtime.JSX.Element;
|
|
541
|
+
declare function SidebarMenuSubButton({ asChild, size, isActive, className, ...props }: React$1.ComponentProps<'a'> & {
|
|
542
542
|
asChild?: boolean;
|
|
543
|
-
size?:
|
|
543
|
+
size?: 'sm' | 'md';
|
|
544
544
|
isActive?: boolean;
|
|
545
545
|
}): react_jsx_runtime.JSX.Element;
|
|
546
546
|
|
|
@@ -588,19 +588,20 @@ interface TimeValue {
|
|
|
588
588
|
hours: number;
|
|
589
589
|
minutes: number;
|
|
590
590
|
}
|
|
591
|
-
|
|
592
|
-
interface TimeInputProps extends BaseInputProps {
|
|
591
|
+
interface TimeInputProps {
|
|
593
592
|
time: TimeValue | null;
|
|
594
593
|
setTime: (time: TimeValue | null) => void;
|
|
595
594
|
timeFormat?: TimeFormat;
|
|
596
595
|
minuteStep?: number;
|
|
597
596
|
inputDisabled?: boolean;
|
|
598
597
|
size?: VariantProps<typeof inputVariants>['size'];
|
|
598
|
+
className?: string;
|
|
599
599
|
inputClassName?: string;
|
|
600
|
+
placeholder?: string;
|
|
600
601
|
icon?: React$1.ReactNode;
|
|
601
602
|
formatDisplay?: (time: TimeValue) => string;
|
|
602
603
|
}
|
|
603
|
-
declare function TimeInput({ time, setTime, timeFormat, minuteStep, inputDisabled, className, inputClassName, size, placeholder,
|
|
604
|
+
declare function TimeInput({ time, setTime, timeFormat, minuteStep, inputDisabled, className, inputClassName, size, placeholder, icon, formatDisplay, }: TimeInputProps): react_jsx_runtime.JSX.Element;
|
|
604
605
|
|
|
605
606
|
declare const toggleVariants: (props?: ({
|
|
606
607
|
variant?: "default" | "outline" | null | undefined;
|
package/dist/index.mjs
CHANGED
|
@@ -1886,7 +1886,11 @@ function ContextMenuShortcut({
|
|
|
1886
1886
|
|
|
1887
1887
|
// src/components/ui/date-input.tsx
|
|
1888
1888
|
import "class-variance-authority";
|
|
1889
|
-
import {
|
|
1889
|
+
import {
|
|
1890
|
+
format as dateFnsFormat,
|
|
1891
|
+
parse as dateFnsParse,
|
|
1892
|
+
isValid
|
|
1893
|
+
} from "date-fns";
|
|
1890
1894
|
import { CalendarDays } from "lucide-react";
|
|
1891
1895
|
import * as React20 from "react";
|
|
1892
1896
|
|
|
@@ -2268,7 +2272,7 @@ function DateInput({
|
|
|
2268
2272
|
onMonthChange: onMonthChange ?? setMonthState,
|
|
2269
2273
|
showOutsideDays,
|
|
2270
2274
|
className: cn(
|
|
2271
|
-
"
|
|
2275
|
+
"w-auto mx-auto h-[350px] overflow-y-auto md:h-auto m-2",
|
|
2272
2276
|
calendarClassName
|
|
2273
2277
|
),
|
|
2274
2278
|
classNames,
|
|
@@ -2341,17 +2345,7 @@ function DateInput({
|
|
|
2341
2345
|
...inputProps
|
|
2342
2346
|
}
|
|
2343
2347
|
) }) }),
|
|
2344
|
-
/* @__PURE__ */ jsx22(
|
|
2345
|
-
PopoverContent,
|
|
2346
|
-
{
|
|
2347
|
-
className: "w-auto overflow-hidden p-0",
|
|
2348
|
-
align: "end",
|
|
2349
|
-
alignOffset: -8,
|
|
2350
|
-
sideOffset: 10,
|
|
2351
|
-
side: "top",
|
|
2352
|
-
children: /* @__PURE__ */ jsx22(Calendar, { ...resolvedCalendarProps })
|
|
2353
|
-
}
|
|
2354
|
-
)
|
|
2348
|
+
/* @__PURE__ */ jsx22(PopoverContent, { className: "p-2 flex flex-col overflow-y-auto h-[400px] md:h-auto md:w-[350px] ", children: /* @__PURE__ */ jsx22(Calendar, { ...resolvedCalendarProps }) })
|
|
2355
2349
|
] }) });
|
|
2356
2350
|
}
|
|
2357
2351
|
|
|
@@ -2500,7 +2494,7 @@ function DateRangeInput({
|
|
|
2500
2494
|
onMonthChange: onMonthChange ?? setMonthState,
|
|
2501
2495
|
showOutsideDays,
|
|
2502
2496
|
className: cn(
|
|
2503
|
-
"
|
|
2497
|
+
"w-auto mx-auto h-[350px] overflow-y-auto md:h-auto m-2",
|
|
2504
2498
|
calendarClassName
|
|
2505
2499
|
),
|
|
2506
2500
|
classNames,
|
|
@@ -2529,7 +2523,7 @@ function DateRangeInput({
|
|
|
2529
2523
|
]
|
|
2530
2524
|
}
|
|
2531
2525
|
) }),
|
|
2532
|
-
/* @__PURE__ */ jsxs11(PopoverContent, { className: "p-0 flex flex-col overflow-y-auto
|
|
2526
|
+
/* @__PURE__ */ jsxs11(PopoverContent, { className: "p-0 flex flex-col overflow-y-auto h-[400px] md:h-auto md:w-[350px] ", children: [
|
|
2533
2527
|
/* @__PURE__ */ jsx23(Calendar, { ...resolvedCalendarProps }),
|
|
2534
2528
|
/* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-2 px-2 py-2", children: [
|
|
2535
2529
|
/* @__PURE__ */ jsx23(
|
|
@@ -5227,27 +5221,6 @@ function formatTime(time, timeFormat = "12h") {
|
|
|
5227
5221
|
return `${h12p}:${m} ${period}`;
|
|
5228
5222
|
}
|
|
5229
5223
|
}
|
|
5230
|
-
function parseTime(value, timeFormat = "12h") {
|
|
5231
|
-
if (!value.trim()) return null;
|
|
5232
|
-
const v = value.trim();
|
|
5233
|
-
if (is24HourFormat(timeFormat)) {
|
|
5234
|
-
const match2 = v.match(/^(\d{1,2}):(\d{2})$/);
|
|
5235
|
-
if (!match2) return null;
|
|
5236
|
-
const hours2 = parseInt(match2[1], 10);
|
|
5237
|
-
const minutes2 = parseInt(match2[2], 10);
|
|
5238
|
-
if (hours2 < 0 || hours2 > 23 || minutes2 < 0 || minutes2 > 59) return null;
|
|
5239
|
-
return { hours: hours2, minutes: minutes2 };
|
|
5240
|
-
}
|
|
5241
|
-
const match = v.match(/^(\d{1,2}):(\d{2})\s*(AM|PM|am|pm)$/i);
|
|
5242
|
-
if (!match) return null;
|
|
5243
|
-
let hours = parseInt(match[1], 10);
|
|
5244
|
-
const minutes = parseInt(match[2], 10);
|
|
5245
|
-
const period = match[3].toUpperCase();
|
|
5246
|
-
if (hours < 1 || hours > 12 || minutes < 0 || minutes > 59) return null;
|
|
5247
|
-
if (period === "AM" && hours === 12) hours = 0;
|
|
5248
|
-
else if (period === "PM" && hours !== 12) hours += 12;
|
|
5249
|
-
return { hours, minutes };
|
|
5250
|
-
}
|
|
5251
5224
|
function getDisplayHour(hours, timeFormat) {
|
|
5252
5225
|
if (is24HourFormat(timeFormat)) return hours;
|
|
5253
5226
|
return hours % 12 || 12;
|
|
@@ -5265,28 +5238,19 @@ function TimeInput({
|
|
|
5265
5238
|
inputClassName,
|
|
5266
5239
|
size,
|
|
5267
5240
|
placeholder,
|
|
5268
|
-
onBlur,
|
|
5269
5241
|
icon,
|
|
5270
|
-
formatDisplay
|
|
5271
|
-
...restProps
|
|
5242
|
+
formatDisplay
|
|
5272
5243
|
}) {
|
|
5273
5244
|
const resolvedPlaceholder = placeholder ?? TIME_FORMAT_PLACEHOLDER[timeFormat];
|
|
5274
|
-
const
|
|
5275
|
-
(
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
},
|
|
5280
|
-
[formatDisplay, timeFormat]
|
|
5281
|
-
);
|
|
5245
|
+
const displayValue = React46.useMemo(() => {
|
|
5246
|
+
if (!time) return "";
|
|
5247
|
+
if (formatDisplay) return formatDisplay(time);
|
|
5248
|
+
return formatTime(time, timeFormat);
|
|
5249
|
+
}, [time, formatDisplay, timeFormat]);
|
|
5282
5250
|
const [open, setOpen] = React46.useState(false);
|
|
5283
|
-
const [value, setValue] = React46.useState(displayFormat(time));
|
|
5284
5251
|
const hoursRef = React46.useRef(null);
|
|
5285
5252
|
const minutesRef = React46.useRef(null);
|
|
5286
5253
|
const periodRef = React46.useRef(null);
|
|
5287
|
-
React46.useEffect(() => {
|
|
5288
|
-
setValue(displayFormat(time));
|
|
5289
|
-
}, [time, displayFormat]);
|
|
5290
5254
|
const scrollToSelected = React46.useCallback(() => {
|
|
5291
5255
|
requestAnimationFrame(() => {
|
|
5292
5256
|
for (const ref of [hoursRef, minutesRef, periodRef]) {
|
|
@@ -5304,29 +5268,6 @@ function TimeInput({
|
|
|
5304
5268
|
scrollToSelected();
|
|
5305
5269
|
}
|
|
5306
5270
|
}, [open, scrollToSelected]);
|
|
5307
|
-
const handleInputChange = (e) => {
|
|
5308
|
-
const inputValue = e.target.value;
|
|
5309
|
-
setValue(inputValue);
|
|
5310
|
-
if (inputValue === "") {
|
|
5311
|
-
setTime(null);
|
|
5312
|
-
return;
|
|
5313
|
-
}
|
|
5314
|
-
const parsed = parseTime(inputValue, timeFormat);
|
|
5315
|
-
if (parsed) {
|
|
5316
|
-
setTime(parsed);
|
|
5317
|
-
}
|
|
5318
|
-
};
|
|
5319
|
-
const handleBlur = (e) => {
|
|
5320
|
-
onBlur?.(e);
|
|
5321
|
-
if (value === "") {
|
|
5322
|
-
if (time !== null) setTime(null);
|
|
5323
|
-
return;
|
|
5324
|
-
}
|
|
5325
|
-
const parsed = parseTime(value, timeFormat);
|
|
5326
|
-
if (!parsed) {
|
|
5327
|
-
setValue(displayFormat(time));
|
|
5328
|
-
}
|
|
5329
|
-
};
|
|
5330
5271
|
const handleHourSelect = (hour) => {
|
|
5331
5272
|
let h24;
|
|
5332
5273
|
if (is24HourFormat(timeFormat)) {
|
|
@@ -5359,29 +5300,24 @@ function TimeInput({
|
|
|
5359
5300
|
const selectedMinute = time?.minutes ?? null;
|
|
5360
5301
|
const selectedPeriod = time ? getPeriod(time.hours) : null;
|
|
5361
5302
|
return /* @__PURE__ */ jsx49("div", { className: cn("relative flex gap-2", className), children: /* @__PURE__ */ jsxs24(Popover, { open, onOpenChange: setOpen, children: [
|
|
5362
|
-
/* @__PURE__ */ jsx49(PopoverTrigger, { asChild: true, disabled: inputDisabled, children: /* @__PURE__ */
|
|
5363
|
-
|
|
5303
|
+
/* @__PURE__ */ jsx49(PopoverTrigger, { asChild: true, disabled: inputDisabled, children: /* @__PURE__ */ jsxs24(
|
|
5304
|
+
Button,
|
|
5364
5305
|
{
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
className: cn(
|
|
5368
|
-
|
|
5369
|
-
|
|
5306
|
+
type: "button",
|
|
5307
|
+
variant: "outline",
|
|
5308
|
+
className: cn(
|
|
5309
|
+
inputVariants({ size }),
|
|
5310
|
+
"bg-background cursor-pointer w-full text-left flex items-center justify-between gap-2 font-normal",
|
|
5311
|
+
inputDisabled && "pointer-events-none cursor-not-allowed opacity-50",
|
|
5312
|
+
inputClassName
|
|
5313
|
+
),
|
|
5370
5314
|
disabled: inputDisabled,
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
onKeyDown: (e) => {
|
|
5376
|
-
if (e.key === "ArrowDown" && !inputDisabled) {
|
|
5377
|
-
e.preventDefault();
|
|
5378
|
-
setOpen(true);
|
|
5379
|
-
}
|
|
5380
|
-
},
|
|
5381
|
-
rightIcon: icon !== void 0 ? icon : /* @__PURE__ */ jsx49(Clock, { className: "h-4 w-4 text-muted-foreground" }),
|
|
5382
|
-
...restProps
|
|
5315
|
+
children: [
|
|
5316
|
+
displayValue || resolvedPlaceholder,
|
|
5317
|
+
icon !== void 0 ? icon : /* @__PURE__ */ jsx49(Clock, { className: "h-4 w-4 text-muted-foreground shrink-0" })
|
|
5318
|
+
]
|
|
5383
5319
|
}
|
|
5384
|
-
) })
|
|
5320
|
+
) }),
|
|
5385
5321
|
/* @__PURE__ */ jsx49(
|
|
5386
5322
|
PopoverContent,
|
|
5387
5323
|
{
|