@bizapps/ui 1.4.1 → 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 +158 -89
- package/dist/main.cjs.map +1 -1
- package/dist/main.css +1 -1
- package/dist/main.d.cts +27 -32
- package/dist/main.d.ts +27 -32
- package/dist/main.js +158 -89
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -1688,31 +1688,37 @@ function SelectContent({
|
|
|
1688
1688
|
className,
|
|
1689
1689
|
children,
|
|
1690
1690
|
position = "popper",
|
|
1691
|
+
maxHeight,
|
|
1692
|
+
style,
|
|
1691
1693
|
...props
|
|
1692
1694
|
}) {
|
|
1695
|
+
const resolvedMaxHeight = typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight;
|
|
1693
1696
|
return /* @__PURE__ */ jsxRuntime.jsx(radixUi.Select.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1694
1697
|
radixUi.Select.Content,
|
|
1695
1698
|
{
|
|
1696
1699
|
"data-slot": "select-content",
|
|
1697
1700
|
className: cn(
|
|
1698
|
-
"border-border bg-popover text-popover-foreground relative z-50 max-h-
|
|
1701
|
+
"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",
|
|
1699
1702
|
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
1700
1703
|
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
|
1701
1704
|
"data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",
|
|
1702
|
-
position === "popper" && "w-
|
|
1705
|
+
position === "popper" && "w-(--radix-select-trigger-width)",
|
|
1703
1706
|
className
|
|
1704
1707
|
),
|
|
1705
1708
|
position,
|
|
1709
|
+
style: {
|
|
1710
|
+
...resolvedMaxHeight ? {
|
|
1711
|
+
maxHeight: `min(${resolvedMaxHeight}, var(--radix-select-content-available-height))`
|
|
1712
|
+
} : null,
|
|
1713
|
+
...style
|
|
1714
|
+
},
|
|
1706
1715
|
...props,
|
|
1707
1716
|
children: [
|
|
1708
1717
|
/* @__PURE__ */ jsxRuntime.jsx(SelectScrollUpButton, {}),
|
|
1709
1718
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1710
1719
|
radixUi.Select.Viewport,
|
|
1711
1720
|
{
|
|
1712
|
-
className: cn(
|
|
1713
|
-
"p-1",
|
|
1714
|
-
position === "popper" && "h-[--radix-select-trigger-height]"
|
|
1715
|
-
),
|
|
1721
|
+
className: cn("scroll-my-1 p-1", position === "popper" && "w-full"),
|
|
1716
1722
|
children
|
|
1717
1723
|
}
|
|
1718
1724
|
),
|
|
@@ -4374,6 +4380,7 @@ ColorPickerPresets.displayName = "ColorPickerPresets";
|
|
|
4374
4380
|
function Calendar({
|
|
4375
4381
|
className,
|
|
4376
4382
|
classNames,
|
|
4383
|
+
modifiersClassNames,
|
|
4377
4384
|
showOutsideDays = true,
|
|
4378
4385
|
captionLayout = "dropdown",
|
|
4379
4386
|
buttonVariant = "ghost",
|
|
@@ -4385,6 +4392,36 @@ function Calendar({
|
|
|
4385
4392
|
...props
|
|
4386
4393
|
}) {
|
|
4387
4394
|
const defaultClassNames = reactDayPicker.getDefaultClassNames();
|
|
4395
|
+
const resolvedComponents = react.useMemo(
|
|
4396
|
+
() => ({
|
|
4397
|
+
Root: ({ className: className2, rootRef, ...rootProps }) => {
|
|
4398
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4399
|
+
"div",
|
|
4400
|
+
{
|
|
4401
|
+
"data-slot": "calendar",
|
|
4402
|
+
ref: rootRef,
|
|
4403
|
+
className: cn(className2),
|
|
4404
|
+
...rootProps
|
|
4405
|
+
}
|
|
4406
|
+
);
|
|
4407
|
+
},
|
|
4408
|
+
Chevron: ({ className: className2, orientation, ...chevronProps }) => {
|
|
4409
|
+
if (orientation === "left") {
|
|
4410
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeftIcon, { className: cn("size-4", className2), ...chevronProps });
|
|
4411
|
+
}
|
|
4412
|
+
if (orientation === "right") {
|
|
4413
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRightIcon, { className: cn("size-4", className2), ...chevronProps });
|
|
4414
|
+
}
|
|
4415
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDownIcon, { className: cn("size-4", className2), ...chevronProps });
|
|
4416
|
+
},
|
|
4417
|
+
DayButton: (dayButtonProps) => /* @__PURE__ */ jsxRuntime.jsx(CalendarDayButton, { locale, ...dayButtonProps }),
|
|
4418
|
+
WeekNumber: ({ children, ...weekNumberProps }) => {
|
|
4419
|
+
return /* @__PURE__ */ jsxRuntime.jsx("td", { ...weekNumberProps, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children }) });
|
|
4420
|
+
},
|
|
4421
|
+
...components
|
|
4422
|
+
}),
|
|
4423
|
+
[locale, components]
|
|
4424
|
+
);
|
|
4388
4425
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4389
4426
|
reactDayPicker.DayPicker,
|
|
4390
4427
|
{
|
|
@@ -4476,33 +4513,13 @@ function Calendar({
|
|
|
4476
4513
|
hidden: cn("invisible", defaultClassNames.hidden),
|
|
4477
4514
|
...classNames
|
|
4478
4515
|
},
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
"data-slot": "calendar",
|
|
4485
|
-
ref: rootRef,
|
|
4486
|
-
className: cn(className2),
|
|
4487
|
-
...props2
|
|
4488
|
-
}
|
|
4489
|
-
);
|
|
4490
|
-
},
|
|
4491
|
-
Chevron: ({ className: className2, orientation, ...props2 }) => {
|
|
4492
|
-
if (orientation === "left") {
|
|
4493
|
-
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeftIcon, { className: cn("size-4", className2), ...props2 });
|
|
4494
|
-
}
|
|
4495
|
-
if (orientation === "right") {
|
|
4496
|
-
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRightIcon, { className: cn("size-4", className2), ...props2 });
|
|
4497
|
-
}
|
|
4498
|
-
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDownIcon, { className: cn("size-4", className2), ...props2 });
|
|
4499
|
-
},
|
|
4500
|
-
DayButton: ({ ...props2 }) => /* @__PURE__ */ jsxRuntime.jsx(CalendarDayButton, { locale, ...props2 }),
|
|
4501
|
-
WeekNumber: ({ children, ...props2 }) => {
|
|
4502
|
-
return /* @__PURE__ */ jsxRuntime.jsx("td", { ...props2, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children }) });
|
|
4503
|
-
},
|
|
4504
|
-
...components
|
|
4516
|
+
modifiersClassNames: {
|
|
4517
|
+
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",
|
|
4518
|
+
preview_middle: "rounded-none bg-primary/8",
|
|
4519
|
+
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",
|
|
4520
|
+
...modifiersClassNames
|
|
4505
4521
|
},
|
|
4522
|
+
components: resolvedComponents,
|
|
4506
4523
|
...props
|
|
4507
4524
|
}
|
|
4508
4525
|
);
|
|
@@ -4519,6 +4536,9 @@ function CalendarDayButton({
|
|
|
4519
4536
|
react.useEffect(() => {
|
|
4520
4537
|
if (modifiers.focused) ref.current?.focus();
|
|
4521
4538
|
}, [modifiers.focused]);
|
|
4539
|
+
const isPreviewEdge = Boolean(
|
|
4540
|
+
(modifiers.preview_start || modifiers.preview_end) && !modifiers.selected
|
|
4541
|
+
);
|
|
4522
4542
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4523
4543
|
Button,
|
|
4524
4544
|
{
|
|
@@ -4530,8 +4550,10 @@ function CalendarDayButton({
|
|
|
4530
4550
|
"data-range-start": modifiers.range_start,
|
|
4531
4551
|
"data-range-end": modifiers.range_end,
|
|
4532
4552
|
"data-range-middle": modifiers.range_middle,
|
|
4553
|
+
"data-preview-middle": Boolean(modifiers.preview_middle),
|
|
4554
|
+
"data-preview-edge": isPreviewEdge,
|
|
4533
4555
|
className: cn(
|
|
4534
|
-
"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",
|
|
4556
|
+
"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",
|
|
4535
4557
|
defaultClassNames.day,
|
|
4536
4558
|
className
|
|
4537
4559
|
),
|
|
@@ -4539,35 +4561,37 @@ function CalendarDayButton({
|
|
|
4539
4561
|
}
|
|
4540
4562
|
);
|
|
4541
4563
|
}
|
|
4542
|
-
function DatePicker({
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
numberOfMonths = 1
|
|
4552
|
-
}) {
|
|
4564
|
+
function DatePicker(props) {
|
|
4565
|
+
const {
|
|
4566
|
+
placeholder = "Pick a date",
|
|
4567
|
+
disabled = false,
|
|
4568
|
+
className,
|
|
4569
|
+
fromDate,
|
|
4570
|
+
toDate,
|
|
4571
|
+
numberOfMonths = 1
|
|
4572
|
+
} = props;
|
|
4553
4573
|
const [open, setOpen] = react.useState(false);
|
|
4554
4574
|
const [awaitingRangeEnd, setAwaitingRangeEnd] = react.useState(false);
|
|
4575
|
+
const [previewDate, setPreviewDate] = react.useState(void 0);
|
|
4555
4576
|
const label = react.useMemo(() => {
|
|
4556
|
-
if (mode === "range") {
|
|
4557
|
-
const range = selected;
|
|
4577
|
+
if (props.mode === "range") {
|
|
4578
|
+
const range = props.selected;
|
|
4558
4579
|
if (!range?.from) return placeholder;
|
|
4559
4580
|
if (!range.to) return `${dateFns.format(range.from, "MMM d, yyyy")} \u2013 \u2026`;
|
|
4560
4581
|
return `${dateFns.format(range.from, "MMM d, yyyy")} \u2013 ${dateFns.format(range.to, "MMM d, yyyy")}`;
|
|
4561
4582
|
}
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
}, [mode, selected, placeholder]);
|
|
4583
|
+
return props.selected ? dateFns.format(props.selected, "MMM d, yyyy") : placeholder;
|
|
4584
|
+
}, [props.mode, props.selected, placeholder]);
|
|
4565
4585
|
const handleOpenChange = (nextOpen) => {
|
|
4566
4586
|
setOpen(nextOpen);
|
|
4567
|
-
if (!nextOpen)
|
|
4587
|
+
if (!nextOpen) {
|
|
4588
|
+
setAwaitingRangeEnd(false);
|
|
4589
|
+
setPreviewDate(void 0);
|
|
4590
|
+
}
|
|
4568
4591
|
};
|
|
4569
4592
|
const handleRangeSelect = (range, triggerDate) => {
|
|
4570
|
-
|
|
4593
|
+
if (props.mode !== "range") return;
|
|
4594
|
+
const emit = props.onSelect;
|
|
4571
4595
|
if (!awaitingRangeEnd) {
|
|
4572
4596
|
setAwaitingRangeEnd(true);
|
|
4573
4597
|
emit?.({ from: triggerDate, to: void 0 });
|
|
@@ -4579,8 +4603,25 @@ function DatePicker({
|
|
|
4579
4603
|
return;
|
|
4580
4604
|
}
|
|
4581
4605
|
setAwaitingRangeEnd(false);
|
|
4606
|
+
setPreviewDate(void 0);
|
|
4582
4607
|
setOpen(false);
|
|
4583
4608
|
};
|
|
4609
|
+
const rangeFrom = props.mode === "range" ? props.selected?.from : void 0;
|
|
4610
|
+
const previewModifiers = react.useMemo(() => {
|
|
4611
|
+
if (!awaitingRangeEnd || !rangeFrom || !previewDate) return void 0;
|
|
4612
|
+
if (dateFns.isSameDay(rangeFrom, previewDate)) return void 0;
|
|
4613
|
+
const [start, end] = previewDate < rangeFrom ? [previewDate, rangeFrom] : [rangeFrom, previewDate];
|
|
4614
|
+
return {
|
|
4615
|
+
preview_start: start,
|
|
4616
|
+
preview_middle: { after: start, before: end },
|
|
4617
|
+
preview_end: end
|
|
4618
|
+
};
|
|
4619
|
+
}, [awaitingRangeEnd, rangeFrom, previewDate]);
|
|
4620
|
+
const handleDayPreview = (day, dayModifiers) => {
|
|
4621
|
+
if (!awaitingRangeEnd) return;
|
|
4622
|
+
if (dayModifiers.disabled || dayModifiers.hidden) return;
|
|
4623
|
+
setPreviewDate((current) => current && dateFns.isSameDay(current, day) ? current : day);
|
|
4624
|
+
};
|
|
4584
4625
|
const dateConstraints = react.useMemo(() => {
|
|
4585
4626
|
const disabledMatchers = [];
|
|
4586
4627
|
if (fromDate) disabledMatchers.push({ before: fromDate });
|
|
@@ -4591,7 +4632,7 @@ function DatePicker({
|
|
|
4591
4632
|
...toDate && { endMonth: toDate }
|
|
4592
4633
|
};
|
|
4593
4634
|
}, [fromDate, toDate]);
|
|
4594
|
-
const hasValue = mode === "range" ? !!selected?.from : !!selected;
|
|
4635
|
+
const hasValue = props.mode === "range" ? !!props.selected?.from : !!props.selected;
|
|
4595
4636
|
return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: handleOpenChange, children: [
|
|
4596
4637
|
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4597
4638
|
Button,
|
|
@@ -4610,32 +4651,36 @@ function DatePicker({
|
|
|
4610
4651
|
]
|
|
4611
4652
|
}
|
|
4612
4653
|
) }),
|
|
4613
|
-
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { "data-slot": "date-picker-content", className: "w-auto p-0", align: "start", children: mode === "range" ?
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4654
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { "data-slot": "date-picker-content", className: "w-auto p-0", align: "start", children: props.mode === "range" ? (
|
|
4655
|
+
// Clearing the preview on the wrapper instead of per day
|
|
4656
|
+
// avoids the blank frame `onDayMouseLeave` would cause when
|
|
4657
|
+
// the pointer travels from one day to the next.
|
|
4658
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { onMouseLeave: () => setPreviewDate(void 0), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4659
|
+
Calendar,
|
|
4660
|
+
{
|
|
4617
4661
|
mode: "range",
|
|
4618
|
-
selected,
|
|
4662
|
+
selected: props.selected,
|
|
4619
4663
|
onSelect: handleRangeSelect,
|
|
4620
|
-
|
|
4664
|
+
modifiers: previewModifiers,
|
|
4665
|
+
onDayMouseEnter: handleDayPreview,
|
|
4666
|
+
onDayFocus: handleDayPreview,
|
|
4621
4667
|
numberOfMonths,
|
|
4622
|
-
autoFocus: true
|
|
4668
|
+
autoFocus: true,
|
|
4669
|
+
...dateConstraints
|
|
4623
4670
|
}
|
|
4624
|
-
}
|
|
4671
|
+
) })
|
|
4625
4672
|
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
4626
4673
|
Calendar,
|
|
4627
4674
|
{
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
onSelect
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
autoFocus: true
|
|
4638
|
-
}
|
|
4675
|
+
mode: "single",
|
|
4676
|
+
selected: props.selected,
|
|
4677
|
+
onSelect: (date) => {
|
|
4678
|
+
props.onSelect?.(date);
|
|
4679
|
+
setOpen(false);
|
|
4680
|
+
},
|
|
4681
|
+
numberOfMonths,
|
|
4682
|
+
autoFocus: true,
|
|
4683
|
+
...dateConstraints
|
|
4639
4684
|
}
|
|
4640
4685
|
) })
|
|
4641
4686
|
] });
|
|
@@ -6949,7 +6994,7 @@ function TableHead({ className, ...props }) {
|
|
|
6949
6994
|
{
|
|
6950
6995
|
"data-slot": "table-head",
|
|
6951
6996
|
className: cn(
|
|
6952
|
-
"text-foreground has
|
|
6997
|
+
"text-foreground has-[[role=checkbox]]:pr-0 h-12 px-3 text-left align-middle font-medium whitespace-nowrap",
|
|
6953
6998
|
className
|
|
6954
6999
|
),
|
|
6955
7000
|
...props
|
|
@@ -6962,7 +7007,7 @@ function TableCell({ className, ...props }) {
|
|
|
6962
7007
|
{
|
|
6963
7008
|
"data-slot": "table-cell",
|
|
6964
7009
|
className: cn(
|
|
6965
|
-
"has
|
|
7010
|
+
"has-[[role=checkbox]]:pr-0 p-3 align-middle whitespace-nowrap",
|
|
6966
7011
|
className
|
|
6967
7012
|
),
|
|
6968
7013
|
...props
|
|
@@ -7223,6 +7268,13 @@ function useTableContext() {
|
|
|
7223
7268
|
function useTableContextSafe() {
|
|
7224
7269
|
return react.useContext(TableContext);
|
|
7225
7270
|
}
|
|
7271
|
+
|
|
7272
|
+
// src/components/compounds/Table/cell-size-class.ts
|
|
7273
|
+
var cellSizeClass = {
|
|
7274
|
+
sm: "px-3 py-1.5 text-xs",
|
|
7275
|
+
md: "px-5 py-2.5 text-sm",
|
|
7276
|
+
lg: "px-6 py-3 text-sm"
|
|
7277
|
+
};
|
|
7226
7278
|
var cardPadding = {
|
|
7227
7279
|
sm: "p-3",
|
|
7228
7280
|
md: "p-4",
|
|
@@ -7560,6 +7612,9 @@ function DataTableHeaderCell({ header }) {
|
|
|
7560
7612
|
},
|
|
7561
7613
|
className: cn(
|
|
7562
7614
|
"bg-primary text-primary-foreground",
|
|
7615
|
+
// Same density padding as the body cells: without it the header
|
|
7616
|
+
// label and the cell value below it sit at different offsets.
|
|
7617
|
+
cellSizeClass[meta.size ?? tableSize],
|
|
7563
7618
|
canResize && "relative",
|
|
7564
7619
|
meta.align === "center" && "text-center",
|
|
7565
7620
|
meta.align === "right" && "text-right",
|
|
@@ -7949,11 +8004,6 @@ function useTablePersistence({
|
|
|
7949
8004
|
persistDensity
|
|
7950
8005
|
};
|
|
7951
8006
|
}
|
|
7952
|
-
var cellSizeClass = {
|
|
7953
|
-
sm: "px-1 py-0 text-xs",
|
|
7954
|
-
md: "px-5 py-2.5 text-sm",
|
|
7955
|
-
lg: "px-6 py-3 text-sm"
|
|
7956
|
-
};
|
|
7957
8007
|
function resolveClassName(value, row) {
|
|
7958
8008
|
return typeof value === "function" ? value(row) : value;
|
|
7959
8009
|
}
|
|
@@ -7994,6 +8044,13 @@ function DataTableCell({
|
|
|
7994
8044
|
}
|
|
7995
8045
|
);
|
|
7996
8046
|
}
|
|
8047
|
+
var INTERACTIVE_CELL_CONTENT = 'button, a, input, select, textarea, [role="button"], [role="checkbox"], [role="menuitem"], [role="link"]';
|
|
8048
|
+
function isInteractiveCellEvent(event) {
|
|
8049
|
+
const target = event.target;
|
|
8050
|
+
if (!(target instanceof Element)) return false;
|
|
8051
|
+
const match = target.closest(INTERACTIVE_CELL_CONTENT);
|
|
8052
|
+
return match !== null && match !== event.currentTarget;
|
|
8053
|
+
}
|
|
7997
8054
|
function DataTableRow({ row, classNames }) {
|
|
7998
8055
|
const { onRowClick, variant } = useTableContext();
|
|
7999
8056
|
const clickable = Boolean(onRowClick);
|
|
@@ -8006,12 +8063,15 @@ function DataTableRow({ row, classNames }) {
|
|
|
8006
8063
|
"data-clickable": clickable || void 0,
|
|
8007
8064
|
role: clickable ? "button" : void 0,
|
|
8008
8065
|
tabIndex: clickable ? 0 : void 0,
|
|
8009
|
-
onClick: clickable ? () =>
|
|
8066
|
+
onClick: clickable ? (e) => {
|
|
8067
|
+
if (isInteractiveCellEvent(e)) return;
|
|
8068
|
+
onRowClick?.(row.original);
|
|
8069
|
+
} : void 0,
|
|
8010
8070
|
onKeyDown: clickable ? (e) => {
|
|
8011
|
-
if (e.key
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8071
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
8072
|
+
if (isInteractiveCellEvent(e)) return;
|
|
8073
|
+
e.preventDefault();
|
|
8074
|
+
onRowClick?.(row.original);
|
|
8015
8075
|
} : void 0,
|
|
8016
8076
|
className: cn("hover:bg-muted", clickable && "cursor-pointer", rowClassName),
|
|
8017
8077
|
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsxRuntime.jsx(DataTableCell, { cell, cellClassName }, cell.id))
|
|
@@ -8612,7 +8672,7 @@ function DataTableFooter({ pagination, selectedCount, className }) {
|
|
|
8612
8672
|
className: cn("flex items-center justify-between border-t px-4 py-2", className),
|
|
8613
8673
|
children: [
|
|
8614
8674
|
selectedCount != null && selectedCount > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-live": "polite", className: "text-muted-foreground text-xs", children: `${selectedCount} row${selectedCount > 1 ? "s" : ""} selected` }),
|
|
8615
|
-
/* @__PURE__ */ jsxRuntime.jsx(TablePagination, { ...pagination })
|
|
8675
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto", children: /* @__PURE__ */ jsxRuntime.jsx(TablePagination, { ...pagination }) })
|
|
8616
8676
|
]
|
|
8617
8677
|
}
|
|
8618
8678
|
);
|
|
@@ -8721,18 +8781,21 @@ function DataTableSearch({
|
|
|
8721
8781
|
debounce = 300
|
|
8722
8782
|
}) {
|
|
8723
8783
|
const ctx = useTableContextSafe();
|
|
8724
|
-
const [inputValue, setInputValue] = react.useState("");
|
|
8725
8784
|
const globalFilter = ctx?.globalFilter;
|
|
8726
8785
|
const setGlobalFilter = ctx?.setGlobalFilter;
|
|
8786
|
+
const committedValue = globalFilter ?? "";
|
|
8787
|
+
const [inputValue, setInputValue] = react.useState(committedValue);
|
|
8727
8788
|
react.useEffect(() => {
|
|
8728
|
-
if (globalFilter ===
|
|
8789
|
+
if (globalFilter === void 0) return;
|
|
8790
|
+
setInputValue(globalFilter);
|
|
8729
8791
|
}, [globalFilter]);
|
|
8730
8792
|
react.useEffect(() => {
|
|
8793
|
+
if (inputValue === committedValue) return;
|
|
8731
8794
|
const timer = setTimeout(() => {
|
|
8732
8795
|
setGlobalFilter?.(inputValue);
|
|
8733
8796
|
}, debounce);
|
|
8734
8797
|
return () => clearTimeout(timer);
|
|
8735
|
-
}, [inputValue, debounce, setGlobalFilter]);
|
|
8798
|
+
}, [inputValue, committedValue, debounce, setGlobalFilter]);
|
|
8736
8799
|
const handleClear = () => {
|
|
8737
8800
|
setInputValue("");
|
|
8738
8801
|
setGlobalFilter?.("");
|
|
@@ -8753,7 +8816,13 @@ function DataTableSearch({
|
|
|
8753
8816
|
onChange: (e) => setInputValue(e.target.value),
|
|
8754
8817
|
placeholder,
|
|
8755
8818
|
"aria-label": placeholder,
|
|
8756
|
-
className:
|
|
8819
|
+
className: cn(
|
|
8820
|
+
"h-8 w-48 pr-9 pl-9 text-sm",
|
|
8821
|
+
"[&::-webkit-search-cancel-button]:appearance-none",
|
|
8822
|
+
"[&::-webkit-search-decoration]:appearance-none",
|
|
8823
|
+
"[&::-webkit-search-results-button]:appearance-none",
|
|
8824
|
+
"[&::-webkit-search-results-decoration]:appearance-none"
|
|
8825
|
+
)
|
|
8757
8826
|
}
|
|
8758
8827
|
),
|
|
8759
8828
|
inputValue && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -8763,7 +8832,7 @@ function DataTableSearch({
|
|
|
8763
8832
|
size: "icon-sm",
|
|
8764
8833
|
onClick: handleClear,
|
|
8765
8834
|
"aria-label": "Clear search",
|
|
8766
|
-
className: "text-muted-foreground hover:text-foreground absolute right-
|
|
8835
|
+
className: "text-muted-foreground hover:text-foreground absolute top-1/2 right-1.5 size-6 -translate-y-1/2",
|
|
8767
8836
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "size-3.5", "aria-hidden": "true" })
|
|
8768
8837
|
}
|
|
8769
8838
|
)
|