@facter/ds-core 1.18.0 → 1.20.0

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.mjs CHANGED
@@ -1625,21 +1625,21 @@ var DataTableSearch = React10.memo(function DataTableSearch2({
1625
1625
  columnInstance?.getFilterValue() ?? ""
1626
1626
  );
1627
1627
  const debouncedValue = useDebounce(value, debounce);
1628
+ const isServerSide = !!onSearch;
1628
1629
  React10.useEffect(() => {
1629
- if (columnInstance) {
1630
- columnInstance.setFilterValue(debouncedValue || void 0);
1631
- }
1632
- if (onSearch) {
1630
+ if (isServerSide) {
1633
1631
  onSearch(debouncedValue);
1632
+ } else if (columnInstance) {
1633
+ columnInstance.setFilterValue(debouncedValue || void 0);
1634
1634
  }
1635
- }, [debouncedValue, columnInstance, onSearch]);
1635
+ }, [debouncedValue, columnInstance, onSearch, isServerSide]);
1636
1636
  React10.useEffect(() => {
1637
- if (!columnInstance) return;
1637
+ if (isServerSide || !columnInstance) return;
1638
1638
  const filterValue = columnInstance.getFilterValue() ?? "";
1639
1639
  if (filterValue !== value) {
1640
1640
  setValue(filterValue);
1641
1641
  }
1642
- }, [columnInstance?.getFilterValue()]);
1642
+ }, [columnInstance?.getFilterValue(), isServerSide]);
1643
1643
  return /* @__PURE__ */ jsxs("div", { className: cn("relative w-[150px] lg:w-[250px]", className), children: [
1644
1644
  /* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" }),
1645
1645
  /* @__PURE__ */ jsx(
@@ -1681,14 +1681,14 @@ var DataTableFilter = React10.memo(function DataTableFilter2({
1681
1681
  const filterValue = column?.getFilterValue() ?? [];
1682
1682
  const [localValue, setLocalValue] = React10.useState("all");
1683
1683
  const currentValue = column ? filterValue.length > 0 ? filterValue[0] : "all" : localValue;
1684
+ const isServerSide = !!onServerValueChange;
1684
1685
  const handleValueChange = React10.useCallback(
1685
1686
  (value) => {
1686
1687
  const resolvedValue = value === "all" ? void 0 : value;
1687
- if (column) {
1688
- column.setFilterValue(resolvedValue ? [resolvedValue] : void 0);
1689
- }
1690
- if (onServerValueChange) {
1688
+ if (isServerSide) {
1691
1689
  onServerValueChange(resolvedValue);
1690
+ } else if (column) {
1691
+ column.setFilterValue(resolvedValue ? [resolvedValue] : void 0);
1692
1692
  }
1693
1693
  setLocalValue(value);
1694
1694
  },
@@ -1704,7 +1704,10 @@ var DataTableFilter = React10.memo(function DataTableFilter2({
1704
1704
  className,
1705
1705
  children: [
1706
1706
  /* @__PURE__ */ jsx(SelectItem, { value: "all", children: "Todos" }),
1707
- options.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value))
1707
+ options.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
1708
+ option.icon && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-muted-foreground", children: option.icon }),
1709
+ option.label
1710
+ ] }) }, option.value))
1708
1711
  ]
1709
1712
  }
1710
1713
  );