@charlesgomes/leafcode-shared-lib-react 1.0.82 → 1.0.84
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 +16 -10
- package/dist/index.d.ts +16 -10
- package/dist/index.js +389 -265
- package/dist/index.mjs +386 -264
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1145,7 +1145,7 @@ function DynamicColumns({
|
|
|
1145
1145
|
size: "small",
|
|
1146
1146
|
onClick: () => {
|
|
1147
1147
|
const constraint = options.filterModel.constraints[0];
|
|
1148
|
-
if (constraint.matchMode === "empty" || constraint.matchMode === "notEmpty") {
|
|
1148
|
+
if (constraint.matchMode === "empty" || constraint.matchMode === "notEmpty" || constraint.matchMode !== "any" || constraint.matchMode !== "none") {
|
|
1149
1149
|
constraint.value = true;
|
|
1150
1150
|
}
|
|
1151
1151
|
options.filterApplyCallback(constraint.value, 0);
|
|
@@ -1709,268 +1709,9 @@ function DataTableAdvancedFilter({
|
|
|
1709
1709
|
// src/components/DataTableAdvancedFilter/FilterTemplates.tsx
|
|
1710
1710
|
import Select2 from "react-select";
|
|
1711
1711
|
import moment2 from "moment";
|
|
1712
|
-
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1713
|
-
var DateFilterTemplate = (options, mask) => {
|
|
1714
|
-
const matchMode = options.filterModel?.matchMode;
|
|
1715
|
-
const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
|
|
1716
|
-
const parsedValue = typeof options.filterModel?.value === "string" ? /* @__PURE__ */ new Date(options.filterModel.value + "T00:00:00") : null;
|
|
1717
|
-
return /* @__PURE__ */ jsx18("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ jsx18(
|
|
1718
|
-
Calendar,
|
|
1719
|
-
{
|
|
1720
|
-
value: parsedValue,
|
|
1721
|
-
onChange: (e) => {
|
|
1722
|
-
const date = e.value;
|
|
1723
|
-
if (!date) {
|
|
1724
|
-
options.filterCallback(null, options.index);
|
|
1725
|
-
return;
|
|
1726
|
-
}
|
|
1727
|
-
const valueToFilter = mask ? mask(date) : `${date.getFullYear()}-${String(
|
|
1728
|
-
date.getMonth() + 1
|
|
1729
|
-
).padStart(2, "0")}-${String(
|
|
1730
|
-
date.getDate()
|
|
1731
|
-
).padStart(2, "0")}`;
|
|
1732
|
-
options.filterCallback(valueToFilter, options.index);
|
|
1733
|
-
},
|
|
1734
|
-
dateFormat: "dd/mm/yy",
|
|
1735
|
-
placeholder: "dd/mm/yyyy",
|
|
1736
|
-
mask: "99/99/9999",
|
|
1737
|
-
inputClassName: "p-column-filter"
|
|
1738
|
-
}
|
|
1739
|
-
) });
|
|
1740
|
-
};
|
|
1741
|
-
var DateTimeFilterTemplate = (options, mask) => {
|
|
1742
|
-
const matchMode = options.filterModel?.matchMode;
|
|
1743
|
-
const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
|
|
1744
|
-
const value = options.filterModel?.value ? moment2(options.filterModel.value).toDate() : null;
|
|
1745
|
-
return /* @__PURE__ */ jsx18("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ jsx18(
|
|
1746
|
-
Calendar,
|
|
1747
|
-
{
|
|
1748
|
-
value,
|
|
1749
|
-
showTime: true,
|
|
1750
|
-
showSeconds: true,
|
|
1751
|
-
hourFormat: "24",
|
|
1752
|
-
dateFormat: "dd/mm/yy",
|
|
1753
|
-
placeholder: "dd/mm/yyyy 00:00:00",
|
|
1754
|
-
readOnlyInput: true,
|
|
1755
|
-
inputClassName: "p-column-filter",
|
|
1756
|
-
onChange: (e) => {
|
|
1757
|
-
const selectedDate = e.value;
|
|
1758
|
-
if (!selectedDate) {
|
|
1759
|
-
options.filterCallback(null, options.index);
|
|
1760
|
-
return;
|
|
1761
|
-
}
|
|
1762
|
-
const formatted = mask ? mask(selectedDate) : moment2(selectedDate).utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
|
|
1763
|
-
options.filterCallback(formatted, options.index);
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
) });
|
|
1767
|
-
};
|
|
1768
|
-
var ValueFilterTemplate = (options, mask) => {
|
|
1769
|
-
const parsedValue = options.value !== null && options.value !== void 0 ? centsToReal(options.value) : null;
|
|
1770
|
-
const handleChange = (e) => {
|
|
1771
|
-
const rawValue = e.value;
|
|
1772
|
-
if (rawValue === null || rawValue === void 0) {
|
|
1773
|
-
options.filterCallback(null, options.index);
|
|
1774
|
-
return;
|
|
1775
|
-
}
|
|
1776
|
-
const valueToFilter = mask ? mask(rawValue) : rawValue;
|
|
1777
|
-
options.filterCallback(String(valueToFilter), options.index);
|
|
1778
|
-
};
|
|
1779
|
-
return /* @__PURE__ */ jsx18(
|
|
1780
|
-
InputNumber,
|
|
1781
|
-
{
|
|
1782
|
-
value: parsedValue,
|
|
1783
|
-
placeholder: "R$ 0,00",
|
|
1784
|
-
onValueChange: handleChange,
|
|
1785
|
-
mode: "currency",
|
|
1786
|
-
currency: "BRL",
|
|
1787
|
-
locale: "pt-BR",
|
|
1788
|
-
inputClassName: "custom-input"
|
|
1789
|
-
}
|
|
1790
|
-
);
|
|
1791
|
-
};
|
|
1792
|
-
var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
|
|
1793
|
-
const selectOptions = items.length > 0 ? items : [
|
|
1794
|
-
{ label: isLanguagePtBr ? "Sim" : "Yes", value: true },
|
|
1795
|
-
{ label: isLanguagePtBr ? "N\xE3o" : "No", value: false }
|
|
1796
|
-
];
|
|
1797
|
-
const matchMode = options.filterModel?.matchMode;
|
|
1798
|
-
const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
|
|
1799
|
-
const currentValue = selectOptions.find(
|
|
1800
|
-
(opt) => opt.value === options.filterModel?.value
|
|
1801
|
-
) || null;
|
|
1802
|
-
return /* @__PURE__ */ jsx18("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ jsx18(
|
|
1803
|
-
Select2,
|
|
1804
|
-
{
|
|
1805
|
-
options: selectOptions,
|
|
1806
|
-
value: currentValue,
|
|
1807
|
-
onChange: (selected) => {
|
|
1808
|
-
options.filterCallback(
|
|
1809
|
-
selected ? selected.value : null,
|
|
1810
|
-
options.index
|
|
1811
|
-
// 🔥 ESSENCIAL
|
|
1812
|
-
);
|
|
1813
|
-
},
|
|
1814
|
-
placeholder: isLanguagePtBr ? "Selecione..." : "Select...",
|
|
1815
|
-
isClearable: true,
|
|
1816
|
-
isSearchable: false,
|
|
1817
|
-
className: "custom-select-filtro",
|
|
1818
|
-
classNamePrefix: "custom-select-filtro"
|
|
1819
|
-
}
|
|
1820
|
-
) });
|
|
1821
|
-
};
|
|
1822
|
-
var CustomFilterElement = (options, isLanguagePtBr = true) => {
|
|
1823
|
-
const matchMode = options.filterModel?.matchMode;
|
|
1824
|
-
const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
|
|
1825
|
-
return !isSpecial && /* @__PURE__ */ jsx18(
|
|
1826
|
-
InputText,
|
|
1827
|
-
{
|
|
1828
|
-
value: options.filterModel?.value ?? "",
|
|
1829
|
-
placeholder: isLanguagePtBr ? "Pesquisar" : "Search",
|
|
1830
|
-
onChange: (e) => {
|
|
1831
|
-
options.filterCallback(
|
|
1832
|
-
e.target.value || null,
|
|
1833
|
-
options.index
|
|
1834
|
-
);
|
|
1835
|
-
},
|
|
1836
|
-
className: "p-column-filter"
|
|
1837
|
-
}
|
|
1838
|
-
);
|
|
1839
|
-
};
|
|
1840
|
-
|
|
1841
|
-
// src/components/DataTableAdvancedFilter/filterModes.ts
|
|
1842
|
-
import { FilterMatchMode as FilterMatchMode3 } from "primereact/api";
|
|
1843
|
-
var customMatchModes = {
|
|
1844
|
-
notStartsWith: "notStartsWith",
|
|
1845
|
-
notEndsWith: "notEndsWith",
|
|
1846
|
-
empty: "empty",
|
|
1847
|
-
notEmpty: "notEmpty",
|
|
1848
|
-
dateBeforeAndEquals: "dateBeforeAndEquals",
|
|
1849
|
-
dateAfterAndEquals: "dateAfterAndEquals"
|
|
1850
|
-
};
|
|
1851
|
-
var getDefaultFilterMatchOptionsString = (isLanguagePtBr = true, isNullable = true) => {
|
|
1852
|
-
const baseOptions = [
|
|
1853
|
-
{
|
|
1854
|
-
label: isLanguagePtBr ? "Cont\xE9m" : "Contains",
|
|
1855
|
-
value: FilterMatchMode3.CONTAINS
|
|
1856
|
-
},
|
|
1857
|
-
{
|
|
1858
|
-
label: isLanguagePtBr ? "N\xE3o cont\xE9m" : "Does not contain",
|
|
1859
|
-
value: FilterMatchMode3.NOT_CONTAINS
|
|
1860
|
-
},
|
|
1861
|
-
{
|
|
1862
|
-
label: isLanguagePtBr ? "Igual" : "Equals",
|
|
1863
|
-
value: FilterMatchMode3.EQUALS
|
|
1864
|
-
},
|
|
1865
|
-
{
|
|
1866
|
-
label: isLanguagePtBr ? "Diferente" : "Not equals",
|
|
1867
|
-
value: FilterMatchMode3.NOT_EQUALS
|
|
1868
|
-
},
|
|
1869
|
-
{
|
|
1870
|
-
label: isLanguagePtBr ? "Come\xE7a com" : "Starts with",
|
|
1871
|
-
value: FilterMatchMode3.STARTS_WITH
|
|
1872
|
-
},
|
|
1873
|
-
{
|
|
1874
|
-
label: isLanguagePtBr ? "N\xE3o come\xE7a com" : "Does not start with",
|
|
1875
|
-
value: customMatchModes.notStartsWith
|
|
1876
|
-
},
|
|
1877
|
-
{
|
|
1878
|
-
label: isLanguagePtBr ? "Termina com" : "Ends with",
|
|
1879
|
-
value: FilterMatchMode3.ENDS_WITH
|
|
1880
|
-
},
|
|
1881
|
-
{
|
|
1882
|
-
label: isLanguagePtBr ? "N\xE3o termina com" : "Does not end with",
|
|
1883
|
-
value: customMatchModes.notEndsWith
|
|
1884
|
-
}
|
|
1885
|
-
];
|
|
1886
|
-
return isNullable ? [...baseOptions, ...getNullable(isLanguagePtBr)] : baseOptions;
|
|
1887
|
-
};
|
|
1888
|
-
var getDefaultFilterMatchOptionsNumber = (isLanguagePtBr = true, isNullable = true) => {
|
|
1889
|
-
const baseOptions = [
|
|
1890
|
-
{
|
|
1891
|
-
label: isLanguagePtBr ? "Igual" : "Equals",
|
|
1892
|
-
value: FilterMatchMode3.EQUALS
|
|
1893
|
-
},
|
|
1894
|
-
{
|
|
1895
|
-
label: isLanguagePtBr ? "Diferente" : "Not equals",
|
|
1896
|
-
value: FilterMatchMode3.NOT_EQUALS
|
|
1897
|
-
},
|
|
1898
|
-
{
|
|
1899
|
-
label: isLanguagePtBr ? "Menor que" : "Less than",
|
|
1900
|
-
value: FilterMatchMode3.LESS_THAN
|
|
1901
|
-
},
|
|
1902
|
-
{
|
|
1903
|
-
label: isLanguagePtBr ? "Menor ou igual a" : "Less than or equal to",
|
|
1904
|
-
value: FilterMatchMode3.LESS_THAN_OR_EQUAL_TO
|
|
1905
|
-
},
|
|
1906
|
-
{
|
|
1907
|
-
label: isLanguagePtBr ? "Maior que" : "Greater than",
|
|
1908
|
-
value: FilterMatchMode3.GREATER_THAN
|
|
1909
|
-
},
|
|
1910
|
-
{
|
|
1911
|
-
label: isLanguagePtBr ? "Maior ou igual a" : "Greater than or equal to",
|
|
1912
|
-
value: FilterMatchMode3.GREATER_THAN_OR_EQUAL_TO
|
|
1913
|
-
}
|
|
1914
|
-
];
|
|
1915
|
-
return isNullable ? [...baseOptions, ...getNullable(isLanguagePtBr)] : baseOptions;
|
|
1916
|
-
};
|
|
1917
|
-
var getDefaultFilterMatchOptionsStringArray = (isLanguagePtBr = true) => [
|
|
1918
|
-
{
|
|
1919
|
-
label: isLanguagePtBr ? "Cont\xE9m" : "Contains",
|
|
1920
|
-
value: FilterMatchMode3.CONTAINS
|
|
1921
|
-
},
|
|
1922
|
-
{
|
|
1923
|
-
label: isLanguagePtBr ? "N\xE3o cont\xE9m" : "Does not contain",
|
|
1924
|
-
value: FilterMatchMode3.NOT_CONTAINS
|
|
1925
|
-
}
|
|
1926
|
-
];
|
|
1927
|
-
var getDefaultFilterMatchOptionsDate = (isLanguagePtBr, isNullable = true) => {
|
|
1928
|
-
const baseOptions = [
|
|
1929
|
-
{
|
|
1930
|
-
label: isLanguagePtBr ? "Data anterior a" : "Date before",
|
|
1931
|
-
value: FilterMatchMode3.DATE_BEFORE
|
|
1932
|
-
},
|
|
1933
|
-
{
|
|
1934
|
-
label: isLanguagePtBr ? "Data anterior ou igual a" : "Date prior to or equal to",
|
|
1935
|
-
value: customMatchModes.dateBeforeAndEquals
|
|
1936
|
-
},
|
|
1937
|
-
{
|
|
1938
|
-
label: isLanguagePtBr ? "Data posterior a" : "Date after",
|
|
1939
|
-
value: FilterMatchMode3.DATE_AFTER
|
|
1940
|
-
},
|
|
1941
|
-
{
|
|
1942
|
-
label: isLanguagePtBr ? "Data posterior ou igual a" : "Date later than or equal to",
|
|
1943
|
-
value: customMatchModes.dateAfterAndEquals
|
|
1944
|
-
}
|
|
1945
|
-
];
|
|
1946
|
-
return isNullable ? [...baseOptions, ...getNullable(isLanguagePtBr)] : baseOptions;
|
|
1947
|
-
};
|
|
1948
|
-
var getDefaultFilterMatchOptionsEnum = (isLanguagePtBr, isNullable = true) => {
|
|
1949
|
-
const baseOptions = [
|
|
1950
|
-
{
|
|
1951
|
-
label: isLanguagePtBr ? "Igual" : "Equals",
|
|
1952
|
-
value: FilterMatchMode3.EQUALS
|
|
1953
|
-
},
|
|
1954
|
-
{
|
|
1955
|
-
label: isLanguagePtBr ? "Diferente" : "Not equals",
|
|
1956
|
-
value: FilterMatchMode3.NOT_EQUALS
|
|
1957
|
-
}
|
|
1958
|
-
];
|
|
1959
|
-
return isNullable ? [...baseOptions, ...getNullable(isLanguagePtBr)] : baseOptions;
|
|
1960
|
-
};
|
|
1961
|
-
var getNullable = (isLanguagePtBr) => [
|
|
1962
|
-
{
|
|
1963
|
-
label: isLanguagePtBr ? "Vazio" : "Empty",
|
|
1964
|
-
value: customMatchModes.empty
|
|
1965
|
-
},
|
|
1966
|
-
{
|
|
1967
|
-
label: isLanguagePtBr ? "N\xE3o Vazio" : "NotEmpty",
|
|
1968
|
-
value: customMatchModes.notEmpty
|
|
1969
|
-
}
|
|
1970
|
-
];
|
|
1971
1712
|
|
|
1972
1713
|
// src/components/DataTableAdvancedFilter/utils/DataTableUtils.tsx
|
|
1973
|
-
import { FilterMatchMode as
|
|
1714
|
+
import { FilterMatchMode as FilterMatchMode3, FilterOperator } from "primereact/api";
|
|
1974
1715
|
var mapMatchMode = (mode) => {
|
|
1975
1716
|
switch (mode) {
|
|
1976
1717
|
case "startsWith":
|
|
@@ -2003,6 +1744,12 @@ var mapMatchMode = (mode) => {
|
|
|
2003
1744
|
};
|
|
2004
1745
|
var buildFilterPayload = (fieldName, matchMode, rawValue) => {
|
|
2005
1746
|
const normalized = normalizeFilterValue(rawValue);
|
|
1747
|
+
if (matchMode === "any") {
|
|
1748
|
+
return { __collectionOperator: "any" };
|
|
1749
|
+
}
|
|
1750
|
+
if (matchMode === "none") {
|
|
1751
|
+
return { __collectionOperator: "none" };
|
|
1752
|
+
}
|
|
2006
1753
|
if (matchMode === "empty") {
|
|
2007
1754
|
return {
|
|
2008
1755
|
field: fieldName,
|
|
@@ -2118,7 +1865,13 @@ var mapPrimeToBackendFilters = (filters, globalFilterFields) => {
|
|
|
2118
1865
|
}
|
|
2119
1866
|
return;
|
|
2120
1867
|
}
|
|
2121
|
-
const constraints = Array.isArray(config.constraints) ? config.constraints.filter((c) =>
|
|
1868
|
+
const constraints = Array.isArray(config.constraints) ? config.constraints.filter((c) => {
|
|
1869
|
+
if (isSpecialMatchMode(c.matchMode)) {
|
|
1870
|
+
return true;
|
|
1871
|
+
}
|
|
1872
|
+
const normalized = normalizeFilterValue(c.value);
|
|
1873
|
+
return normalized !== null || normalized === "__NULL__";
|
|
1874
|
+
}) : [];
|
|
2122
1875
|
if (!constraints.length) return;
|
|
2123
1876
|
const colOperator = config.operator === "or" ? "or" : "and";
|
|
2124
1877
|
if (config.collection === "campos" && config.fieldId) {
|
|
@@ -2137,6 +1890,18 @@ var mapPrimeToBackendFilters = (filters, globalFilterFields) => {
|
|
|
2137
1890
|
).filter(Boolean);
|
|
2138
1891
|
if (!columnPayloads.length) return;
|
|
2139
1892
|
if (config.collection) {
|
|
1893
|
+
const collectionExistence = columnPayloads.find(
|
|
1894
|
+
(p) => p.__collectionOperator
|
|
1895
|
+
);
|
|
1896
|
+
if (collectionExistence) {
|
|
1897
|
+
const rootNode = buildCollectionExistenceNode(config.collection);
|
|
1898
|
+
if (collectionExistence.__collectionOperator === "none") {
|
|
1899
|
+
finalAnd.push({ not: rootNode });
|
|
1900
|
+
} else {
|
|
1901
|
+
finalAnd.push(rootNode);
|
|
1902
|
+
}
|
|
1903
|
+
return;
|
|
1904
|
+
}
|
|
2140
1905
|
const rootCollections = [];
|
|
2141
1906
|
columnPayloads.forEach((payload) => {
|
|
2142
1907
|
pushIntoCollectionTree(
|
|
@@ -2169,6 +1934,7 @@ function pushIntoCollectionTree(root, collectionPath, fieldName, payloadBase) {
|
|
|
2169
1934
|
const collections = collectionPath.split(".");
|
|
2170
1935
|
let current = root;
|
|
2171
1936
|
collections.forEach((collection) => {
|
|
1937
|
+
var _a;
|
|
2172
1938
|
let node = current.find(
|
|
2173
1939
|
(n) => n.collection === collection && n.any
|
|
2174
1940
|
);
|
|
@@ -2179,6 +1945,8 @@ function pushIntoCollectionTree(root, collectionPath, fieldName, payloadBase) {
|
|
|
2179
1945
|
};
|
|
2180
1946
|
current.push(node);
|
|
2181
1947
|
}
|
|
1948
|
+
node.any ?? (node.any = {});
|
|
1949
|
+
(_a = node.any).or ?? (_a.or = []);
|
|
2182
1950
|
current = node.any.or;
|
|
2183
1951
|
});
|
|
2184
1952
|
current.push({
|
|
@@ -2190,9 +1958,9 @@ function getMatchModeByTipo(tipo) {
|
|
|
2190
1958
|
switch (tipo) {
|
|
2191
1959
|
case "NumeroInteiro":
|
|
2192
1960
|
case "NumeroDecimal":
|
|
2193
|
-
return
|
|
1961
|
+
return FilterMatchMode3.EQUALS;
|
|
2194
1962
|
default:
|
|
2195
|
-
return
|
|
1963
|
+
return FilterMatchMode3.CONTAINS;
|
|
2196
1964
|
}
|
|
2197
1965
|
}
|
|
2198
1966
|
function buildDynamicCampoFilters(campos) {
|
|
@@ -2213,6 +1981,27 @@ function buildDynamicCampoFilters(campos) {
|
|
|
2213
1981
|
return acc;
|
|
2214
1982
|
}, {});
|
|
2215
1983
|
}
|
|
1984
|
+
function buildCollectionExistenceNode(collectionPath) {
|
|
1985
|
+
const collections = collectionPath.split(".");
|
|
1986
|
+
let root = null;
|
|
1987
|
+
let current = null;
|
|
1988
|
+
collections.forEach((collection) => {
|
|
1989
|
+
const node = {
|
|
1990
|
+
collection,
|
|
1991
|
+
any: {}
|
|
1992
|
+
};
|
|
1993
|
+
if (!root) {
|
|
1994
|
+
root = node;
|
|
1995
|
+
} else {
|
|
1996
|
+
if (!current.any.or) {
|
|
1997
|
+
current.any.or = [];
|
|
1998
|
+
}
|
|
1999
|
+
current.any.or.push(node);
|
|
2000
|
+
}
|
|
2001
|
+
current = node;
|
|
2002
|
+
});
|
|
2003
|
+
return root;
|
|
2004
|
+
}
|
|
2216
2005
|
var getUrlParams = (sortFieldInitial, sortOrderInitial) => {
|
|
2217
2006
|
const params = new URLSearchParams(
|
|
2218
2007
|
typeof window !== "undefined" ? window.location.search : ""
|
|
@@ -2282,6 +2071,337 @@ function resolveMatchMode(constraintMatchMode, rawValue) {
|
|
|
2282
2071
|
}
|
|
2283
2072
|
return constraintMatchMode;
|
|
2284
2073
|
}
|
|
2074
|
+
var SPECIAL_MATCH_MODES = /* @__PURE__ */ new Set([
|
|
2075
|
+
"empty",
|
|
2076
|
+
"notEmpty",
|
|
2077
|
+
"any",
|
|
2078
|
+
"none"
|
|
2079
|
+
]);
|
|
2080
|
+
var isSpecialMatchMode = (matchMode) => !!matchMode && SPECIAL_MATCH_MODES.has(matchMode);
|
|
2081
|
+
|
|
2082
|
+
// src/components/DataTableAdvancedFilter/FilterTemplates.tsx
|
|
2083
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
2084
|
+
var DateFilterTemplate = (options, mask) => {
|
|
2085
|
+
const matchMode = options.filterModel?.matchMode;
|
|
2086
|
+
const value = options.filterModel?.value;
|
|
2087
|
+
const isSpecial = isSpecialMatchMode(matchMode);
|
|
2088
|
+
if (!isSpecial && value === true) {
|
|
2089
|
+
options.filterCallback(
|
|
2090
|
+
"",
|
|
2091
|
+
options.index
|
|
2092
|
+
);
|
|
2093
|
+
}
|
|
2094
|
+
const parsedValue = typeof options.filterModel?.value === "string" ? /* @__PURE__ */ new Date(options.filterModel.value + "T00:00:00") : null;
|
|
2095
|
+
return /* @__PURE__ */ jsx18("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ jsx18(
|
|
2096
|
+
Calendar,
|
|
2097
|
+
{
|
|
2098
|
+
value: parsedValue,
|
|
2099
|
+
onChange: (e) => {
|
|
2100
|
+
const date = e.value;
|
|
2101
|
+
if (!date) {
|
|
2102
|
+
options.filterCallback(null, options.index);
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
const valueToFilter = mask ? mask(date) : `${date.getFullYear()}-${String(
|
|
2106
|
+
date.getMonth() + 1
|
|
2107
|
+
).padStart(2, "0")}-${String(
|
|
2108
|
+
date.getDate()
|
|
2109
|
+
).padStart(2, "0")}`;
|
|
2110
|
+
options.filterCallback(valueToFilter, options.index);
|
|
2111
|
+
},
|
|
2112
|
+
dateFormat: "dd/mm/yy",
|
|
2113
|
+
placeholder: "dd/mm/yyyy",
|
|
2114
|
+
mask: "99/99/9999",
|
|
2115
|
+
inputClassName: "p-column-filter"
|
|
2116
|
+
}
|
|
2117
|
+
) });
|
|
2118
|
+
};
|
|
2119
|
+
var DateTimeFilterTemplate = (options, mask) => {
|
|
2120
|
+
const matchMode = options.filterModel?.matchMode;
|
|
2121
|
+
const value = options.filterModel?.value ? moment2(options.filterModel.value).toDate() : null;
|
|
2122
|
+
return /* @__PURE__ */ jsx18("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecialMatchMode(matchMode) && /* @__PURE__ */ jsx18(
|
|
2123
|
+
Calendar,
|
|
2124
|
+
{
|
|
2125
|
+
value,
|
|
2126
|
+
showTime: true,
|
|
2127
|
+
showSeconds: true,
|
|
2128
|
+
hourFormat: "24",
|
|
2129
|
+
dateFormat: "dd/mm/yy",
|
|
2130
|
+
placeholder: "dd/mm/yyyy 00:00:00",
|
|
2131
|
+
readOnlyInput: true,
|
|
2132
|
+
inputClassName: "p-column-filter",
|
|
2133
|
+
onChange: (e) => {
|
|
2134
|
+
const selectedDate = e.value;
|
|
2135
|
+
if (!selectedDate) {
|
|
2136
|
+
options.filterCallback(null, options.index);
|
|
2137
|
+
return;
|
|
2138
|
+
}
|
|
2139
|
+
const formatted = mask ? mask(selectedDate) : moment2(selectedDate).utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
|
|
2140
|
+
options.filterCallback(formatted, options.index);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
) });
|
|
2144
|
+
};
|
|
2145
|
+
var ValueFilterTemplate = (options, mask) => {
|
|
2146
|
+
const parsedValue = options.value !== null && options.value !== void 0 ? centsToReal(options.value) : null;
|
|
2147
|
+
const handleChange = (e) => {
|
|
2148
|
+
const rawValue = e.value;
|
|
2149
|
+
if (rawValue === null || rawValue === void 0) {
|
|
2150
|
+
options.filterCallback(null, options.index);
|
|
2151
|
+
return;
|
|
2152
|
+
}
|
|
2153
|
+
const valueToFilter = mask ? mask(rawValue) : rawValue;
|
|
2154
|
+
options.filterCallback(String(valueToFilter), options.index);
|
|
2155
|
+
};
|
|
2156
|
+
const matchMode = options.filterModel?.matchMode;
|
|
2157
|
+
const value = options.filterModel?.value;
|
|
2158
|
+
const isSpecial = isSpecialMatchMode(matchMode);
|
|
2159
|
+
if (!isSpecial && value === true) {
|
|
2160
|
+
options.filterCallback(
|
|
2161
|
+
"",
|
|
2162
|
+
options.index
|
|
2163
|
+
);
|
|
2164
|
+
}
|
|
2165
|
+
return !isSpecial && /* @__PURE__ */ jsx18(
|
|
2166
|
+
InputNumber,
|
|
2167
|
+
{
|
|
2168
|
+
value: parsedValue,
|
|
2169
|
+
placeholder: "R$ 0,00",
|
|
2170
|
+
onValueChange: handleChange,
|
|
2171
|
+
mode: "currency",
|
|
2172
|
+
currency: "BRL",
|
|
2173
|
+
locale: "pt-BR",
|
|
2174
|
+
inputClassName: "custom-input"
|
|
2175
|
+
}
|
|
2176
|
+
);
|
|
2177
|
+
};
|
|
2178
|
+
var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
|
|
2179
|
+
const selectOptions = items.length > 0 ? items : [
|
|
2180
|
+
{ label: isLanguagePtBr ? "Sim" : "Yes", value: true },
|
|
2181
|
+
{ label: isLanguagePtBr ? "N\xE3o" : "No", value: false }
|
|
2182
|
+
];
|
|
2183
|
+
const matchMode = options.filterModel?.matchMode;
|
|
2184
|
+
const value = options.filterModel?.value;
|
|
2185
|
+
const isSpecial = isSpecialMatchMode(matchMode);
|
|
2186
|
+
if (!isSpecial && value === true) {
|
|
2187
|
+
options.filterCallback(
|
|
2188
|
+
"",
|
|
2189
|
+
options.index
|
|
2190
|
+
);
|
|
2191
|
+
}
|
|
2192
|
+
const currentValue = selectOptions.find(
|
|
2193
|
+
(opt) => opt.value === options.filterModel?.value
|
|
2194
|
+
) || null;
|
|
2195
|
+
return /* @__PURE__ */ jsx18("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ jsx18(
|
|
2196
|
+
Select2,
|
|
2197
|
+
{
|
|
2198
|
+
options: selectOptions,
|
|
2199
|
+
value: currentValue,
|
|
2200
|
+
onChange: (selected) => {
|
|
2201
|
+
options.filterCallback(
|
|
2202
|
+
selected ? selected.value : null,
|
|
2203
|
+
options.index
|
|
2204
|
+
);
|
|
2205
|
+
},
|
|
2206
|
+
placeholder: isLanguagePtBr ? "Selecione..." : "Select...",
|
|
2207
|
+
isClearable: true,
|
|
2208
|
+
isSearchable: false,
|
|
2209
|
+
className: "custom-select-filtro",
|
|
2210
|
+
classNamePrefix: "custom-select-filtro"
|
|
2211
|
+
}
|
|
2212
|
+
) });
|
|
2213
|
+
};
|
|
2214
|
+
var CustomFilterElement = (options, isLanguagePtBr = true) => {
|
|
2215
|
+
const matchMode = options.filterModel?.matchMode;
|
|
2216
|
+
const value = options.filterModel?.value;
|
|
2217
|
+
const isSpecial = isSpecialMatchMode(matchMode);
|
|
2218
|
+
if (!isSpecial && value === true) {
|
|
2219
|
+
options.filterCallback(
|
|
2220
|
+
"",
|
|
2221
|
+
options.index
|
|
2222
|
+
);
|
|
2223
|
+
}
|
|
2224
|
+
return !isSpecial && /* @__PURE__ */ jsx18(
|
|
2225
|
+
InputText,
|
|
2226
|
+
{
|
|
2227
|
+
value: options.filterModel?.value ?? "",
|
|
2228
|
+
placeholder: isLanguagePtBr ? "Pesquisar" : "Search",
|
|
2229
|
+
onChange: (e) => {
|
|
2230
|
+
options.filterCallback(
|
|
2231
|
+
e.target.value || null,
|
|
2232
|
+
options.index
|
|
2233
|
+
);
|
|
2234
|
+
},
|
|
2235
|
+
className: "p-column-filter"
|
|
2236
|
+
}
|
|
2237
|
+
);
|
|
2238
|
+
};
|
|
2239
|
+
|
|
2240
|
+
// src/components/DataTableAdvancedFilter/filterModes.ts
|
|
2241
|
+
import { FilterMatchMode as FilterMatchMode4 } from "primereact/api";
|
|
2242
|
+
var customMatchModes = {
|
|
2243
|
+
notStartsWith: "notStartsWith",
|
|
2244
|
+
notEndsWith: "notEndsWith",
|
|
2245
|
+
empty: "empty",
|
|
2246
|
+
notEmpty: "notEmpty",
|
|
2247
|
+
dateBeforeAndEquals: "dateBeforeAndEquals",
|
|
2248
|
+
dateAfterAndEquals: "dateAfterAndEquals",
|
|
2249
|
+
any: "any",
|
|
2250
|
+
none: "none"
|
|
2251
|
+
};
|
|
2252
|
+
var getDefaultFilterMatchOptionsString = (isLanguagePtBr = true, isNullable = true, isCollection = false) => {
|
|
2253
|
+
const baseOptions = [
|
|
2254
|
+
{
|
|
2255
|
+
label: isLanguagePtBr ? "Cont\xE9m" : "Contains",
|
|
2256
|
+
value: FilterMatchMode4.CONTAINS
|
|
2257
|
+
},
|
|
2258
|
+
{
|
|
2259
|
+
label: isLanguagePtBr ? "N\xE3o cont\xE9m" : "Does not contain",
|
|
2260
|
+
value: FilterMatchMode4.NOT_CONTAINS
|
|
2261
|
+
},
|
|
2262
|
+
{
|
|
2263
|
+
label: isLanguagePtBr ? "Igual" : "Equals",
|
|
2264
|
+
value: FilterMatchMode4.EQUALS
|
|
2265
|
+
},
|
|
2266
|
+
{
|
|
2267
|
+
label: isLanguagePtBr ? "Diferente" : "Not equals",
|
|
2268
|
+
value: FilterMatchMode4.NOT_EQUALS
|
|
2269
|
+
},
|
|
2270
|
+
{
|
|
2271
|
+
label: isLanguagePtBr ? "Come\xE7a com" : "Starts with",
|
|
2272
|
+
value: FilterMatchMode4.STARTS_WITH
|
|
2273
|
+
},
|
|
2274
|
+
{
|
|
2275
|
+
label: isLanguagePtBr ? "N\xE3o come\xE7a com" : "Does not start with",
|
|
2276
|
+
value: customMatchModes.notStartsWith
|
|
2277
|
+
},
|
|
2278
|
+
{
|
|
2279
|
+
label: isLanguagePtBr ? "Termina com" : "Ends with",
|
|
2280
|
+
value: FilterMatchMode4.ENDS_WITH
|
|
2281
|
+
},
|
|
2282
|
+
{
|
|
2283
|
+
label: isLanguagePtBr ? "N\xE3o termina com" : "Does not end with",
|
|
2284
|
+
value: customMatchModes.notEndsWith
|
|
2285
|
+
}
|
|
2286
|
+
];
|
|
2287
|
+
return [
|
|
2288
|
+
...baseOptions,
|
|
2289
|
+
...isCollection ? getNullableCollection(isLanguagePtBr) : [],
|
|
2290
|
+
...isNullable ? getNullable(isLanguagePtBr) : []
|
|
2291
|
+
];
|
|
2292
|
+
};
|
|
2293
|
+
var getDefaultFilterMatchOptionsNumber = (isLanguagePtBr = true, isNullable = true, isCollection = false) => {
|
|
2294
|
+
const baseOptions = [
|
|
2295
|
+
{
|
|
2296
|
+
label: isLanguagePtBr ? "Igual" : "Equals",
|
|
2297
|
+
value: FilterMatchMode4.EQUALS
|
|
2298
|
+
},
|
|
2299
|
+
{
|
|
2300
|
+
label: isLanguagePtBr ? "Diferente" : "Not equals",
|
|
2301
|
+
value: FilterMatchMode4.NOT_EQUALS
|
|
2302
|
+
},
|
|
2303
|
+
{
|
|
2304
|
+
label: isLanguagePtBr ? "Menor que" : "Less than",
|
|
2305
|
+
value: FilterMatchMode4.LESS_THAN
|
|
2306
|
+
},
|
|
2307
|
+
{
|
|
2308
|
+
label: isLanguagePtBr ? "Menor ou igual a" : "Less than or equal to",
|
|
2309
|
+
value: FilterMatchMode4.LESS_THAN_OR_EQUAL_TO
|
|
2310
|
+
},
|
|
2311
|
+
{
|
|
2312
|
+
label: isLanguagePtBr ? "Maior que" : "Greater than",
|
|
2313
|
+
value: FilterMatchMode4.GREATER_THAN
|
|
2314
|
+
},
|
|
2315
|
+
{
|
|
2316
|
+
label: isLanguagePtBr ? "Maior ou igual a" : "Greater than or equal to",
|
|
2317
|
+
value: FilterMatchMode4.GREATER_THAN_OR_EQUAL_TO
|
|
2318
|
+
}
|
|
2319
|
+
];
|
|
2320
|
+
return [
|
|
2321
|
+
...baseOptions,
|
|
2322
|
+
...isCollection ? getNullableCollection(isLanguagePtBr) : [],
|
|
2323
|
+
...isNullable ? getNullable(isLanguagePtBr) : []
|
|
2324
|
+
];
|
|
2325
|
+
};
|
|
2326
|
+
var getDefaultFilterMatchOptionsStringArray = (isLanguagePtBr = true, isNullable = true, isCollection = false) => {
|
|
2327
|
+
const baseOptions = [
|
|
2328
|
+
{
|
|
2329
|
+
label: isLanguagePtBr ? "Cont\xE9m" : "Contains",
|
|
2330
|
+
value: FilterMatchMode4.CONTAINS
|
|
2331
|
+
},
|
|
2332
|
+
{
|
|
2333
|
+
label: isLanguagePtBr ? "N\xE3o cont\xE9m" : "Does not contain",
|
|
2334
|
+
value: FilterMatchMode4.NOT_CONTAINS
|
|
2335
|
+
}
|
|
2336
|
+
];
|
|
2337
|
+
return [
|
|
2338
|
+
...baseOptions,
|
|
2339
|
+
...isCollection ? getNullableCollection(isLanguagePtBr) : [],
|
|
2340
|
+
...isNullable ? getNullable(isLanguagePtBr) : []
|
|
2341
|
+
];
|
|
2342
|
+
};
|
|
2343
|
+
var getDefaultFilterMatchOptionsDate = (isLanguagePtBr, isNullable = true, isCollection = false) => {
|
|
2344
|
+
const baseOptions = [
|
|
2345
|
+
{
|
|
2346
|
+
label: isLanguagePtBr ? "Data anterior a" : "Date before",
|
|
2347
|
+
value: FilterMatchMode4.DATE_BEFORE
|
|
2348
|
+
},
|
|
2349
|
+
{
|
|
2350
|
+
label: isLanguagePtBr ? "Data anterior ou igual a" : "Date prior to or equal to",
|
|
2351
|
+
value: customMatchModes.dateBeforeAndEquals
|
|
2352
|
+
},
|
|
2353
|
+
{
|
|
2354
|
+
label: isLanguagePtBr ? "Data posterior a" : "Date after",
|
|
2355
|
+
value: FilterMatchMode4.DATE_AFTER
|
|
2356
|
+
},
|
|
2357
|
+
{
|
|
2358
|
+
label: isLanguagePtBr ? "Data posterior ou igual a" : "Date later than or equal to",
|
|
2359
|
+
value: customMatchModes.dateAfterAndEquals
|
|
2360
|
+
}
|
|
2361
|
+
];
|
|
2362
|
+
return [
|
|
2363
|
+
...baseOptions,
|
|
2364
|
+
...isCollection ? getNullableCollection(isLanguagePtBr) : [],
|
|
2365
|
+
...isNullable ? getNullable(isLanguagePtBr) : []
|
|
2366
|
+
];
|
|
2367
|
+
};
|
|
2368
|
+
var getDefaultFilterMatchOptionsEnum = (isLanguagePtBr, isNullable = true, isCollection = false) => {
|
|
2369
|
+
const baseOptions = [
|
|
2370
|
+
{
|
|
2371
|
+
label: isLanguagePtBr ? "Igual" : "Equals",
|
|
2372
|
+
value: FilterMatchMode4.EQUALS
|
|
2373
|
+
},
|
|
2374
|
+
{
|
|
2375
|
+
label: isLanguagePtBr ? "Diferente" : "Not equals",
|
|
2376
|
+
value: FilterMatchMode4.NOT_EQUALS
|
|
2377
|
+
}
|
|
2378
|
+
];
|
|
2379
|
+
return [
|
|
2380
|
+
...baseOptions,
|
|
2381
|
+
...isCollection ? getNullableCollection(isLanguagePtBr) : [],
|
|
2382
|
+
...isNullable ? getNullable(isLanguagePtBr) : []
|
|
2383
|
+
];
|
|
2384
|
+
};
|
|
2385
|
+
var getNullable = (isLanguagePtBr) => [
|
|
2386
|
+
{
|
|
2387
|
+
label: isLanguagePtBr ? "Vazio" : "Empty",
|
|
2388
|
+
value: customMatchModes.empty
|
|
2389
|
+
},
|
|
2390
|
+
{
|
|
2391
|
+
label: isLanguagePtBr ? "N\xE3o Vazio" : "NotEmpty",
|
|
2392
|
+
value: customMatchModes.notEmpty
|
|
2393
|
+
}
|
|
2394
|
+
];
|
|
2395
|
+
var getNullableCollection = (isLanguagePtBr) => [
|
|
2396
|
+
{
|
|
2397
|
+
label: isLanguagePtBr ? "Algum" : "Any",
|
|
2398
|
+
value: customMatchModes.any
|
|
2399
|
+
},
|
|
2400
|
+
{
|
|
2401
|
+
label: isLanguagePtBr ? "Nenhum" : "None",
|
|
2402
|
+
value: customMatchModes.none
|
|
2403
|
+
}
|
|
2404
|
+
];
|
|
2285
2405
|
|
|
2286
2406
|
// src/index.tsx
|
|
2287
2407
|
import { FilterMatchMode as FilterMatchMode5, FilterOperator as FilterOperator2 } from "primereact/api";
|
|
@@ -2311,6 +2431,8 @@ export {
|
|
|
2311
2431
|
getDefaultFilterMatchOptionsString,
|
|
2312
2432
|
getDefaultFilterMatchOptionsStringArray,
|
|
2313
2433
|
getNullable,
|
|
2434
|
+
getNullableCollection,
|
|
2314
2435
|
getUrlParams,
|
|
2436
|
+
isSpecialMatchMode,
|
|
2315
2437
|
mapPrimeToBackendFilters
|
|
2316
2438
|
};
|