@facter/ds-core 1.17.0 → 1.19.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.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +33 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -360,6 +360,8 @@ interface DataTableSearchProps {
|
|
|
360
360
|
interface DataTableFiltersProps {
|
|
361
361
|
/** Children: Individual filters */
|
|
362
362
|
children?: React$1.ReactNode;
|
|
363
|
+
/** Callback when any column filter changes (server-side filtering) */
|
|
364
|
+
onChange?: (filters: _tanstack_react_table.ColumnFiltersState) => void;
|
|
363
365
|
/** Custom className */
|
|
364
366
|
className?: string;
|
|
365
367
|
}
|
|
@@ -369,14 +371,16 @@ interface DataTableFilterOption {
|
|
|
369
371
|
icon?: React$1.ReactNode;
|
|
370
372
|
}
|
|
371
373
|
interface DataTableFilterProps {
|
|
372
|
-
/** Coluna para filtrar */
|
|
373
|
-
column
|
|
374
|
+
/** Coluna para filtrar (opcional para server-side only) */
|
|
375
|
+
column?: string;
|
|
374
376
|
/** Label do filtro */
|
|
375
377
|
title: string;
|
|
376
378
|
/** Opções de filtro */
|
|
377
379
|
options: DataTableFilterOption[];
|
|
378
380
|
/** Permitir seleção múltipla */
|
|
379
381
|
multiSelect?: boolean;
|
|
382
|
+
/** Callback para server-side filtering (recebe valor selecionado ou undefined para "todos") */
|
|
383
|
+
onValueChange?: (value: string | undefined) => void;
|
|
380
384
|
/** Custom className */
|
|
381
385
|
className?: string;
|
|
382
386
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -360,6 +360,8 @@ interface DataTableSearchProps {
|
|
|
360
360
|
interface DataTableFiltersProps {
|
|
361
361
|
/** Children: Individual filters */
|
|
362
362
|
children?: React$1.ReactNode;
|
|
363
|
+
/** Callback when any column filter changes (server-side filtering) */
|
|
364
|
+
onChange?: (filters: _tanstack_react_table.ColumnFiltersState) => void;
|
|
363
365
|
/** Custom className */
|
|
364
366
|
className?: string;
|
|
365
367
|
}
|
|
@@ -369,14 +371,16 @@ interface DataTableFilterOption {
|
|
|
369
371
|
icon?: React$1.ReactNode;
|
|
370
372
|
}
|
|
371
373
|
interface DataTableFilterProps {
|
|
372
|
-
/** Coluna para filtrar */
|
|
373
|
-
column
|
|
374
|
+
/** Coluna para filtrar (opcional para server-side only) */
|
|
375
|
+
column?: string;
|
|
374
376
|
/** Label do filtro */
|
|
375
377
|
title: string;
|
|
376
378
|
/** Opções de filtro */
|
|
377
379
|
options: DataTableFilterOption[];
|
|
378
380
|
/** Permitir seleção múltipla */
|
|
379
381
|
multiSelect?: boolean;
|
|
382
|
+
/** Callback para server-side filtering (recebe valor selecionado ou undefined para "todos") */
|
|
383
|
+
onValueChange?: (value: string | undefined) => void;
|
|
380
384
|
/** Custom className */
|
|
381
385
|
className?: string;
|
|
382
386
|
}
|
package/dist/index.js
CHANGED
|
@@ -1651,32 +1651,38 @@ var DataTableSearch = React10__namespace.memo(function DataTableSearch2({
|
|
|
1651
1651
|
className
|
|
1652
1652
|
}) {
|
|
1653
1653
|
const table = useDataTableInstance();
|
|
1654
|
-
const columnInstance = table.getColumn(column);
|
|
1654
|
+
const columnInstance = column ? table.getColumn(column) : null;
|
|
1655
1655
|
const [value, setValue] = React10__namespace.useState(
|
|
1656
1656
|
columnInstance?.getFilterValue() ?? ""
|
|
1657
1657
|
);
|
|
1658
1658
|
const debouncedValue = useDebounce(value, debounce);
|
|
1659
|
+
const isServerSide = !!onSearch;
|
|
1659
1660
|
React10__namespace.useEffect(() => {
|
|
1660
|
-
|
|
1661
|
-
if (onSearch) {
|
|
1661
|
+
if (isServerSide) {
|
|
1662
1662
|
onSearch(debouncedValue);
|
|
1663
|
+
} else if (columnInstance) {
|
|
1664
|
+
columnInstance.setFilterValue(debouncedValue || void 0);
|
|
1663
1665
|
}
|
|
1664
|
-
}, [debouncedValue, columnInstance, onSearch]);
|
|
1666
|
+
}, [debouncedValue, columnInstance, onSearch, isServerSide]);
|
|
1665
1667
|
React10__namespace.useEffect(() => {
|
|
1666
|
-
|
|
1668
|
+
if (isServerSide || !columnInstance) return;
|
|
1669
|
+
const filterValue = columnInstance.getFilterValue() ?? "";
|
|
1667
1670
|
if (filterValue !== value) {
|
|
1668
1671
|
setValue(filterValue);
|
|
1669
1672
|
}
|
|
1670
|
-
}, [columnInstance?.getFilterValue()]);
|
|
1671
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1673
|
+
}, [columnInstance?.getFilterValue(), isServerSide]);
|
|
1674
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("relative w-[150px] lg:w-[250px]", className), children: [
|
|
1675
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" }),
|
|
1676
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1677
|
+
Input,
|
|
1678
|
+
{
|
|
1679
|
+
placeholder,
|
|
1680
|
+
value,
|
|
1681
|
+
onChange: (e) => setValue(e.target.value),
|
|
1682
|
+
className: "h-9 pl-9"
|
|
1683
|
+
}
|
|
1684
|
+
)
|
|
1685
|
+
] });
|
|
1680
1686
|
});
|
|
1681
1687
|
var DataTableFilters = React10__namespace.memo(function DataTableFilters2({
|
|
1682
1688
|
onChange,
|
|
@@ -1698,21 +1704,26 @@ var DataTableFilter = React10__namespace.memo(function DataTableFilter2({
|
|
|
1698
1704
|
column: columnId,
|
|
1699
1705
|
title,
|
|
1700
1706
|
options,
|
|
1707
|
+
onValueChange: onServerValueChange,
|
|
1701
1708
|
className
|
|
1702
1709
|
}) {
|
|
1703
1710
|
const table = useDataTableInstance();
|
|
1704
|
-
const column = table.getColumn(columnId);
|
|
1711
|
+
const column = columnId ? table.getColumn(columnId) : null;
|
|
1705
1712
|
const filterValue = column?.getFilterValue() ?? [];
|
|
1706
|
-
const
|
|
1713
|
+
const [localValue, setLocalValue] = React10__namespace.useState("all");
|
|
1714
|
+
const currentValue = column ? filterValue.length > 0 ? filterValue[0] : "all" : localValue;
|
|
1707
1715
|
const handleValueChange = React10__namespace.useCallback(
|
|
1708
1716
|
(value) => {
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1717
|
+
const resolvedValue = value === "all" ? void 0 : value;
|
|
1718
|
+
if (column) {
|
|
1719
|
+
column.setFilterValue(resolvedValue ? [resolvedValue] : void 0);
|
|
1720
|
+
}
|
|
1721
|
+
if (onServerValueChange) {
|
|
1722
|
+
onServerValueChange(resolvedValue);
|
|
1713
1723
|
}
|
|
1724
|
+
setLocalValue(value);
|
|
1714
1725
|
},
|
|
1715
|
-
[column]
|
|
1726
|
+
[column, onServerValueChange]
|
|
1716
1727
|
);
|
|
1717
1728
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1718
1729
|
Select,
|