@postxl/ui-components 1.3.0 → 1.3.2
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.ts +179 -140
- package/dist/index.js +202 -100
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { clsx } from "clsx";
|
|
|
2
2
|
import { twMerge } from "tailwind-merge";
|
|
3
3
|
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
4
4
|
import { ArrowLeftIcon, ArrowRightIcon, CalendarIcon, CaretSortIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CircleIcon, Cross1Icon, Cross2Icon, DotFilledIcon, DotsHorizontalIcon, DoubleArrowLeftIcon, DoubleArrowRightIcon, DragHandleDots2Icon, EnterFullScreenIcon, MagnifyingGlassIcon } from "@radix-ui/react-icons";
|
|
5
|
+
import * as React$48 from "react";
|
|
5
6
|
import * as React$47 from "react";
|
|
6
7
|
import * as React$46 from "react";
|
|
7
8
|
import * as React$45 from "react";
|
|
@@ -94,13 +95,13 @@ function cn(...inputs) {
|
|
|
94
95
|
//#endregion
|
|
95
96
|
//#region src/accordion/accordion.tsx
|
|
96
97
|
const Accordion = AccordionPrimitive.Root;
|
|
97
|
-
const AccordionItem = React$
|
|
98
|
+
const AccordionItem = React$48.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(AccordionPrimitive.Item, {
|
|
98
99
|
ref,
|
|
99
100
|
className: cn("border-b", className),
|
|
100
101
|
...props
|
|
101
102
|
}));
|
|
102
103
|
AccordionItem.displayName = "AccordionItem";
|
|
103
|
-
const AccordionTrigger = React$
|
|
104
|
+
const AccordionTrigger = React$48.forwardRef(({ className, children,...props }, ref) => /* @__PURE__ */ jsx(AccordionPrimitive.Header, {
|
|
104
105
|
className: "flex",
|
|
105
106
|
children: /* @__PURE__ */ jsxs(AccordionPrimitive.Trigger, {
|
|
106
107
|
ref,
|
|
@@ -110,7 +111,7 @@ const AccordionTrigger = React$47.forwardRef(({ className, children,...props },
|
|
|
110
111
|
})
|
|
111
112
|
}));
|
|
112
113
|
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
|
|
113
|
-
const AccordionContent = React$
|
|
114
|
+
const AccordionContent = React$48.forwardRef(({ className, children,...props }, ref) => /* @__PURE__ */ jsx(AccordionPrimitive.Content, {
|
|
114
115
|
ref,
|
|
115
116
|
className: "overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",
|
|
116
117
|
...props,
|
|
@@ -130,21 +131,21 @@ const alertVariants = cva("relative w-full rounded-lg border px-4 py-3 text-sm [
|
|
|
130
131
|
} },
|
|
131
132
|
defaultVariants: { variant: "default" }
|
|
132
133
|
});
|
|
133
|
-
const Alert = React$
|
|
134
|
+
const Alert = React$47.forwardRef(({ className, variant,...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
134
135
|
ref,
|
|
135
136
|
role: "alert",
|
|
136
137
|
className: cn(alertVariants({ variant }), className),
|
|
137
138
|
...props
|
|
138
139
|
}));
|
|
139
140
|
Alert.displayName = "Alert";
|
|
140
|
-
const AlertTitle = React$
|
|
141
|
+
const AlertTitle = React$47.forwardRef(({ className, children,...props }, ref) => /* @__PURE__ */ jsx("h5", {
|
|
141
142
|
ref,
|
|
142
143
|
className: cn("mb-1 font-medium leading-none tracking-tight", className),
|
|
143
144
|
...props,
|
|
144
145
|
children
|
|
145
146
|
}));
|
|
146
147
|
AlertTitle.displayName = "AlertTitle";
|
|
147
|
-
const AlertDescription = React$
|
|
148
|
+
const AlertDescription = React$47.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
148
149
|
ref,
|
|
149
150
|
className: cn("text-sm [&_p]:leading-relaxed", className),
|
|
150
151
|
...props
|
|
@@ -203,13 +204,13 @@ function Button({ className, variant, size, asChild = false, __e2e_test_id__,...
|
|
|
203
204
|
const AlertDialog = AlertDialogPrimitive.Root;
|
|
204
205
|
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
|
205
206
|
const AlertDialogPortal = AlertDialogPrimitive.Portal;
|
|
206
|
-
const AlertDialogOverlay = React$
|
|
207
|
+
const AlertDialogOverlay = React$46.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(AlertDialogPrimitive.Overlay, {
|
|
207
208
|
className: cn("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", className),
|
|
208
209
|
...props,
|
|
209
210
|
ref
|
|
210
211
|
}));
|
|
211
212
|
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
|
212
|
-
const AlertDialogContent = React$
|
|
213
|
+
const AlertDialogContent = React$46.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsxs(AlertDialogPortal, { children: [/* @__PURE__ */ jsx(AlertDialogOverlay, {}), /* @__PURE__ */ jsx(AlertDialogPrimitive.Content, {
|
|
213
214
|
ref,
|
|
214
215
|
className: cn("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=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", className),
|
|
215
216
|
...props
|
|
@@ -225,25 +226,25 @@ const AlertDialogFooter = ({ className,...props }) => /* @__PURE__ */ jsx("div",
|
|
|
225
226
|
...props
|
|
226
227
|
});
|
|
227
228
|
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
228
|
-
const AlertDialogTitle = React$
|
|
229
|
+
const AlertDialogTitle = React$46.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(AlertDialogPrimitive.Title, {
|
|
229
230
|
ref,
|
|
230
231
|
className: cn("text-lg font-semibold", className),
|
|
231
232
|
...props
|
|
232
233
|
}));
|
|
233
234
|
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
|
234
|
-
const AlertDialogDescription = React$
|
|
235
|
+
const AlertDialogDescription = React$46.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(AlertDialogPrimitive.Description, {
|
|
235
236
|
ref,
|
|
236
237
|
className: cn("text-sm text-muted-foreground", className),
|
|
237
238
|
...props
|
|
238
239
|
}));
|
|
239
240
|
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
|
240
|
-
const AlertDialogAction = React$
|
|
241
|
+
const AlertDialogAction = React$46.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(AlertDialogPrimitive.Action, {
|
|
241
242
|
ref,
|
|
242
243
|
className: cn(buttonVariants(), className),
|
|
243
244
|
...props
|
|
244
245
|
}));
|
|
245
246
|
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
|
246
|
-
const AlertDialogCancel = React$
|
|
247
|
+
const AlertDialogCancel = React$46.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(AlertDialogPrimitive.Cancel, {
|
|
247
248
|
ref,
|
|
248
249
|
className: cn(buttonVariants({ variant: "outline" }), "mt-2 sm:mt-0", className),
|
|
249
250
|
...props
|
|
@@ -252,19 +253,19 @@ AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
|
|
252
253
|
|
|
253
254
|
//#endregion
|
|
254
255
|
//#region src/avatar/avatar.tsx
|
|
255
|
-
const Avatar = React$
|
|
256
|
+
const Avatar = React$45.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(AvatarPrimitive.Root, {
|
|
256
257
|
ref,
|
|
257
258
|
className: cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", className),
|
|
258
259
|
...props
|
|
259
260
|
}));
|
|
260
261
|
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
261
|
-
const AvatarImage = React$
|
|
262
|
+
const AvatarImage = React$45.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(AvatarPrimitive.Image, {
|
|
262
263
|
ref,
|
|
263
264
|
className: cn("aspect-square h-full w-full", className),
|
|
264
265
|
...props
|
|
265
266
|
}));
|
|
266
267
|
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
267
|
-
const AvatarFallback = React$
|
|
268
|
+
const AvatarFallback = React$45.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(AvatarPrimitive.Fallback, {
|
|
268
269
|
ref,
|
|
269
270
|
className: cn("flex h-full w-full items-center justify-center rounded-full bg-muted", className),
|
|
270
271
|
...props
|
|
@@ -310,25 +311,25 @@ function Badge({ className, variant, size, asChild = false,...props }) {
|
|
|
310
311
|
|
|
311
312
|
//#endregion
|
|
312
313
|
//#region src/breadcrumb/breadcrumb.tsx
|
|
313
|
-
const Breadcrumb = React$
|
|
314
|
+
const Breadcrumb = React$44.forwardRef(({ ...props }, ref) => /* @__PURE__ */ jsx("nav", {
|
|
314
315
|
ref,
|
|
315
316
|
"aria-label": "breadcrumb",
|
|
316
317
|
...props
|
|
317
318
|
}));
|
|
318
319
|
Breadcrumb.displayName = "Breadcrumb";
|
|
319
|
-
const BreadcrumbList = React$
|
|
320
|
+
const BreadcrumbList = React$44.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("ol", {
|
|
320
321
|
ref,
|
|
321
322
|
className: cn("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5", className),
|
|
322
323
|
...props
|
|
323
324
|
}));
|
|
324
325
|
BreadcrumbList.displayName = "BreadcrumbList";
|
|
325
|
-
const BreadcrumbItem = React$
|
|
326
|
+
const BreadcrumbItem = React$44.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("li", {
|
|
326
327
|
ref,
|
|
327
328
|
className: cn("inline-flex items-center gap-1.5", className),
|
|
328
329
|
...props
|
|
329
330
|
}));
|
|
330
331
|
BreadcrumbItem.displayName = "BreadcrumbItem";
|
|
331
|
-
const BreadcrumbLink = React$
|
|
332
|
+
const BreadcrumbLink = React$44.forwardRef(({ asChild, className,...props }, ref) => {
|
|
332
333
|
const Comp = asChild ? Slot : "a";
|
|
333
334
|
return /* @__PURE__ */ jsx(Comp, {
|
|
334
335
|
ref,
|
|
@@ -337,7 +338,7 @@ const BreadcrumbLink = React$43.forwardRef(({ asChild, className,...props }, ref
|
|
|
337
338
|
});
|
|
338
339
|
});
|
|
339
340
|
BreadcrumbLink.displayName = "BreadcrumbLink";
|
|
340
|
-
const BreadcrumbPage = React$
|
|
341
|
+
const BreadcrumbPage = React$44.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("span", {
|
|
341
342
|
ref,
|
|
342
343
|
"aria-disabled": "true",
|
|
343
344
|
"aria-current": "page",
|
|
@@ -367,8 +368,8 @@ BreadcrumbEllipsis.displayName = "BreadcrumbElipssis";
|
|
|
367
368
|
//#region src/calendar/calendar.tsx
|
|
368
369
|
function Calendar({ className, classNames, showOutsideDays = true, captionLayout = "label", buttonVariant = "ghost", showYearNavigation = false, formatters, components,...props }) {
|
|
369
370
|
const defaultClassNames = getDefaultClassNames();
|
|
370
|
-
const [rangeSelectionStep, setRangeSelectionStep] = React$
|
|
371
|
-
const handleDayClick = React$
|
|
371
|
+
const [rangeSelectionStep, setRangeSelectionStep] = React$43.useState("from");
|
|
372
|
+
const handleDayClick = React$43.useCallback((day, modifiers, e) => {
|
|
372
373
|
if (props.mode === "range") {
|
|
373
374
|
const range = props.selected;
|
|
374
375
|
if (rangeSelectionStep === "from") {
|
|
@@ -398,8 +399,8 @@ function Calendar({ className, classNames, showOutsideDays = true, captionLayout
|
|
|
398
399
|
fromMonth = props.startMonth ?? new Date(nowYear - 100, 0);
|
|
399
400
|
toMonth = props.endMonth ?? new Date(nowYear + 100, 11);
|
|
400
401
|
}
|
|
401
|
-
const [currentMonth, setCurrentMonth] = React$
|
|
402
|
-
React$
|
|
402
|
+
const [currentMonth, setCurrentMonth] = React$43.useState(props.defaultMonth ?? props.month ?? new Date());
|
|
403
|
+
React$43.useEffect(() => {
|
|
403
404
|
if (props.month) setCurrentMonth(props.month);
|
|
404
405
|
}, [props.month]);
|
|
405
406
|
const addMonths = (date, months) => {
|
|
@@ -538,8 +539,8 @@ function Calendar({ className, classNames, showOutsideDays = true, captionLayout
|
|
|
538
539
|
}
|
|
539
540
|
function CalendarDayButton({ className, day, modifiers,...props }) {
|
|
540
541
|
const defaultClassNames = getDefaultClassNames();
|
|
541
|
-
const ref = React$
|
|
542
|
-
React$
|
|
542
|
+
const ref = React$43.useRef(null);
|
|
543
|
+
React$43.useEffect(() => {
|
|
543
544
|
if (modifiers.focused) ref.current?.focus();
|
|
544
545
|
}, [modifiers.focused]);
|
|
545
546
|
return /* @__PURE__ */ jsx(Button, {
|
|
@@ -558,38 +559,38 @@ function CalendarDayButton({ className, day, modifiers,...props }) {
|
|
|
558
559
|
|
|
559
560
|
//#endregion
|
|
560
561
|
//#region src/card/card.tsx
|
|
561
|
-
const Card = React$
|
|
562
|
+
const Card = React$42.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
562
563
|
ref,
|
|
563
564
|
className: cn("rounded-xl border bg-card text-card-foreground shadow", className),
|
|
564
565
|
...props
|
|
565
566
|
}));
|
|
566
567
|
Card.displayName = "Card";
|
|
567
|
-
const CardHeader = React$
|
|
568
|
+
const CardHeader = React$42.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
568
569
|
ref,
|
|
569
570
|
className: cn("flex flex-col space-y-1.5 p-6", className),
|
|
570
571
|
...props
|
|
571
572
|
}));
|
|
572
573
|
CardHeader.displayName = "CardHeader";
|
|
573
|
-
const CardTitle = React$
|
|
574
|
+
const CardTitle = React$42.forwardRef(({ className, children,...props }, ref) => /* @__PURE__ */ jsx("h3", {
|
|
574
575
|
ref,
|
|
575
576
|
className: cn("font-semibold leading-none tracking-tight", className),
|
|
576
577
|
...props,
|
|
577
578
|
children
|
|
578
579
|
}));
|
|
579
580
|
CardTitle.displayName = "CardTitle";
|
|
580
|
-
const CardDescription = React$
|
|
581
|
+
const CardDescription = React$42.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("p", {
|
|
581
582
|
ref,
|
|
582
583
|
className: cn("text-sm text-muted-foreground", className),
|
|
583
584
|
...props
|
|
584
585
|
}));
|
|
585
586
|
CardDescription.displayName = "CardDescription";
|
|
586
|
-
const CardContent = React$
|
|
587
|
+
const CardContent = React$42.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
587
588
|
ref,
|
|
588
589
|
className: cn("p-6 pt-0", className),
|
|
589
590
|
...props
|
|
590
591
|
}));
|
|
591
592
|
CardContent.displayName = "CardContent";
|
|
592
|
-
const CardFooter = React$
|
|
593
|
+
const CardFooter = React$42.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
593
594
|
ref,
|
|
594
595
|
className: cn("flex items-center p-6 pt-0", className),
|
|
595
596
|
...props
|
|
@@ -600,7 +601,7 @@ CardFooter.displayName = "CardFooter";
|
|
|
600
601
|
//#region src/card-hover/card-hover.tsx
|
|
601
602
|
const HoverCard = HoverCardPrimitive.Root;
|
|
602
603
|
const HoverCardTrigger = HoverCardPrimitive.Trigger;
|
|
603
|
-
const HoverCardContent = React$
|
|
604
|
+
const HoverCardContent = React$41.forwardRef(({ className, align = "center", sideOffset = 4,...props }, ref) => /* @__PURE__ */ jsx(HoverCardPrimitive.Content, {
|
|
604
605
|
ref,
|
|
605
606
|
align,
|
|
606
607
|
sideOffset,
|
|
@@ -611,31 +612,31 @@ HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
|
|
|
611
612
|
|
|
612
613
|
//#endregion
|
|
613
614
|
//#region src/carousel/carousel.tsx
|
|
614
|
-
const CarouselContext = React$
|
|
615
|
+
const CarouselContext = React$40.createContext(null);
|
|
615
616
|
function useCarousel() {
|
|
616
|
-
const context = React$
|
|
617
|
+
const context = React$40.useContext(CarouselContext);
|
|
617
618
|
if (!context) throw new Error("useCarousel must be used within a <Carousel />");
|
|
618
619
|
return context;
|
|
619
620
|
}
|
|
620
|
-
const Carousel = React$
|
|
621
|
+
const Carousel = React$40.forwardRef(({ orientation = "horizontal", opts, setApi, plugins, className, children,...props }, ref) => {
|
|
621
622
|
const [carouselRef, api] = useEmblaCarousel({
|
|
622
623
|
...opts,
|
|
623
624
|
axis: orientation === "horizontal" ? "x" : "y"
|
|
624
625
|
}, plugins);
|
|
625
|
-
const [canScrollPrev, setCanScrollPrev] = React$
|
|
626
|
-
const [canScrollNext, setCanScrollNext] = React$
|
|
627
|
-
const onSelect = React$
|
|
626
|
+
const [canScrollPrev, setCanScrollPrev] = React$40.useState(false);
|
|
627
|
+
const [canScrollNext, setCanScrollNext] = React$40.useState(false);
|
|
628
|
+
const onSelect = React$40.useCallback(() => {
|
|
628
629
|
if (!api) return;
|
|
629
630
|
setCanScrollPrev(api.canScrollPrev());
|
|
630
631
|
setCanScrollNext(api.canScrollNext());
|
|
631
632
|
}, [api]);
|
|
632
|
-
const scrollPrev = React$
|
|
633
|
+
const scrollPrev = React$40.useCallback(() => {
|
|
633
634
|
api?.scrollPrev();
|
|
634
635
|
}, [api]);
|
|
635
|
-
const scrollNext = React$
|
|
636
|
+
const scrollNext = React$40.useCallback(() => {
|
|
636
637
|
api?.scrollNext();
|
|
637
638
|
}, [api]);
|
|
638
|
-
const handleKeyDown = React$
|
|
639
|
+
const handleKeyDown = React$40.useCallback((event) => {
|
|
639
640
|
if (event.key === "ArrowLeft") {
|
|
640
641
|
event.preventDefault();
|
|
641
642
|
scrollPrev();
|
|
@@ -644,11 +645,11 @@ const Carousel = React$39.forwardRef(({ orientation = "horizontal", opts, setApi
|
|
|
644
645
|
scrollNext();
|
|
645
646
|
}
|
|
646
647
|
}, [scrollPrev, scrollNext]);
|
|
647
|
-
React$
|
|
648
|
+
React$40.useEffect(() => {
|
|
648
649
|
if (!api || !setApi) return;
|
|
649
650
|
setApi(api);
|
|
650
651
|
}, [api, setApi]);
|
|
651
|
-
React$
|
|
652
|
+
React$40.useEffect(() => {
|
|
652
653
|
if (!api) return;
|
|
653
654
|
onSelect();
|
|
654
655
|
api.on("reInit", onSelect);
|
|
@@ -689,7 +690,7 @@ const Carousel = React$39.forwardRef(({ orientation = "horizontal", opts, setApi
|
|
|
689
690
|
});
|
|
690
691
|
});
|
|
691
692
|
Carousel.displayName = "Carousel";
|
|
692
|
-
const CarouselContent = React$
|
|
693
|
+
const CarouselContent = React$40.forwardRef(({ className,...props }, ref) => {
|
|
693
694
|
const { carouselRef, orientation } = useCarousel();
|
|
694
695
|
return /* @__PURE__ */ jsx("div", {
|
|
695
696
|
ref: carouselRef,
|
|
@@ -702,7 +703,7 @@ const CarouselContent = React$39.forwardRef(({ className,...props }, ref) => {
|
|
|
702
703
|
});
|
|
703
704
|
});
|
|
704
705
|
CarouselContent.displayName = "CarouselContent";
|
|
705
|
-
const CarouselItem = React$
|
|
706
|
+
const CarouselItem = React$40.forwardRef(({ className,...props }, ref) => {
|
|
706
707
|
const { orientation } = useCarousel();
|
|
707
708
|
return /* @__PURE__ */ jsx("div", {
|
|
708
709
|
ref,
|
|
@@ -712,7 +713,7 @@ const CarouselItem = React$39.forwardRef(({ className,...props }, ref) => {
|
|
|
712
713
|
});
|
|
713
714
|
});
|
|
714
715
|
CarouselItem.displayName = "CarouselItem";
|
|
715
|
-
const CarouselPrevious = React$
|
|
716
|
+
const CarouselPrevious = React$40.forwardRef(({ className, variant = "outline", size = "icon",...props }, ref) => {
|
|
716
717
|
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
717
718
|
return /* @__PURE__ */ jsxs(Button, {
|
|
718
719
|
ref,
|
|
@@ -729,7 +730,7 @@ const CarouselPrevious = React$39.forwardRef(({ className, variant = "outline",
|
|
|
729
730
|
});
|
|
730
731
|
});
|
|
731
732
|
CarouselPrevious.displayName = "CarouselPrevious";
|
|
732
|
-
const CarouselNext = React$
|
|
733
|
+
const CarouselNext = React$40.forwardRef(({ className, variant = "outline", size = "icon",...props }, ref) => {
|
|
733
734
|
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
734
735
|
return /* @__PURE__ */ jsxs(Button, {
|
|
735
736
|
ref,
|
|
@@ -913,7 +914,7 @@ function DialogDescription({ className,...props }) {
|
|
|
913
914
|
|
|
914
915
|
//#endregion
|
|
915
916
|
//#region src/command-palette/command-palette.tsx
|
|
916
|
-
const CommandPalette = React$
|
|
917
|
+
const CommandPalette = React$39.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(Command$1, {
|
|
917
918
|
ref,
|
|
918
919
|
className: cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground", className),
|
|
919
920
|
...props
|
|
@@ -931,7 +932,7 @@ const CommandPaletteDialog = ({ children,...props }) => {
|
|
|
931
932
|
})
|
|
932
933
|
});
|
|
933
934
|
};
|
|
934
|
-
const CommandPaletteInput = React$
|
|
935
|
+
const CommandPaletteInput = React$39.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsxs("div", {
|
|
935
936
|
className: "flex items-center border-b px-3",
|
|
936
937
|
"data-cmdk-input-wrapper": "",
|
|
937
938
|
children: [/* @__PURE__ */ jsx(MagnifyingGlassIcon, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }), /* @__PURE__ */ jsx(Command$1.Input, {
|
|
@@ -941,31 +942,31 @@ const CommandPaletteInput = React$38.forwardRef(({ className,...props }, ref) =>
|
|
|
941
942
|
})]
|
|
942
943
|
}));
|
|
943
944
|
CommandPaletteInput.displayName = Command$1.Input.displayName;
|
|
944
|
-
const CommandPaletteList = React$
|
|
945
|
+
const CommandPaletteList = React$39.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(Command$1.List, {
|
|
945
946
|
ref,
|
|
946
947
|
className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className),
|
|
947
948
|
...props
|
|
948
949
|
}));
|
|
949
950
|
CommandPaletteList.displayName = Command$1.List.displayName;
|
|
950
|
-
const CommandPaletteEmpty = React$
|
|
951
|
+
const CommandPaletteEmpty = React$39.forwardRef((props, ref) => /* @__PURE__ */ jsx(Command$1.Empty, {
|
|
951
952
|
ref,
|
|
952
953
|
className: "py-6 text-center text-sm",
|
|
953
954
|
...props
|
|
954
955
|
}));
|
|
955
956
|
CommandPaletteEmpty.displayName = Command$1.Empty.displayName;
|
|
956
|
-
const CommandPaletteGroup = React$
|
|
957
|
+
const CommandPaletteGroup = React$39.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(Command$1.Group, {
|
|
957
958
|
ref,
|
|
958
959
|
className: cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground", className),
|
|
959
960
|
...props
|
|
960
961
|
}));
|
|
961
962
|
CommandPaletteGroup.displayName = Command$1.Group.displayName;
|
|
962
|
-
const CommandPaletteSeparator = React$
|
|
963
|
+
const CommandPaletteSeparator = React$39.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(Command$1.Separator, {
|
|
963
964
|
ref,
|
|
964
965
|
className: cn("-mx-1 h-px bg-border", className),
|
|
965
966
|
...props
|
|
966
967
|
}));
|
|
967
968
|
CommandPaletteSeparator.displayName = Command$1.Separator.displayName;
|
|
968
|
-
const CommandPaletteItem = React$
|
|
969
|
+
const CommandPaletteItem = React$39.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(Command$1.Item, {
|
|
969
970
|
ref,
|
|
970
971
|
className: cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50", className),
|
|
971
972
|
...props
|
|
@@ -1041,8 +1042,8 @@ const frameworks = [
|
|
|
1041
1042
|
}
|
|
1042
1043
|
];
|
|
1043
1044
|
function ComboboxDemo() {
|
|
1044
|
-
const [open, setOpen] = React$
|
|
1045
|
-
const [value, setValue] = React$
|
|
1045
|
+
const [open, setOpen] = React$38.useState(false);
|
|
1046
|
+
const [value, setValue] = React$38.useState("");
|
|
1046
1047
|
return /* @__PURE__ */ jsxs(Popover, {
|
|
1047
1048
|
open,
|
|
1048
1049
|
onOpenChange: setOpen,
|
|
@@ -1282,32 +1283,32 @@ const ContextMenuGroup = ContextMenuPrimitive.Group;
|
|
|
1282
1283
|
const ContextMenuPortal = ContextMenuPrimitive.Portal;
|
|
1283
1284
|
const ContextMenuSub = ContextMenuPrimitive.Sub;
|
|
1284
1285
|
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
|
|
1285
|
-
const ContextMenuSubTrigger = React$
|
|
1286
|
+
const ContextMenuSubTrigger = React$37.forwardRef(({ className, inset, children,...props }, ref) => /* @__PURE__ */ jsxs(ContextMenuPrimitive.SubTrigger, {
|
|
1286
1287
|
ref,
|
|
1287
1288
|
className: cn("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground", inset && "pl-8", className),
|
|
1288
1289
|
...props,
|
|
1289
1290
|
children: [children, /* @__PURE__ */ jsx(ChevronRightIcon, { className: "ml-auto h-4 w-4" })]
|
|
1290
1291
|
}));
|
|
1291
1292
|
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
|
|
1292
|
-
const ContextMenuSubContent = React$
|
|
1293
|
+
const ContextMenuSubContent = React$37.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(ContextMenuPrimitive.SubContent, {
|
|
1293
1294
|
ref,
|
|
1294
1295
|
className: cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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", className),
|
|
1295
1296
|
...props
|
|
1296
1297
|
}));
|
|
1297
1298
|
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
|
|
1298
|
-
const ContextMenuContent = React$
|
|
1299
|
+
const ContextMenuContent = React$37.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(ContextMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(ContextMenuPrimitive.Content, {
|
|
1299
1300
|
ref,
|
|
1300
1301
|
className: cn("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", className),
|
|
1301
1302
|
...props
|
|
1302
1303
|
}) }));
|
|
1303
1304
|
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
|
1304
|
-
const ContextMenuItem = React$
|
|
1305
|
+
const ContextMenuItem = React$37.forwardRef(({ className, inset,...props }, ref) => /* @__PURE__ */ jsx(ContextMenuPrimitive.Item, {
|
|
1305
1306
|
ref,
|
|
1306
1307
|
className: cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", inset && "pl-8", className),
|
|
1307
1308
|
...props
|
|
1308
1309
|
}));
|
|
1309
1310
|
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
|
1310
|
-
const ContextMenuCheckboxItem = React$
|
|
1311
|
+
const ContextMenuCheckboxItem = React$37.forwardRef(({ className, children, checked,...props }, ref) => /* @__PURE__ */ jsxs(ContextMenuPrimitive.CheckboxItem, {
|
|
1311
1312
|
ref,
|
|
1312
1313
|
className: cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className),
|
|
1313
1314
|
checked,
|
|
@@ -1318,7 +1319,7 @@ const ContextMenuCheckboxItem = React$36.forwardRef(({ className, children, chec
|
|
|
1318
1319
|
}), children]
|
|
1319
1320
|
}));
|
|
1320
1321
|
ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName;
|
|
1321
|
-
const ContextMenuRadioItem = React$
|
|
1322
|
+
const ContextMenuRadioItem = React$37.forwardRef(({ className, children,...props }, ref) => /* @__PURE__ */ jsxs(ContextMenuPrimitive.RadioItem, {
|
|
1322
1323
|
ref,
|
|
1323
1324
|
className: cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className),
|
|
1324
1325
|
...props,
|
|
@@ -1328,13 +1329,13 @@ const ContextMenuRadioItem = React$36.forwardRef(({ className, children,...props
|
|
|
1328
1329
|
}), children]
|
|
1329
1330
|
}));
|
|
1330
1331
|
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;
|
|
1331
|
-
const ContextMenuLabel = React$
|
|
1332
|
+
const ContextMenuLabel = React$37.forwardRef(({ className, inset,...props }, ref) => /* @__PURE__ */ jsx(ContextMenuPrimitive.Label, {
|
|
1332
1333
|
ref,
|
|
1333
1334
|
className: cn("px-2 py-1.5 text-sm font-semibold text-foreground", inset && "pl-8", className),
|
|
1334
1335
|
...props
|
|
1335
1336
|
}));
|
|
1336
1337
|
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;
|
|
1337
|
-
const ContextMenuSeparator = React$
|
|
1338
|
+
const ContextMenuSeparator = React$37.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(ContextMenuPrimitive.Separator, {
|
|
1338
1339
|
ref,
|
|
1339
1340
|
className: cn("-mx-1 my-1 h-px bg-border", className),
|
|
1340
1341
|
...props
|
|
@@ -1479,7 +1480,7 @@ function DropdownMenuSubContent({ className,...props }) {
|
|
|
1479
1480
|
const TooltipProvider = TooltipPrimitive.Provider;
|
|
1480
1481
|
const Tooltip = TooltipPrimitive.Root;
|
|
1481
1482
|
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
1482
|
-
const TooltipContent = React$
|
|
1483
|
+
const TooltipContent = React$36.forwardRef(({ className, sideOffset = 4,...props }, ref) => /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx(TooltipPrimitive.Content, {
|
|
1483
1484
|
ref,
|
|
1484
1485
|
sideOffset,
|
|
1485
1486
|
className: cn("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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", className),
|
|
@@ -1986,7 +1987,7 @@ function getColumnVariant(variant) {
|
|
|
1986
1987
|
}
|
|
1987
1988
|
}
|
|
1988
1989
|
function DataGridColumnHeader({ header, table, className, onPointerDown,...props }) {
|
|
1989
|
-
const [open, setOpen] = React$
|
|
1990
|
+
const [open, setOpen] = React$35.useState(false);
|
|
1990
1991
|
const column = header.column;
|
|
1991
1992
|
const label = column.columnDef.meta?.label ? column.columnDef.meta.label : typeof column.columnDef.header === "string" ? column.columnDef.header : column.id;
|
|
1992
1993
|
const isAnyColumnResizing = table.getState().columnSizingInfo.isResizingColumn;
|
|
@@ -1995,7 +1996,7 @@ function DataGridColumnHeader({ header, table, className, onPointerDown,...props
|
|
|
1995
1996
|
const pinnedPosition = column.getIsPinned();
|
|
1996
1997
|
const isPinnedLeft = pinnedPosition === "left";
|
|
1997
1998
|
const isPinnedRight = pinnedPosition === "right";
|
|
1998
|
-
const onSortingChange = React$
|
|
1999
|
+
const onSortingChange = React$35.useCallback((direction) => {
|
|
1999
2000
|
table.setSorting((prev) => {
|
|
2000
2001
|
const existingSortIndex = prev.findIndex((sort) => sort.id === column.id);
|
|
2001
2002
|
const newSort = {
|
|
@@ -2009,19 +2010,19 @@ function DataGridColumnHeader({ header, table, className, onPointerDown,...props
|
|
|
2009
2010
|
} else return [...prev, newSort];
|
|
2010
2011
|
});
|
|
2011
2012
|
}, [column.id, table]);
|
|
2012
|
-
const onSortRemove = React$
|
|
2013
|
+
const onSortRemove = React$35.useCallback(() => {
|
|
2013
2014
|
table.setSorting((prev) => prev.filter((sort) => sort.id !== column.id));
|
|
2014
2015
|
}, [column.id, table]);
|
|
2015
|
-
const onLeftPin = React$
|
|
2016
|
+
const onLeftPin = React$35.useCallback(() => {
|
|
2016
2017
|
column.pin("left");
|
|
2017
2018
|
}, [column]);
|
|
2018
|
-
const onRightPin = React$
|
|
2019
|
+
const onRightPin = React$35.useCallback(() => {
|
|
2019
2020
|
column.pin("right");
|
|
2020
2021
|
}, [column]);
|
|
2021
|
-
const onUnpin = React$
|
|
2022
|
+
const onUnpin = React$35.useCallback(() => {
|
|
2022
2023
|
column.pin(false);
|
|
2023
2024
|
}, [column]);
|
|
2024
|
-
const onTriggerPointerDown = React$
|
|
2025
|
+
const onTriggerPointerDown = React$35.useCallback((event) => {
|
|
2025
2026
|
onPointerDown?.(event);
|
|
2026
2027
|
if (event.defaultPrevented) return;
|
|
2027
2028
|
if (event.button !== 0) return;
|
|
@@ -2133,7 +2134,7 @@ function DataGridColumnHeader({ header, table, className, onPointerDown,...props
|
|
|
2133
2134
|
})
|
|
2134
2135
|
] });
|
|
2135
2136
|
}
|
|
2136
|
-
const DataGridColumnResizer = React$
|
|
2137
|
+
const DataGridColumnResizer = React$35.memo(DataGridColumnResizerImpl, (prev, next) => {
|
|
2137
2138
|
const prevColumn = prev.header.column;
|
|
2138
2139
|
const nextColumn = next.header.column;
|
|
2139
2140
|
if (prevColumn.getIsResizing() !== nextColumn.getIsResizing() || prevColumn.getSize() !== nextColumn.getSize()) return false;
|
|
@@ -2142,7 +2143,7 @@ const DataGridColumnResizer = React$34.memo(DataGridColumnResizerImpl, (prev, ne
|
|
|
2142
2143
|
});
|
|
2143
2144
|
function DataGridColumnResizerImpl({ header, table, label }) {
|
|
2144
2145
|
const defaultColumnDef = table._getDefaultColumnDef();
|
|
2145
|
-
const onDoubleClick = React$
|
|
2146
|
+
const onDoubleClick = React$35.useCallback(() => {
|
|
2146
2147
|
header.column.resetSize();
|
|
2147
2148
|
}, [header.column]);
|
|
2148
2149
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -2251,7 +2252,7 @@ function DataGridContextMenu({ table }) {
|
|
|
2251
2252
|
onRowsDelete
|
|
2252
2253
|
});
|
|
2253
2254
|
}
|
|
2254
|
-
const ContextMenu$1 = React$
|
|
2255
|
+
const ContextMenu$1 = React$34.memo(ContextMenuImpl, (prev, next) => {
|
|
2255
2256
|
if (prev.contextMenu.open !== next.contextMenu.open) return false;
|
|
2256
2257
|
if (!next.contextMenu.open) return true;
|
|
2257
2258
|
if (prev.contextMenu.x !== next.contextMenu.x) return false;
|
|
@@ -2262,7 +2263,7 @@ const ContextMenu$1 = React$33.memo(ContextMenuImpl, (prev, next) => {
|
|
|
2262
2263
|
return true;
|
|
2263
2264
|
});
|
|
2264
2265
|
function ContextMenuImpl({ table, dataGridRef, contextMenu, onContextMenuOpenChange, selectionState, onDataUpdate, onRowsDelete }) {
|
|
2265
|
-
const triggerStyle = React$
|
|
2266
|
+
const triggerStyle = React$34.useMemo(() => ({
|
|
2266
2267
|
position: "fixed",
|
|
2267
2268
|
left: `${contextMenu.x}px`,
|
|
2268
2269
|
top: `${contextMenu.y}px`,
|
|
@@ -2275,11 +2276,11 @@ function ContextMenuImpl({ table, dataGridRef, contextMenu, onContextMenuOpenCha
|
|
|
2275
2276
|
pointerEvents: "none",
|
|
2276
2277
|
opacity: 0
|
|
2277
2278
|
}), [contextMenu.x, contextMenu.y]);
|
|
2278
|
-
const onCloseAutoFocus = React$
|
|
2279
|
+
const onCloseAutoFocus = React$34.useCallback((event) => {
|
|
2279
2280
|
event.preventDefault();
|
|
2280
2281
|
dataGridRef?.current?.focus();
|
|
2281
2282
|
}, [dataGridRef]);
|
|
2282
|
-
const onCopy = React$
|
|
2283
|
+
const onCopy = React$34.useCallback(async () => {
|
|
2283
2284
|
if (!selectionState?.selectedCells || selectionState.selectedCells.size === 0) return;
|
|
2284
2285
|
const rows = table.getRowModel().rows;
|
|
2285
2286
|
const columnIds = [];
|
|
@@ -2318,7 +2319,7 @@ function ContextMenuImpl({ table, dataGridRef, contextMenu, onContextMenuOpenCha
|
|
|
2318
2319
|
await navigator.clipboard.writeText(tsvData);
|
|
2319
2320
|
toast$1.success(`${selectionState.selectedCells.size} cell${selectionState.selectedCells.size !== 1 ? "s" : ""} copied`);
|
|
2320
2321
|
}, [table, selectionState]);
|
|
2321
|
-
const canClear = React$
|
|
2322
|
+
const canClear = React$34.useMemo(() => {
|
|
2322
2323
|
if (!selectionState?.selectedCells || selectionState.selectedCells.size === 0) return false;
|
|
2323
2324
|
const visibleCols = table.getVisibleLeafColumns();
|
|
2324
2325
|
const rows = table.getRowModel().rows;
|
|
@@ -2335,7 +2336,7 @@ function ContextMenuImpl({ table, dataGridRef, contextMenu, onContextMenuOpenCha
|
|
|
2335
2336
|
}
|
|
2336
2337
|
return true;
|
|
2337
2338
|
}, [selectionState, table]);
|
|
2338
|
-
const onClear = React$
|
|
2339
|
+
const onClear = React$34.useCallback(() => {
|
|
2339
2340
|
if (!selectionState?.selectedCells || selectionState.selectedCells.size === 0) return;
|
|
2340
2341
|
if (!canClear) return;
|
|
2341
2342
|
const updates = [];
|
|
@@ -2354,7 +2355,7 @@ function ContextMenuImpl({ table, dataGridRef, contextMenu, onContextMenuOpenCha
|
|
|
2354
2355
|
selectionState,
|
|
2355
2356
|
canClear
|
|
2356
2357
|
]);
|
|
2357
|
-
const onDelete = React$
|
|
2358
|
+
const onDelete = React$34.useCallback(async () => {
|
|
2358
2359
|
if (!selectionState?.selectedCells || selectionState.selectedCells.size === 0) return;
|
|
2359
2360
|
const rowIndices = new Set();
|
|
2360
2361
|
for (const cellKey of selectionState.selectedCells) {
|
|
@@ -2431,12 +2432,12 @@ function composeRefs(...refs) {
|
|
|
2431
2432
|
* Accepts callback refs and RefObject(s)
|
|
2432
2433
|
*/
|
|
2433
2434
|
function useComposedRefs(...refs) {
|
|
2434
|
-
return React$
|
|
2435
|
+
return React$33.useCallback(composeRefs(...refs), refs);
|
|
2435
2436
|
}
|
|
2436
2437
|
|
|
2437
2438
|
//#endregion
|
|
2438
2439
|
//#region src/data-grid/data-grid-row.tsx
|
|
2439
|
-
const DataGridRow = React$
|
|
2440
|
+
const DataGridRow = React$32.memo(DataGridRowImpl, (prev, next) => {
|
|
2440
2441
|
if (prev.row.id !== next.row.id) return false;
|
|
2441
2442
|
if (prev.row.original !== next.row.original) return false;
|
|
2442
2443
|
const prevRowIndex = prev.virtualRowIndex;
|
|
@@ -2466,7 +2467,7 @@ function DataGridRowImpl({ row, virtualRowIndex, virtualStart, rowVirtualizer, r
|
|
|
2466
2467
|
}
|
|
2467
2468
|
});
|
|
2468
2469
|
const isRowSelected = row.getIsSelected();
|
|
2469
|
-
const handleRowClick = React$
|
|
2470
|
+
const handleRowClick = React$32.useCallback((event) => {
|
|
2470
2471
|
const target = event.target;
|
|
2471
2472
|
if (target.closest("input, button, [role=\"checkbox\"]")) return;
|
|
2472
2473
|
if (event.detail === 1) onRowClick?.(virtualRowIndex);
|
|
@@ -2516,20 +2517,20 @@ function DataGridRowImpl({ row, virtualRowIndex, virtualStart, rowVirtualizer, r
|
|
|
2516
2517
|
* prop or avoid re-executing effects when passed as a dependency
|
|
2517
2518
|
*/
|
|
2518
2519
|
function useCallbackRef(callback) {
|
|
2519
|
-
const callbackRef = React$
|
|
2520
|
-
React$
|
|
2520
|
+
const callbackRef = React$31.useRef(callback);
|
|
2521
|
+
React$31.useEffect(() => {
|
|
2521
2522
|
callbackRef.current = callback;
|
|
2522
2523
|
});
|
|
2523
|
-
return React$
|
|
2524
|
+
return React$31.useMemo(() => (...args) => callbackRef.current?.(...args), []);
|
|
2524
2525
|
}
|
|
2525
2526
|
|
|
2526
2527
|
//#endregion
|
|
2527
2528
|
//#region src/hooks/use-debounced-callback.ts
|
|
2528
2529
|
function useDebouncedCallback(callback, delay) {
|
|
2529
2530
|
const handleCallback = useCallbackRef(callback);
|
|
2530
|
-
const debounceTimerRef = React$
|
|
2531
|
-
React$
|
|
2532
|
-
const setValue = React$
|
|
2531
|
+
const debounceTimerRef = React$30.useRef(0);
|
|
2532
|
+
React$30.useEffect(() => () => window.clearTimeout(debounceTimerRef.current), []);
|
|
2533
|
+
const setValue = React$30.useCallback((...args) => {
|
|
2533
2534
|
window.clearTimeout(debounceTimerRef.current);
|
|
2534
2535
|
debounceTimerRef.current = window.setTimeout(() => handleCallback(...args), delay);
|
|
2535
2536
|
}, [handleCallback, delay]);
|
|
@@ -2549,8 +2550,8 @@ const inputVariants = cva("file:text-foreground placeholder:text-muted-foregroun
|
|
|
2549
2550
|
} },
|
|
2550
2551
|
defaultVariants: { variant: "default" }
|
|
2551
2552
|
});
|
|
2552
|
-
|
|
2553
|
-
|
|
2553
|
+
const Input = React$29.forwardRef(({ className, type, variant, __e2e_test_id__, onEnter, wrapperClassName,...props }, ref) => {
|
|
2554
|
+
const input = /* @__PURE__ */ jsx("input", {
|
|
2554
2555
|
type,
|
|
2555
2556
|
"data-slot": "input",
|
|
2556
2557
|
className: cn(inputVariants({
|
|
@@ -2562,9 +2563,16 @@ function Input({ className, type, variant, __e2e_test_id__, onEnter,...props })
|
|
|
2562
2563
|
props.onKeyDown?.(e);
|
|
2563
2564
|
if (e.key === "Enter") onEnter?.();
|
|
2564
2565
|
},
|
|
2566
|
+
ref,
|
|
2565
2567
|
...props
|
|
2566
2568
|
});
|
|
2567
|
-
|
|
2569
|
+
if (wrapperClassName) return /* @__PURE__ */ jsx("div", {
|
|
2570
|
+
className: wrapperClassName,
|
|
2571
|
+
children: input
|
|
2572
|
+
});
|
|
2573
|
+
return input;
|
|
2574
|
+
});
|
|
2575
|
+
Input.displayName = "Input";
|
|
2568
2576
|
|
|
2569
2577
|
//#endregion
|
|
2570
2578
|
//#region src/data-grid/data-grid-search.tsx
|
|
@@ -6084,9 +6092,52 @@ function useIsMobile(mobileBreakpoint = 768) {
|
|
|
6084
6092
|
//#endregion
|
|
6085
6093
|
//#region src/input/number-input.tsx
|
|
6086
6094
|
/**
|
|
6095
|
+
* Formats a number according to the provided formatter
|
|
6096
|
+
*/
|
|
6097
|
+
function formatNumber(value, formatter, intlFormatter) {
|
|
6098
|
+
if (typeof formatter === "function") return formatter(value);
|
|
6099
|
+
if (intlFormatter) return intlFormatter.format(value);
|
|
6100
|
+
const { locale, options } = formatter;
|
|
6101
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
6102
|
+
}
|
|
6103
|
+
/**
|
|
6104
|
+
* Parses a formatted string back to a number using the format configuration
|
|
6105
|
+
* This is more robust than heuristics as it uses the actual locale/format settings
|
|
6106
|
+
*/
|
|
6107
|
+
function parseFormattedNumber(formatted, formatter, intlFormatter) {
|
|
6108
|
+
if (formatted === "") return void 0;
|
|
6109
|
+
if (typeof formatter === "function") return parseFormattedNumberHeuristic(formatted);
|
|
6110
|
+
const formatterToUse = intlFormatter ?? new Intl.NumberFormat(formatter.locale, formatter.options);
|
|
6111
|
+
const parts = formatterToUse.formatToParts(12345.6);
|
|
6112
|
+
const groupSeparator = parts.find((p) => p.type === "group")?.value ?? "";
|
|
6113
|
+
const decimalSeparator = parts.find((p) => p.type === "decimal")?.value ?? ".";
|
|
6114
|
+
const normalized = formatted.replaceAll(groupSeparator, "").replaceAll(decimalSeparator, ".").replaceAll(/[^\d.-]/g, "");
|
|
6115
|
+
let parsed = Number(normalized);
|
|
6116
|
+
if (Number.isNaN(parsed)) return void 0;
|
|
6117
|
+
if (formatter.options?.style === "percent") parsed = parsed / 100;
|
|
6118
|
+
return parsed;
|
|
6119
|
+
}
|
|
6120
|
+
/**
|
|
6121
|
+
* Fallback parser for custom format functions where we don't know the format rules
|
|
6122
|
+
* Uses heuristics to guess the decimal separator
|
|
6123
|
+
*/
|
|
6124
|
+
function parseFormattedNumberHeuristic(formatted) {
|
|
6125
|
+
let cleaned = formatted.trim();
|
|
6126
|
+
const lastComma = cleaned.lastIndexOf(",");
|
|
6127
|
+
const lastPeriod = cleaned.lastIndexOf(".");
|
|
6128
|
+
if (lastComma > lastPeriod) {
|
|
6129
|
+
cleaned = cleaned.replaceAll(/[.\s']/g, "");
|
|
6130
|
+
cleaned = cleaned.replace(",", ".");
|
|
6131
|
+
} else if (lastPeriod > lastComma) cleaned = cleaned.replaceAll(/[,\s']/g, "");
|
|
6132
|
+
else cleaned = cleaned.replaceAll(/[,.\s']/g, "");
|
|
6133
|
+
cleaned = cleaned.replaceAll(/[^0-9.-]/g, "");
|
|
6134
|
+
const parsed = Number(cleaned);
|
|
6135
|
+
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
6136
|
+
}
|
|
6137
|
+
/**
|
|
6087
6138
|
* Wrapper variants that mirror inputVariants but use focus-within (for wrapper)
|
|
6088
6139
|
* instead of focus-visible (for input element).
|
|
6089
|
-
*
|
|
6140
|
+
* Note: When modifying variants, also update inputVariants in input.tsx
|
|
6090
6141
|
*/
|
|
6091
6142
|
const numberInputWrapperVariants = cva("border-input bg-background grid grid-cols-[auto_1fr_auto] items-center overflow-hidden rounded-md border shadow-xs transition-[color,box-shadow] has-[input:disabled]:pointer-events-none has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50", {
|
|
6092
6143
|
variants: { variant: {
|
|
@@ -6095,19 +6146,26 @@ const numberInputWrapperVariants = cva("border-input bg-background grid grid-col
|
|
|
6095
6146
|
} },
|
|
6096
6147
|
defaultVariants: { variant: "default" }
|
|
6097
6148
|
});
|
|
6098
|
-
const NumberInput = React$10.forwardRef(({ className, wrapperClassName, prefix, suffix, variant, showSpinButtons = false, __e2e_test_id__, onEnter,...props }, ref) => {
|
|
6149
|
+
const NumberInput = React$10.forwardRef(({ className, wrapperClassName, prefix, suffix, variant, showSpinButtons = false, __e2e_test_id__, onEnter, onChange, format: format$1, value: controlledValue,...props }, ref) => {
|
|
6150
|
+
const [isFocused, setIsFocused] = React$10.useState(false);
|
|
6151
|
+
const [inputString, setInputString] = React$10.useState("");
|
|
6152
|
+
const intlFormatter = React$10.useMemo(() => {
|
|
6153
|
+
if (!format$1 || typeof format$1 === "function") return void 0;
|
|
6154
|
+
return new Intl.NumberFormat(format$1.locale, format$1.options);
|
|
6155
|
+
}, [format$1]);
|
|
6099
6156
|
const focusInputAtPosition = (element, cursor) => {
|
|
6100
6157
|
const parent = element.parentElement;
|
|
6101
6158
|
if (!parent) return;
|
|
6102
6159
|
const input = parent.querySelector("input");
|
|
6103
6160
|
if (!input) return;
|
|
6104
|
-
input.type
|
|
6161
|
+
const originalType = input.type;
|
|
6162
|
+
if (originalType === "number") input.type = "text";
|
|
6105
6163
|
if (cursor === "start") input.setSelectionRange(0, 0);
|
|
6106
6164
|
else {
|
|
6107
6165
|
const length = input.value.length;
|
|
6108
6166
|
input.setSelectionRange(length, length);
|
|
6109
6167
|
}
|
|
6110
|
-
input.type =
|
|
6168
|
+
input.type = originalType;
|
|
6111
6169
|
input.click();
|
|
6112
6170
|
input.focus();
|
|
6113
6171
|
};
|
|
@@ -6121,6 +6179,46 @@ const NumberInput = React$10.forwardRef(({ className, wrapperClassName, prefix,
|
|
|
6121
6179
|
focusInputAtPosition(e.target, cursor);
|
|
6122
6180
|
}
|
|
6123
6181
|
};
|
|
6182
|
+
const handleChange = (e) => {
|
|
6183
|
+
const value = e.target.value;
|
|
6184
|
+
if (format$1) setInputString(value);
|
|
6185
|
+
let parsedValue;
|
|
6186
|
+
if (format$1) parsedValue = parseFormattedNumber(value, format$1, intlFormatter);
|
|
6187
|
+
else parsedValue = value === "" ? void 0 : Number(value);
|
|
6188
|
+
onChange?.(parsedValue);
|
|
6189
|
+
};
|
|
6190
|
+
const handleFocus = (e) => {
|
|
6191
|
+
setIsFocused(true);
|
|
6192
|
+
props.onFocus?.(e);
|
|
6193
|
+
};
|
|
6194
|
+
const handleBlur = (e) => {
|
|
6195
|
+
setIsFocused(false);
|
|
6196
|
+
setInputString("");
|
|
6197
|
+
props.onBlur?.(e);
|
|
6198
|
+
};
|
|
6199
|
+
const displayValue = React$10.useMemo(() => {
|
|
6200
|
+
if (isFocused && format$1) {
|
|
6201
|
+
if (inputString !== "") return inputString;
|
|
6202
|
+
if (controlledValue !== void 0) {
|
|
6203
|
+
const formatted = formatNumber(controlledValue, format$1, intlFormatter);
|
|
6204
|
+
if (typeof format$1 !== "function" && intlFormatter) {
|
|
6205
|
+
const parts = intlFormatter.formatToParts(controlledValue);
|
|
6206
|
+
const groupSeparator = parts.find((p) => p.type === "group")?.value ?? "";
|
|
6207
|
+
return formatted.replaceAll(groupSeparator, "");
|
|
6208
|
+
}
|
|
6209
|
+
return controlledValue.toString();
|
|
6210
|
+
}
|
|
6211
|
+
return "";
|
|
6212
|
+
}
|
|
6213
|
+
if (!isFocused && format$1 && controlledValue !== void 0) return formatNumber(controlledValue, format$1, intlFormatter);
|
|
6214
|
+
return controlledValue?.toString() ?? "";
|
|
6215
|
+
}, [
|
|
6216
|
+
isFocused,
|
|
6217
|
+
format$1,
|
|
6218
|
+
inputString,
|
|
6219
|
+
controlledValue,
|
|
6220
|
+
intlFormatter
|
|
6221
|
+
]);
|
|
6124
6222
|
return /* @__PURE__ */ jsxs("div", {
|
|
6125
6223
|
className: cn(numberInputWrapperVariants({ variant }), wrapperClassName),
|
|
6126
6224
|
children: [
|
|
@@ -6131,7 +6229,7 @@ const NumberInput = React$10.forwardRef(({ className, wrapperClassName, prefix,
|
|
|
6131
6229
|
children: prefix
|
|
6132
6230
|
}),
|
|
6133
6231
|
/* @__PURE__ */ jsx("input", {
|
|
6134
|
-
type: "number",
|
|
6232
|
+
type: format$1 ? "text" : "number",
|
|
6135
6233
|
"data-slot": "input",
|
|
6136
6234
|
className: cn(
|
|
6137
6235
|
inputVariants({ variant }),
|
|
@@ -6142,11 +6240,15 @@ const NumberInput = React$10.forwardRef(({ className, wrapperClassName, prefix,
|
|
|
6142
6240
|
"text-right",
|
|
6143
6241
|
!prefix && "pl-2",
|
|
6144
6242
|
!suffix && (showSpinButtons ? "pr-1" : "pr-2"),
|
|
6145
|
-
!showSpinButtons && "appearance-none",
|
|
6243
|
+
!showSpinButtons && !format$1 && "appearance-none",
|
|
6146
6244
|
className
|
|
6147
6245
|
),
|
|
6148
6246
|
"data-test-id": __e2e_test_id__,
|
|
6149
6247
|
ref,
|
|
6248
|
+
value: displayValue,
|
|
6249
|
+
onChange: handleChange,
|
|
6250
|
+
onFocus: handleFocus,
|
|
6251
|
+
onBlur: handleBlur,
|
|
6150
6252
|
onKeyDown: (e) => {
|
|
6151
6253
|
props.onKeyDown?.(e);
|
|
6152
6254
|
if (e.key === "Enter") onEnter?.();
|