@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 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-[--radix-select-content-available-height] min-w-[8rem] overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
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-[--radix-select-trigger-width]",
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
- components: {
4480
- Root: ({ className: className2, rootRef, ...props2 }) => {
4481
- return /* @__PURE__ */ jsxRuntime.jsx(
4482
- "div",
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,30 +4561,79 @@ function CalendarDayButton({
4539
4561
  }
4540
4562
  );
4541
4563
  }
4542
- function DatePicker({
4543
- mode = "single",
4544
- selected,
4545
- onSelect,
4546
- placeholder = "Pick a date",
4547
- disabled = false,
4548
- className,
4549
- fromDate,
4550
- toDate
4551
- }) {
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;
4552
4573
  const [open, setOpen] = react.useState(false);
4574
+ const [awaitingRangeEnd, setAwaitingRangeEnd] = react.useState(false);
4575
+ const [previewDate, setPreviewDate] = react.useState(void 0);
4553
4576
  const label = react.useMemo(() => {
4554
- if (mode === "range") {
4555
- const range = selected;
4556
- if (range?.from && range?.to)
4557
- return `${dateFns.format(range.from, "MMM d, yyyy")} \u2013 ${dateFns.format(range.to, "MMM d, yyyy")}`;
4558
- if (range?.from) return `${dateFns.format(range.from, "MMM d, yyyy")} \u2013 \u2026`;
4559
- return placeholder;
4560
- }
4561
- const date = selected;
4562
- return date ? dateFns.format(date, "MMM d, yyyy") : placeholder;
4563
- }, [mode, selected, placeholder]);
4564
- const hasValue = mode === "range" ? !!selected?.from : !!selected;
4565
- return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: setOpen, children: [
4577
+ if (props.mode === "range") {
4578
+ const range = props.selected;
4579
+ if (!range?.from) return placeholder;
4580
+ if (!range.to) return `${dateFns.format(range.from, "MMM d, yyyy")} \u2013 \u2026`;
4581
+ return `${dateFns.format(range.from, "MMM d, yyyy")} \u2013 ${dateFns.format(range.to, "MMM d, yyyy")}`;
4582
+ }
4583
+ return props.selected ? dateFns.format(props.selected, "MMM d, yyyy") : placeholder;
4584
+ }, [props.mode, props.selected, placeholder]);
4585
+ const handleOpenChange = (nextOpen) => {
4586
+ setOpen(nextOpen);
4587
+ if (!nextOpen) {
4588
+ setAwaitingRangeEnd(false);
4589
+ setPreviewDate(void 0);
4590
+ }
4591
+ };
4592
+ const handleRangeSelect = (range, triggerDate) => {
4593
+ if (props.mode !== "range") return;
4594
+ const emit = props.onSelect;
4595
+ if (!awaitingRangeEnd) {
4596
+ setAwaitingRangeEnd(true);
4597
+ emit?.({ from: triggerDate, to: void 0 });
4598
+ return;
4599
+ }
4600
+ emit?.(range);
4601
+ if (!range?.from || !range.to) {
4602
+ setAwaitingRangeEnd(!!range?.from);
4603
+ return;
4604
+ }
4605
+ setAwaitingRangeEnd(false);
4606
+ setPreviewDate(void 0);
4607
+ setOpen(false);
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
+ };
4625
+ const dateConstraints = react.useMemo(() => {
4626
+ const disabledMatchers = [];
4627
+ if (fromDate) disabledMatchers.push({ before: fromDate });
4628
+ if (toDate) disabledMatchers.push({ after: toDate });
4629
+ return {
4630
+ ...disabledMatchers.length > 0 && { disabled: disabledMatchers },
4631
+ ...fromDate && { startMonth: fromDate },
4632
+ ...toDate && { endMonth: toDate }
4633
+ };
4634
+ }, [fromDate, toDate]);
4635
+ const hasValue = props.mode === "range" ? !!props.selected?.from : !!props.selected;
4636
+ return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: handleOpenChange, children: [
4566
4637
  /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
4567
4638
  Button,
4568
4639
  {
@@ -4580,36 +4651,36 @@ function DatePicker({
4580
4651
  ]
4581
4652
  }
4582
4653
  ) }),
4583
- /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { "data-slot": "date-picker-content", className: "w-auto p-0", align: "start", children: mode === "range" ? /* @__PURE__ */ jsxRuntime.jsx(
4584
- Calendar,
4585
- {
4586
- ...{
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
+ {
4587
4661
  mode: "range",
4588
- selected,
4589
- onSelect: (range) => {
4590
- onSelect?.(range);
4591
- if (range?.to) setOpen(false);
4592
- },
4593
- fromDate,
4594
- toDate,
4595
- numberOfMonths: 2,
4596
- initialFocus: true
4662
+ selected: props.selected,
4663
+ onSelect: handleRangeSelect,
4664
+ modifiers: previewModifiers,
4665
+ onDayMouseEnter: handleDayPreview,
4666
+ onDayFocus: handleDayPreview,
4667
+ numberOfMonths,
4668
+ autoFocus: true,
4669
+ ...dateConstraints
4597
4670
  }
4598
- }
4671
+ ) })
4599
4672
  ) : /* @__PURE__ */ jsxRuntime.jsx(
4600
4673
  Calendar,
4601
4674
  {
4602
- ...{
4603
- mode: "single",
4604
- selected,
4605
- onSelect: (date) => {
4606
- onSelect?.(date);
4607
- setOpen(false);
4608
- },
4609
- fromDate,
4610
- toDate,
4611
- initialFocus: true
4612
- }
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
4613
4684
  }
4614
4685
  ) })
4615
4686
  ] });
@@ -6923,7 +6994,7 @@ function TableHead({ className, ...props }) {
6923
6994
  {
6924
6995
  "data-slot": "table-head",
6925
6996
  className: cn(
6926
- "text-foreground has([role=checkbox])]:pr-0 h-12 px-3 text-left align-middle font-medium whitespace-nowrap",
6997
+ "text-foreground has-[[role=checkbox]]:pr-0 h-12 px-3 text-left align-middle font-medium whitespace-nowrap",
6927
6998
  className
6928
6999
  ),
6929
7000
  ...props
@@ -6936,7 +7007,7 @@ function TableCell({ className, ...props }) {
6936
7007
  {
6937
7008
  "data-slot": "table-cell",
6938
7009
  className: cn(
6939
- "has([role=checkbox])]:pr-0 p-3 align-middle whitespace-nowrap",
7010
+ "has-[[role=checkbox]]:pr-0 p-3 align-middle whitespace-nowrap",
6940
7011
  className
6941
7012
  ),
6942
7013
  ...props
@@ -7197,6 +7268,13 @@ function useTableContext() {
7197
7268
  function useTableContextSafe() {
7198
7269
  return react.useContext(TableContext);
7199
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
+ };
7200
7278
  var cardPadding = {
7201
7279
  sm: "p-3",
7202
7280
  md: "p-4",
@@ -7534,6 +7612,9 @@ function DataTableHeaderCell({ header }) {
7534
7612
  },
7535
7613
  className: cn(
7536
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],
7537
7618
  canResize && "relative",
7538
7619
  meta.align === "center" && "text-center",
7539
7620
  meta.align === "right" && "text-right",
@@ -7923,11 +8004,6 @@ function useTablePersistence({
7923
8004
  persistDensity
7924
8005
  };
7925
8006
  }
7926
- var cellSizeClass = {
7927
- sm: "px-1 py-0 text-xs",
7928
- md: "px-5 py-2.5 text-sm",
7929
- lg: "px-6 py-3 text-sm"
7930
- };
7931
8007
  function resolveClassName(value, row) {
7932
8008
  return typeof value === "function" ? value(row) : value;
7933
8009
  }
@@ -7968,6 +8044,13 @@ function DataTableCell({
7968
8044
  }
7969
8045
  );
7970
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
+ }
7971
8054
  function DataTableRow({ row, classNames }) {
7972
8055
  const { onRowClick, variant } = useTableContext();
7973
8056
  const clickable = Boolean(onRowClick);
@@ -7980,12 +8063,15 @@ function DataTableRow({ row, classNames }) {
7980
8063
  "data-clickable": clickable || void 0,
7981
8064
  role: clickable ? "button" : void 0,
7982
8065
  tabIndex: clickable ? 0 : void 0,
7983
- onClick: clickable ? () => onRowClick?.(row.original) : void 0,
8066
+ onClick: clickable ? (e) => {
8067
+ if (isInteractiveCellEvent(e)) return;
8068
+ onRowClick?.(row.original);
8069
+ } : void 0,
7984
8070
  onKeyDown: clickable ? (e) => {
7985
- if (e.key === "Enter" || e.key === " ") {
7986
- e.preventDefault();
7987
- onRowClick?.(row.original);
7988
- }
8071
+ if (e.key !== "Enter" && e.key !== " ") return;
8072
+ if (isInteractiveCellEvent(e)) return;
8073
+ e.preventDefault();
8074
+ onRowClick?.(row.original);
7989
8075
  } : void 0,
7990
8076
  className: cn("hover:bg-muted", clickable && "cursor-pointer", rowClassName),
7991
8077
  children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsxRuntime.jsx(DataTableCell, { cell, cellClassName }, cell.id))
@@ -8586,7 +8672,7 @@ function DataTableFooter({ pagination, selectedCount, className }) {
8586
8672
  className: cn("flex items-center justify-between border-t px-4 py-2", className),
8587
8673
  children: [
8588
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` }),
8589
- /* @__PURE__ */ jsxRuntime.jsx(TablePagination, { ...pagination })
8675
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto", children: /* @__PURE__ */ jsxRuntime.jsx(TablePagination, { ...pagination }) })
8590
8676
  ]
8591
8677
  }
8592
8678
  );
@@ -8695,18 +8781,21 @@ function DataTableSearch({
8695
8781
  debounce = 300
8696
8782
  }) {
8697
8783
  const ctx = useTableContextSafe();
8698
- const [inputValue, setInputValue] = react.useState("");
8699
8784
  const globalFilter = ctx?.globalFilter;
8700
8785
  const setGlobalFilter = ctx?.setGlobalFilter;
8786
+ const committedValue = globalFilter ?? "";
8787
+ const [inputValue, setInputValue] = react.useState(committedValue);
8701
8788
  react.useEffect(() => {
8702
- if (globalFilter === "") setInputValue("");
8789
+ if (globalFilter === void 0) return;
8790
+ setInputValue(globalFilter);
8703
8791
  }, [globalFilter]);
8704
8792
  react.useEffect(() => {
8793
+ if (inputValue === committedValue) return;
8705
8794
  const timer = setTimeout(() => {
8706
8795
  setGlobalFilter?.(inputValue);
8707
8796
  }, debounce);
8708
8797
  return () => clearTimeout(timer);
8709
- }, [inputValue, debounce, setGlobalFilter]);
8798
+ }, [inputValue, committedValue, debounce, setGlobalFilter]);
8710
8799
  const handleClear = () => {
8711
8800
  setInputValue("");
8712
8801
  setGlobalFilter?.("");
@@ -8727,7 +8816,13 @@ function DataTableSearch({
8727
8816
  onChange: (e) => setInputValue(e.target.value),
8728
8817
  placeholder,
8729
8818
  "aria-label": placeholder,
8730
- className: "h-8 w-48 pr-8 pl-8 text-sm"
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
+ )
8731
8826
  }
8732
8827
  ),
8733
8828
  inputValue && /* @__PURE__ */ jsxRuntime.jsx(
@@ -8737,7 +8832,7 @@ function DataTableSearch({
8737
8832
  size: "icon-sm",
8738
8833
  onClick: handleClear,
8739
8834
  "aria-label": "Clear search",
8740
- className: "text-muted-foreground hover:text-foreground absolute right-0.5 size-6",
8835
+ className: "text-muted-foreground hover:text-foreground absolute top-1/2 right-1.5 size-6 -translate-y-1/2",
8741
8836
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "size-3.5", "aria-hidden": "true" })
8742
8837
  }
8743
8838
  )