@codapet/design-system 0.4.7 → 0.4.9
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 +32 -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,
|
|
@@ -2325,7 +2329,7 @@ function DateInput({
|
|
|
2325
2329
|
id: "date",
|
|
2326
2330
|
value,
|
|
2327
2331
|
placeholder: resolvedPlaceholder,
|
|
2328
|
-
className: cn("bg-background cursor-pointer", inputClassName),
|
|
2332
|
+
className: cn("bg-background cursor-pointer", open && "border-blue-500", inputClassName),
|
|
2329
2333
|
onChange: handleInputChange,
|
|
2330
2334
|
onBlur: handleBlur,
|
|
2331
2335
|
disabled: isInputDisabled,
|
|
@@ -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
|
|
|
@@ -2519,6 +2513,7 @@ function DateRangeInput({
|
|
|
2519
2513
|
className: cn(
|
|
2520
2514
|
inputVariants({ size }),
|
|
2521
2515
|
"bg-background cursor-pointer w-full text-left flex items-center justify-between gap-2 font-normal",
|
|
2516
|
+
open && "border-blue-500",
|
|
2522
2517
|
isInputDisabled && "pointer-events-none cursor-not-allowed opacity-50",
|
|
2523
2518
|
inputClassName
|
|
2524
2519
|
),
|
|
@@ -5227,27 +5222,6 @@ function formatTime(time, timeFormat = "12h") {
|
|
|
5227
5222
|
return `${h12p}:${m} ${period}`;
|
|
5228
5223
|
}
|
|
5229
5224
|
}
|
|
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
5225
|
function getDisplayHour(hours, timeFormat) {
|
|
5252
5226
|
if (is24HourFormat(timeFormat)) return hours;
|
|
5253
5227
|
return hours % 12 || 12;
|
|
@@ -5265,28 +5239,19 @@ function TimeInput({
|
|
|
5265
5239
|
inputClassName,
|
|
5266
5240
|
size,
|
|
5267
5241
|
placeholder,
|
|
5268
|
-
onBlur,
|
|
5269
5242
|
icon,
|
|
5270
|
-
formatDisplay
|
|
5271
|
-
...restProps
|
|
5243
|
+
formatDisplay
|
|
5272
5244
|
}) {
|
|
5273
5245
|
const resolvedPlaceholder = placeholder ?? TIME_FORMAT_PLACEHOLDER[timeFormat];
|
|
5274
|
-
const
|
|
5275
|
-
(
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
},
|
|
5280
|
-
[formatDisplay, timeFormat]
|
|
5281
|
-
);
|
|
5246
|
+
const displayValue = React46.useMemo(() => {
|
|
5247
|
+
if (!time) return "";
|
|
5248
|
+
if (formatDisplay) return formatDisplay(time);
|
|
5249
|
+
return formatTime(time, timeFormat);
|
|
5250
|
+
}, [time, formatDisplay, timeFormat]);
|
|
5282
5251
|
const [open, setOpen] = React46.useState(false);
|
|
5283
|
-
const [value, setValue] = React46.useState(displayFormat(time));
|
|
5284
5252
|
const hoursRef = React46.useRef(null);
|
|
5285
5253
|
const minutesRef = React46.useRef(null);
|
|
5286
5254
|
const periodRef = React46.useRef(null);
|
|
5287
|
-
React46.useEffect(() => {
|
|
5288
|
-
setValue(displayFormat(time));
|
|
5289
|
-
}, [time, displayFormat]);
|
|
5290
5255
|
const scrollToSelected = React46.useCallback(() => {
|
|
5291
5256
|
requestAnimationFrame(() => {
|
|
5292
5257
|
for (const ref of [hoursRef, minutesRef, periodRef]) {
|
|
@@ -5304,29 +5269,6 @@ function TimeInput({
|
|
|
5304
5269
|
scrollToSelected();
|
|
5305
5270
|
}
|
|
5306
5271
|
}, [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
5272
|
const handleHourSelect = (hour) => {
|
|
5331
5273
|
let h24;
|
|
5332
5274
|
if (is24HourFormat(timeFormat)) {
|
|
@@ -5359,29 +5301,25 @@ function TimeInput({
|
|
|
5359
5301
|
const selectedMinute = time?.minutes ?? null;
|
|
5360
5302
|
const selectedPeriod = time ? getPeriod(time.hours) : null;
|
|
5361
5303
|
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
|
-
|
|
5304
|
+
/* @__PURE__ */ jsx49(PopoverTrigger, { asChild: true, disabled: inputDisabled, children: /* @__PURE__ */ jsxs24(
|
|
5305
|
+
Button,
|
|
5364
5306
|
{
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
className: cn(
|
|
5368
|
-
|
|
5369
|
-
|
|
5307
|
+
type: "button",
|
|
5308
|
+
variant: "outline",
|
|
5309
|
+
className: cn(
|
|
5310
|
+
inputVariants({ size }),
|
|
5311
|
+
"bg-background cursor-pointer w-full text-left flex items-center justify-between gap-2 font-normal",
|
|
5312
|
+
open && "border-blue-500",
|
|
5313
|
+
inputDisabled && "pointer-events-none cursor-not-allowed opacity-50",
|
|
5314
|
+
inputClassName
|
|
5315
|
+
),
|
|
5370
5316
|
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
|
|
5317
|
+
children: [
|
|
5318
|
+
displayValue || resolvedPlaceholder,
|
|
5319
|
+
icon !== void 0 ? icon : /* @__PURE__ */ jsx49(Clock, { className: "h-4 w-4 text-muted-foreground shrink-0" })
|
|
5320
|
+
]
|
|
5383
5321
|
}
|
|
5384
|
-
) })
|
|
5322
|
+
) }),
|
|
5385
5323
|
/* @__PURE__ */ jsx49(
|
|
5386
5324
|
PopoverContent,
|
|
5387
5325
|
{
|
|
@@ -5403,7 +5341,7 @@ function TimeInput({
|
|
|
5403
5341
|
},
|
|
5404
5342
|
h
|
|
5405
5343
|
)) }) }),
|
|
5406
|
-
/* @__PURE__ */ jsx49("div", { className: "h-56 w-16 overflow-y-auto overscroll-y-contain [-webkit-overflow-scrolling:touch]", children: /* @__PURE__ */ jsx49("div", { ref: minutesRef, className: "flex flex-col p-1 ", children: minutesList.map((m) => /* @__PURE__ */ jsx49(
|
|
5344
|
+
/* @__PURE__ */ jsx49("div", { className: "h-56 w-16 overflow-y-auto overscroll-y-contain [-webkit-overflow-scrolling:touch]", children: /* @__PURE__ */ jsx49("div", { ref: minutesRef, className: cn("flex flex-col p-1", minutesList.length <= 12 && "h-full justify-center"), children: minutesList.map((m) => /* @__PURE__ */ jsx49(
|
|
5407
5345
|
Button,
|
|
5408
5346
|
{
|
|
5409
5347
|
variant: "ghost",
|