@bizapps/ui 1.4.0 → 1.4.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/main.cjs +193 -98
- package/dist/main.cjs.map +1 -1
- package/dist/main.css +1 -1
- package/dist/main.d.cts +31 -24
- package/dist/main.d.ts +31 -24
- package/dist/main.js +193 -98
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1683,31 +1683,37 @@ function SelectContent({
|
|
|
1683
1683
|
className,
|
|
1684
1684
|
children,
|
|
1685
1685
|
position = "popper",
|
|
1686
|
+
maxHeight,
|
|
1687
|
+
style,
|
|
1686
1688
|
...props
|
|
1687
1689
|
}) {
|
|
1690
|
+
const resolvedMaxHeight = typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight;
|
|
1688
1691
|
return /* @__PURE__ */ jsx(Select$1.Portal, { children: /* @__PURE__ */ jsxs(
|
|
1689
1692
|
Select$1.Content,
|
|
1690
1693
|
{
|
|
1691
1694
|
"data-slot": "select-content",
|
|
1692
1695
|
className: cn(
|
|
1693
|
-
"border-border bg-popover text-popover-foreground relative z-50 max-h-
|
|
1696
|
+
"border-border bg-popover text-popover-foreground relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-hidden rounded-md border shadow-md",
|
|
1694
1697
|
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
1695
1698
|
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
|
1696
1699
|
"data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",
|
|
1697
|
-
position === "popper" && "w-
|
|
1700
|
+
position === "popper" && "w-(--radix-select-trigger-width)",
|
|
1698
1701
|
className
|
|
1699
1702
|
),
|
|
1700
1703
|
position,
|
|
1704
|
+
style: {
|
|
1705
|
+
...resolvedMaxHeight ? {
|
|
1706
|
+
maxHeight: `min(${resolvedMaxHeight}, var(--radix-select-content-available-height))`
|
|
1707
|
+
} : null,
|
|
1708
|
+
...style
|
|
1709
|
+
},
|
|
1701
1710
|
...props,
|
|
1702
1711
|
children: [
|
|
1703
1712
|
/* @__PURE__ */ jsx(SelectScrollUpButton, {}),
|
|
1704
1713
|
/* @__PURE__ */ jsx(
|
|
1705
1714
|
Select$1.Viewport,
|
|
1706
1715
|
{
|
|
1707
|
-
className: cn(
|
|
1708
|
-
"p-1",
|
|
1709
|
-
position === "popper" && "h-[--radix-select-trigger-height]"
|
|
1710
|
-
),
|
|
1716
|
+
className: cn("scroll-my-1 p-1", position === "popper" && "w-full"),
|
|
1711
1717
|
children
|
|
1712
1718
|
}
|
|
1713
1719
|
),
|
|
@@ -4369,6 +4375,7 @@ ColorPickerPresets.displayName = "ColorPickerPresets";
|
|
|
4369
4375
|
function Calendar({
|
|
4370
4376
|
className,
|
|
4371
4377
|
classNames,
|
|
4378
|
+
modifiersClassNames,
|
|
4372
4379
|
showOutsideDays = true,
|
|
4373
4380
|
captionLayout = "dropdown",
|
|
4374
4381
|
buttonVariant = "ghost",
|
|
@@ -4380,6 +4387,36 @@ function Calendar({
|
|
|
4380
4387
|
...props
|
|
4381
4388
|
}) {
|
|
4382
4389
|
const defaultClassNames = getDefaultClassNames();
|
|
4390
|
+
const resolvedComponents = useMemo(
|
|
4391
|
+
() => ({
|
|
4392
|
+
Root: ({ className: className2, rootRef, ...rootProps }) => {
|
|
4393
|
+
return /* @__PURE__ */ jsx(
|
|
4394
|
+
"div",
|
|
4395
|
+
{
|
|
4396
|
+
"data-slot": "calendar",
|
|
4397
|
+
ref: rootRef,
|
|
4398
|
+
className: cn(className2),
|
|
4399
|
+
...rootProps
|
|
4400
|
+
}
|
|
4401
|
+
);
|
|
4402
|
+
},
|
|
4403
|
+
Chevron: ({ className: className2, orientation, ...chevronProps }) => {
|
|
4404
|
+
if (orientation === "left") {
|
|
4405
|
+
return /* @__PURE__ */ jsx(ChevronLeftIcon, { className: cn("size-4", className2), ...chevronProps });
|
|
4406
|
+
}
|
|
4407
|
+
if (orientation === "right") {
|
|
4408
|
+
return /* @__PURE__ */ jsx(ChevronRightIcon, { className: cn("size-4", className2), ...chevronProps });
|
|
4409
|
+
}
|
|
4410
|
+
return /* @__PURE__ */ jsx(ChevronDownIcon, { className: cn("size-4", className2), ...chevronProps });
|
|
4411
|
+
},
|
|
4412
|
+
DayButton: (dayButtonProps) => /* @__PURE__ */ jsx(CalendarDayButton, { locale, ...dayButtonProps }),
|
|
4413
|
+
WeekNumber: ({ children, ...weekNumberProps }) => {
|
|
4414
|
+
return /* @__PURE__ */ jsx("td", { ...weekNumberProps, children: /* @__PURE__ */ jsx("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children }) });
|
|
4415
|
+
},
|
|
4416
|
+
...components
|
|
4417
|
+
}),
|
|
4418
|
+
[locale, components]
|
|
4419
|
+
);
|
|
4383
4420
|
return /* @__PURE__ */ jsx(
|
|
4384
4421
|
DayPicker,
|
|
4385
4422
|
{
|
|
@@ -4471,33 +4508,13 @@ function Calendar({
|
|
|
4471
4508
|
hidden: cn("invisible", defaultClassNames.hidden),
|
|
4472
4509
|
...classNames
|
|
4473
4510
|
},
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
"data-slot": "calendar",
|
|
4480
|
-
ref: rootRef,
|
|
4481
|
-
className: cn(className2),
|
|
4482
|
-
...props2
|
|
4483
|
-
}
|
|
4484
|
-
);
|
|
4485
|
-
},
|
|
4486
|
-
Chevron: ({ className: className2, orientation, ...props2 }) => {
|
|
4487
|
-
if (orientation === "left") {
|
|
4488
|
-
return /* @__PURE__ */ jsx(ChevronLeftIcon, { className: cn("size-4", className2), ...props2 });
|
|
4489
|
-
}
|
|
4490
|
-
if (orientation === "right") {
|
|
4491
|
-
return /* @__PURE__ */ jsx(ChevronRightIcon, { className: cn("size-4", className2), ...props2 });
|
|
4492
|
-
}
|
|
4493
|
-
return /* @__PURE__ */ jsx(ChevronDownIcon, { className: cn("size-4", className2), ...props2 });
|
|
4494
|
-
},
|
|
4495
|
-
DayButton: ({ ...props2 }) => /* @__PURE__ */ jsx(CalendarDayButton, { locale, ...props2 }),
|
|
4496
|
-
WeekNumber: ({ children, ...props2 }) => {
|
|
4497
|
-
return /* @__PURE__ */ jsx("td", { ...props2, children: /* @__PURE__ */ jsx("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children }) });
|
|
4498
|
-
},
|
|
4499
|
-
...components
|
|
4511
|
+
modifiersClassNames: {
|
|
4512
|
+
preview_start: "relative isolate z-0 rounded-l-md bg-primary/8 after:absolute after:inset-y-0 after:right-0 after:w-3 after:bg-primary/8",
|
|
4513
|
+
preview_middle: "rounded-none bg-primary/8",
|
|
4514
|
+
preview_end: "relative isolate z-0 rounded-r-md bg-primary/8 after:absolute after:inset-y-0 after:left-0 after:w-3 after:bg-primary/8",
|
|
4515
|
+
...modifiersClassNames
|
|
4500
4516
|
},
|
|
4517
|
+
components: resolvedComponents,
|
|
4501
4518
|
...props
|
|
4502
4519
|
}
|
|
4503
4520
|
);
|
|
@@ -4514,6 +4531,9 @@ function CalendarDayButton({
|
|
|
4514
4531
|
useEffect(() => {
|
|
4515
4532
|
if (modifiers.focused) ref.current?.focus();
|
|
4516
4533
|
}, [modifiers.focused]);
|
|
4534
|
+
const isPreviewEdge = Boolean(
|
|
4535
|
+
(modifiers.preview_start || modifiers.preview_end) && !modifiers.selected
|
|
4536
|
+
);
|
|
4517
4537
|
return /* @__PURE__ */ jsx(
|
|
4518
4538
|
Button,
|
|
4519
4539
|
{
|
|
@@ -4525,8 +4545,10 @@ function CalendarDayButton({
|
|
|
4525
4545
|
"data-range-start": modifiers.range_start,
|
|
4526
4546
|
"data-range-end": modifiers.range_end,
|
|
4527
4547
|
"data-range-middle": modifiers.range_middle,
|
|
4548
|
+
"data-preview-middle": Boolean(modifiers.preview_middle),
|
|
4549
|
+
"data-preview-edge": isPreviewEdge,
|
|
4528
4550
|
className: cn(
|
|
4529
|
-
"group-data-[focused=true]/day:ring-primary/40 data-[range-end=true]:!bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:!bg-primary/8 data-[range-middle=true]:text-foreground data-[range-start=true]:!bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:!bg-primary data-[selected-single=true]:text-primary-foreground relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 !rounded-md border-0 !bg-transparent leading-none font-normal transition-colors duration-150 group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:rounded-md group-data-[focused=true]/day:ring-[2px] hover:!bg-transparent data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md data-[selected-single=true]:rounded-md [&>span]:text-xs [&>span]:font-medium [&>span]:opacity-75",
|
|
4551
|
+
"group-data-[focused=true]/day:ring-primary/40 data-[preview-edge=true]:ring-primary/50 data-[preview-edge=true]:text-primary data-[preview-middle=true]:text-primary data-[range-end=true]:!bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:!bg-primary/8 data-[range-middle=true]:text-foreground data-[range-start=true]:!bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:!bg-primary data-[selected-single=true]:text-primary-foreground relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 !rounded-md border-0 !bg-transparent leading-none font-normal transition-colors duration-150 group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:rounded-md group-data-[focused=true]/day:ring-[2px] hover:!bg-transparent data-[preview-edge=true]:rounded-md data-[preview-edge=true]:font-medium data-[preview-edge=true]:ring-[2px] data-[preview-middle=true]:font-medium data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md data-[selected-single=true]:rounded-md [&>span]:text-xs [&>span]:font-medium [&>span]:opacity-75",
|
|
4530
4552
|
defaultClassNames.day,
|
|
4531
4553
|
className
|
|
4532
4554
|
),
|
|
@@ -4534,30 +4556,79 @@ function CalendarDayButton({
|
|
|
4534
4556
|
}
|
|
4535
4557
|
);
|
|
4536
4558
|
}
|
|
4537
|
-
function DatePicker({
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
}) {
|
|
4559
|
+
function DatePicker(props) {
|
|
4560
|
+
const {
|
|
4561
|
+
placeholder = "Pick a date",
|
|
4562
|
+
disabled = false,
|
|
4563
|
+
className,
|
|
4564
|
+
fromDate,
|
|
4565
|
+
toDate,
|
|
4566
|
+
numberOfMonths = 1
|
|
4567
|
+
} = props;
|
|
4547
4568
|
const [open, setOpen] = useState(false);
|
|
4569
|
+
const [awaitingRangeEnd, setAwaitingRangeEnd] = useState(false);
|
|
4570
|
+
const [previewDate, setPreviewDate] = useState(void 0);
|
|
4548
4571
|
const label = useMemo(() => {
|
|
4549
|
-
if (mode === "range") {
|
|
4550
|
-
const range = selected;
|
|
4551
|
-
if (range?.from
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4572
|
+
if (props.mode === "range") {
|
|
4573
|
+
const range = props.selected;
|
|
4574
|
+
if (!range?.from) return placeholder;
|
|
4575
|
+
if (!range.to) return `${format(range.from, "MMM d, yyyy")} \u2013 \u2026`;
|
|
4576
|
+
return `${format(range.from, "MMM d, yyyy")} \u2013 ${format(range.to, "MMM d, yyyy")}`;
|
|
4577
|
+
}
|
|
4578
|
+
return props.selected ? format(props.selected, "MMM d, yyyy") : placeholder;
|
|
4579
|
+
}, [props.mode, props.selected, placeholder]);
|
|
4580
|
+
const handleOpenChange = (nextOpen) => {
|
|
4581
|
+
setOpen(nextOpen);
|
|
4582
|
+
if (!nextOpen) {
|
|
4583
|
+
setAwaitingRangeEnd(false);
|
|
4584
|
+
setPreviewDate(void 0);
|
|
4585
|
+
}
|
|
4586
|
+
};
|
|
4587
|
+
const handleRangeSelect = (range, triggerDate) => {
|
|
4588
|
+
if (props.mode !== "range") return;
|
|
4589
|
+
const emit = props.onSelect;
|
|
4590
|
+
if (!awaitingRangeEnd) {
|
|
4591
|
+
setAwaitingRangeEnd(true);
|
|
4592
|
+
emit?.({ from: triggerDate, to: void 0 });
|
|
4593
|
+
return;
|
|
4594
|
+
}
|
|
4595
|
+
emit?.(range);
|
|
4596
|
+
if (!range?.from || !range.to) {
|
|
4597
|
+
setAwaitingRangeEnd(!!range?.from);
|
|
4598
|
+
return;
|
|
4599
|
+
}
|
|
4600
|
+
setAwaitingRangeEnd(false);
|
|
4601
|
+
setPreviewDate(void 0);
|
|
4602
|
+
setOpen(false);
|
|
4603
|
+
};
|
|
4604
|
+
const rangeFrom = props.mode === "range" ? props.selected?.from : void 0;
|
|
4605
|
+
const previewModifiers = useMemo(() => {
|
|
4606
|
+
if (!awaitingRangeEnd || !rangeFrom || !previewDate) return void 0;
|
|
4607
|
+
if (isSameDay(rangeFrom, previewDate)) return void 0;
|
|
4608
|
+
const [start, end] = previewDate < rangeFrom ? [previewDate, rangeFrom] : [rangeFrom, previewDate];
|
|
4609
|
+
return {
|
|
4610
|
+
preview_start: start,
|
|
4611
|
+
preview_middle: { after: start, before: end },
|
|
4612
|
+
preview_end: end
|
|
4613
|
+
};
|
|
4614
|
+
}, [awaitingRangeEnd, rangeFrom, previewDate]);
|
|
4615
|
+
const handleDayPreview = (day, dayModifiers) => {
|
|
4616
|
+
if (!awaitingRangeEnd) return;
|
|
4617
|
+
if (dayModifiers.disabled || dayModifiers.hidden) return;
|
|
4618
|
+
setPreviewDate((current) => current && isSameDay(current, day) ? current : day);
|
|
4619
|
+
};
|
|
4620
|
+
const dateConstraints = useMemo(() => {
|
|
4621
|
+
const disabledMatchers = [];
|
|
4622
|
+
if (fromDate) disabledMatchers.push({ before: fromDate });
|
|
4623
|
+
if (toDate) disabledMatchers.push({ after: toDate });
|
|
4624
|
+
return {
|
|
4625
|
+
...disabledMatchers.length > 0 && { disabled: disabledMatchers },
|
|
4626
|
+
...fromDate && { startMonth: fromDate },
|
|
4627
|
+
...toDate && { endMonth: toDate }
|
|
4628
|
+
};
|
|
4629
|
+
}, [fromDate, toDate]);
|
|
4630
|
+
const hasValue = props.mode === "range" ? !!props.selected?.from : !!props.selected;
|
|
4631
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: handleOpenChange, children: [
|
|
4561
4632
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
4562
4633
|
Button,
|
|
4563
4634
|
{
|
|
@@ -4575,36 +4646,36 @@ function DatePicker({
|
|
|
4575
4646
|
]
|
|
4576
4647
|
}
|
|
4577
4648
|
) }),
|
|
4578
|
-
/* @__PURE__ */ jsx(PopoverContent, { "data-slot": "date-picker-content", className: "w-auto p-0", align: "start", children: mode === "range" ?
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4649
|
+
/* @__PURE__ */ jsx(PopoverContent, { "data-slot": "date-picker-content", className: "w-auto p-0", align: "start", children: props.mode === "range" ? (
|
|
4650
|
+
// Clearing the preview on the wrapper instead of per day
|
|
4651
|
+
// avoids the blank frame `onDayMouseLeave` would cause when
|
|
4652
|
+
// the pointer travels from one day to the next.
|
|
4653
|
+
/* @__PURE__ */ jsx("div", { onMouseLeave: () => setPreviewDate(void 0), children: /* @__PURE__ */ jsx(
|
|
4654
|
+
Calendar,
|
|
4655
|
+
{
|
|
4582
4656
|
mode: "range",
|
|
4583
|
-
selected,
|
|
4584
|
-
onSelect:
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
initialFocus: true
|
|
4657
|
+
selected: props.selected,
|
|
4658
|
+
onSelect: handleRangeSelect,
|
|
4659
|
+
modifiers: previewModifiers,
|
|
4660
|
+
onDayMouseEnter: handleDayPreview,
|
|
4661
|
+
onDayFocus: handleDayPreview,
|
|
4662
|
+
numberOfMonths,
|
|
4663
|
+
autoFocus: true,
|
|
4664
|
+
...dateConstraints
|
|
4592
4665
|
}
|
|
4593
|
-
}
|
|
4666
|
+
) })
|
|
4594
4667
|
) : /* @__PURE__ */ jsx(
|
|
4595
4668
|
Calendar,
|
|
4596
4669
|
{
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
onSelect
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
initialFocus: true
|
|
4607
|
-
}
|
|
4670
|
+
mode: "single",
|
|
4671
|
+
selected: props.selected,
|
|
4672
|
+
onSelect: (date) => {
|
|
4673
|
+
props.onSelect?.(date);
|
|
4674
|
+
setOpen(false);
|
|
4675
|
+
},
|
|
4676
|
+
numberOfMonths,
|
|
4677
|
+
autoFocus: true,
|
|
4678
|
+
...dateConstraints
|
|
4608
4679
|
}
|
|
4609
4680
|
) })
|
|
4610
4681
|
] });
|
|
@@ -6918,7 +6989,7 @@ function TableHead({ className, ...props }) {
|
|
|
6918
6989
|
{
|
|
6919
6990
|
"data-slot": "table-head",
|
|
6920
6991
|
className: cn(
|
|
6921
|
-
"text-foreground has
|
|
6992
|
+
"text-foreground has-[[role=checkbox]]:pr-0 h-12 px-3 text-left align-middle font-medium whitespace-nowrap",
|
|
6922
6993
|
className
|
|
6923
6994
|
),
|
|
6924
6995
|
...props
|
|
@@ -6931,7 +7002,7 @@ function TableCell({ className, ...props }) {
|
|
|
6931
7002
|
{
|
|
6932
7003
|
"data-slot": "table-cell",
|
|
6933
7004
|
className: cn(
|
|
6934
|
-
"has
|
|
7005
|
+
"has-[[role=checkbox]]:pr-0 p-3 align-middle whitespace-nowrap",
|
|
6935
7006
|
className
|
|
6936
7007
|
),
|
|
6937
7008
|
...props
|
|
@@ -7192,6 +7263,13 @@ function useTableContext() {
|
|
|
7192
7263
|
function useTableContextSafe() {
|
|
7193
7264
|
return useContext(TableContext);
|
|
7194
7265
|
}
|
|
7266
|
+
|
|
7267
|
+
// src/components/compounds/Table/cell-size-class.ts
|
|
7268
|
+
var cellSizeClass = {
|
|
7269
|
+
sm: "px-3 py-1.5 text-xs",
|
|
7270
|
+
md: "px-5 py-2.5 text-sm",
|
|
7271
|
+
lg: "px-6 py-3 text-sm"
|
|
7272
|
+
};
|
|
7195
7273
|
var cardPadding = {
|
|
7196
7274
|
sm: "p-3",
|
|
7197
7275
|
md: "p-4",
|
|
@@ -7529,6 +7607,9 @@ function DataTableHeaderCell({ header }) {
|
|
|
7529
7607
|
},
|
|
7530
7608
|
className: cn(
|
|
7531
7609
|
"bg-primary text-primary-foreground",
|
|
7610
|
+
// Same density padding as the body cells: without it the header
|
|
7611
|
+
// label and the cell value below it sit at different offsets.
|
|
7612
|
+
cellSizeClass[meta.size ?? tableSize],
|
|
7532
7613
|
canResize && "relative",
|
|
7533
7614
|
meta.align === "center" && "text-center",
|
|
7534
7615
|
meta.align === "right" && "text-right",
|
|
@@ -7918,11 +7999,6 @@ function useTablePersistence({
|
|
|
7918
7999
|
persistDensity
|
|
7919
8000
|
};
|
|
7920
8001
|
}
|
|
7921
|
-
var cellSizeClass = {
|
|
7922
|
-
sm: "px-1 py-0 text-xs",
|
|
7923
|
-
md: "px-5 py-2.5 text-sm",
|
|
7924
|
-
lg: "px-6 py-3 text-sm"
|
|
7925
|
-
};
|
|
7926
8002
|
function resolveClassName(value, row) {
|
|
7927
8003
|
return typeof value === "function" ? value(row) : value;
|
|
7928
8004
|
}
|
|
@@ -7963,6 +8039,13 @@ function DataTableCell({
|
|
|
7963
8039
|
}
|
|
7964
8040
|
);
|
|
7965
8041
|
}
|
|
8042
|
+
var INTERACTIVE_CELL_CONTENT = 'button, a, input, select, textarea, [role="button"], [role="checkbox"], [role="menuitem"], [role="link"]';
|
|
8043
|
+
function isInteractiveCellEvent(event) {
|
|
8044
|
+
const target = event.target;
|
|
8045
|
+
if (!(target instanceof Element)) return false;
|
|
8046
|
+
const match = target.closest(INTERACTIVE_CELL_CONTENT);
|
|
8047
|
+
return match !== null && match !== event.currentTarget;
|
|
8048
|
+
}
|
|
7966
8049
|
function DataTableRow({ row, classNames }) {
|
|
7967
8050
|
const { onRowClick, variant } = useTableContext();
|
|
7968
8051
|
const clickable = Boolean(onRowClick);
|
|
@@ -7975,12 +8058,15 @@ function DataTableRow({ row, classNames }) {
|
|
|
7975
8058
|
"data-clickable": clickable || void 0,
|
|
7976
8059
|
role: clickable ? "button" : void 0,
|
|
7977
8060
|
tabIndex: clickable ? 0 : void 0,
|
|
7978
|
-
onClick: clickable ? () =>
|
|
8061
|
+
onClick: clickable ? (e) => {
|
|
8062
|
+
if (isInteractiveCellEvent(e)) return;
|
|
8063
|
+
onRowClick?.(row.original);
|
|
8064
|
+
} : void 0,
|
|
7979
8065
|
onKeyDown: clickable ? (e) => {
|
|
7980
|
-
if (e.key
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
8066
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
8067
|
+
if (isInteractiveCellEvent(e)) return;
|
|
8068
|
+
e.preventDefault();
|
|
8069
|
+
onRowClick?.(row.original);
|
|
7984
8070
|
} : void 0,
|
|
7985
8071
|
className: cn("hover:bg-muted", clickable && "cursor-pointer", rowClassName),
|
|
7986
8072
|
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(DataTableCell, { cell, cellClassName }, cell.id))
|
|
@@ -8581,7 +8667,7 @@ function DataTableFooter({ pagination, selectedCount, className }) {
|
|
|
8581
8667
|
className: cn("flex items-center justify-between border-t px-4 py-2", className),
|
|
8582
8668
|
children: [
|
|
8583
8669
|
selectedCount != null && selectedCount > 0 && /* @__PURE__ */ jsx("span", { "aria-live": "polite", className: "text-muted-foreground text-xs", children: `${selectedCount} row${selectedCount > 1 ? "s" : ""} selected` }),
|
|
8584
|
-
/* @__PURE__ */ jsx(TablePagination, { ...pagination })
|
|
8670
|
+
/* @__PURE__ */ jsx("div", { className: "ml-auto", children: /* @__PURE__ */ jsx(TablePagination, { ...pagination }) })
|
|
8585
8671
|
]
|
|
8586
8672
|
}
|
|
8587
8673
|
);
|
|
@@ -8690,18 +8776,21 @@ function DataTableSearch({
|
|
|
8690
8776
|
debounce = 300
|
|
8691
8777
|
}) {
|
|
8692
8778
|
const ctx = useTableContextSafe();
|
|
8693
|
-
const [inputValue, setInputValue] = useState("");
|
|
8694
8779
|
const globalFilter = ctx?.globalFilter;
|
|
8695
8780
|
const setGlobalFilter = ctx?.setGlobalFilter;
|
|
8781
|
+
const committedValue = globalFilter ?? "";
|
|
8782
|
+
const [inputValue, setInputValue] = useState(committedValue);
|
|
8696
8783
|
useEffect(() => {
|
|
8697
|
-
if (globalFilter ===
|
|
8784
|
+
if (globalFilter === void 0) return;
|
|
8785
|
+
setInputValue(globalFilter);
|
|
8698
8786
|
}, [globalFilter]);
|
|
8699
8787
|
useEffect(() => {
|
|
8788
|
+
if (inputValue === committedValue) return;
|
|
8700
8789
|
const timer = setTimeout(() => {
|
|
8701
8790
|
setGlobalFilter?.(inputValue);
|
|
8702
8791
|
}, debounce);
|
|
8703
8792
|
return () => clearTimeout(timer);
|
|
8704
|
-
}, [inputValue, debounce, setGlobalFilter]);
|
|
8793
|
+
}, [inputValue, committedValue, debounce, setGlobalFilter]);
|
|
8705
8794
|
const handleClear = () => {
|
|
8706
8795
|
setInputValue("");
|
|
8707
8796
|
setGlobalFilter?.("");
|
|
@@ -8722,7 +8811,13 @@ function DataTableSearch({
|
|
|
8722
8811
|
onChange: (e) => setInputValue(e.target.value),
|
|
8723
8812
|
placeholder,
|
|
8724
8813
|
"aria-label": placeholder,
|
|
8725
|
-
className:
|
|
8814
|
+
className: cn(
|
|
8815
|
+
"h-8 w-48 pr-9 pl-9 text-sm",
|
|
8816
|
+
"[&::-webkit-search-cancel-button]:appearance-none",
|
|
8817
|
+
"[&::-webkit-search-decoration]:appearance-none",
|
|
8818
|
+
"[&::-webkit-search-results-button]:appearance-none",
|
|
8819
|
+
"[&::-webkit-search-results-decoration]:appearance-none"
|
|
8820
|
+
)
|
|
8726
8821
|
}
|
|
8727
8822
|
),
|
|
8728
8823
|
inputValue && /* @__PURE__ */ jsx(
|
|
@@ -8732,7 +8827,7 @@ function DataTableSearch({
|
|
|
8732
8827
|
size: "icon-sm",
|
|
8733
8828
|
onClick: handleClear,
|
|
8734
8829
|
"aria-label": "Clear search",
|
|
8735
|
-
className: "text-muted-foreground hover:text-foreground absolute right-
|
|
8830
|
+
className: "text-muted-foreground hover:text-foreground absolute top-1/2 right-1.5 size-6 -translate-y-1/2",
|
|
8736
8831
|
children: /* @__PURE__ */ jsx(X, { className: "size-3.5", "aria-hidden": "true" })
|
|
8737
8832
|
}
|
|
8738
8833
|
)
|