@charlesgomes/leafcode-shared-lib-react 1.0.83 → 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.js CHANGED
@@ -55,7 +55,9 @@ __export(index_exports, {
55
55
  getDefaultFilterMatchOptionsString: () => getDefaultFilterMatchOptionsString,
56
56
  getDefaultFilterMatchOptionsStringArray: () => getDefaultFilterMatchOptionsStringArray,
57
57
  getNullable: () => getNullable,
58
+ getNullableCollection: () => getNullableCollection,
58
59
  getUrlParams: () => getUrlParams,
60
+ isSpecialMatchMode: () => isSpecialMatchMode,
59
61
  mapPrimeToBackendFilters: () => mapPrimeToBackendFilters
60
62
  });
61
63
  module.exports = __toCommonJS(index_exports);
@@ -1195,7 +1197,7 @@ function DynamicColumns({
1195
1197
  size: "small",
1196
1198
  onClick: () => {
1197
1199
  const constraint = options.filterModel.constraints[0];
1198
- if (constraint.matchMode === "empty" || constraint.matchMode === "notEmpty") {
1200
+ if (constraint.matchMode === "empty" || constraint.matchMode === "notEmpty" || constraint.matchMode !== "any" || constraint.matchMode !== "none") {
1199
1201
  constraint.value = true;
1200
1202
  }
1201
1203
  options.filterApplyCallback(constraint.value, 0);
@@ -1759,271 +1761,9 @@ function DataTableAdvancedFilter({
1759
1761
  // src/components/DataTableAdvancedFilter/FilterTemplates.tsx
1760
1762
  var import_react_select2 = __toESM(require("react-select"));
1761
1763
  var import_moment2 = __toESM(require("moment"));
1762
- var import_jsx_runtime18 = require("react/jsx-runtime");
1763
- var DateFilterTemplate = (options, mask) => {
1764
- const matchMode = options.filterModel?.matchMode;
1765
- const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
1766
- const parsedValue = typeof options.filterModel?.value === "string" ? /* @__PURE__ */ new Date(options.filterModel.value + "T00:00:00") : null;
1767
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1768
- import_calendar.Calendar,
1769
- {
1770
- value: parsedValue,
1771
- onChange: (e) => {
1772
- const date = e.value;
1773
- if (!date) {
1774
- options.filterCallback(null, options.index);
1775
- return;
1776
- }
1777
- const valueToFilter = mask ? mask(date) : `${date.getFullYear()}-${String(
1778
- date.getMonth() + 1
1779
- ).padStart(2, "0")}-${String(
1780
- date.getDate()
1781
- ).padStart(2, "0")}`;
1782
- options.filterCallback(valueToFilter, options.index);
1783
- },
1784
- dateFormat: "dd/mm/yy",
1785
- placeholder: "dd/mm/yyyy",
1786
- mask: "99/99/9999",
1787
- inputClassName: "p-column-filter"
1788
- }
1789
- ) });
1790
- };
1791
- var DateTimeFilterTemplate = (options, mask) => {
1792
- const matchMode = options.filterModel?.matchMode;
1793
- const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
1794
- const value = options.filterModel?.value ? (0, import_moment2.default)(options.filterModel.value).toDate() : null;
1795
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1796
- import_calendar.Calendar,
1797
- {
1798
- value,
1799
- showTime: true,
1800
- showSeconds: true,
1801
- hourFormat: "24",
1802
- dateFormat: "dd/mm/yy",
1803
- placeholder: "dd/mm/yyyy 00:00:00",
1804
- readOnlyInput: true,
1805
- inputClassName: "p-column-filter",
1806
- onChange: (e) => {
1807
- const selectedDate = e.value;
1808
- if (!selectedDate) {
1809
- options.filterCallback(null, options.index);
1810
- return;
1811
- }
1812
- const formatted = mask ? mask(selectedDate) : (0, import_moment2.default)(selectedDate).utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
1813
- options.filterCallback(formatted, options.index);
1814
- }
1815
- }
1816
- ) });
1817
- };
1818
- var ValueFilterTemplate = (options, mask) => {
1819
- const parsedValue = options.value !== null && options.value !== void 0 ? centsToReal(options.value) : null;
1820
- const handleChange = (e) => {
1821
- const rawValue = e.value;
1822
- if (rawValue === null || rawValue === void 0) {
1823
- options.filterCallback(null, options.index);
1824
- return;
1825
- }
1826
- const valueToFilter = mask ? mask(rawValue) : rawValue;
1827
- options.filterCallback(String(valueToFilter), options.index);
1828
- };
1829
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1830
- import_inputnumber.InputNumber,
1831
- {
1832
- value: parsedValue,
1833
- placeholder: "R$ 0,00",
1834
- onValueChange: handleChange,
1835
- mode: "currency",
1836
- currency: "BRL",
1837
- locale: "pt-BR",
1838
- inputClassName: "custom-input"
1839
- }
1840
- );
1841
- };
1842
- var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
1843
- const selectOptions = items.length > 0 ? items : [
1844
- { label: isLanguagePtBr ? "Sim" : "Yes", value: true },
1845
- { label: isLanguagePtBr ? "N\xE3o" : "No", value: false }
1846
- ];
1847
- const matchMode = options.filterModel?.matchMode;
1848
- const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
1849
- const currentValue = selectOptions.find(
1850
- (opt) => opt.value === options.filterModel?.value
1851
- ) || null;
1852
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1853
- import_react_select2.default,
1854
- {
1855
- options: selectOptions,
1856
- value: currentValue,
1857
- onChange: (selected) => {
1858
- options.filterCallback(
1859
- selected ? selected.value : null,
1860
- options.index
1861
- // 🔥 ESSENCIAL
1862
- );
1863
- },
1864
- placeholder: isLanguagePtBr ? "Selecione..." : "Select...",
1865
- isClearable: true,
1866
- isSearchable: false,
1867
- className: "custom-select-filtro",
1868
- classNamePrefix: "custom-select-filtro"
1869
- }
1870
- ) });
1871
- };
1872
- var CustomFilterElement = (options, isLanguagePtBr = true) => {
1873
- const matchMode = options.filterModel?.matchMode;
1874
- const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
1875
- return !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1876
- import_inputtext.InputText,
1877
- {
1878
- value: options.filterModel?.value ?? "",
1879
- placeholder: isLanguagePtBr ? "Pesquisar" : "Search",
1880
- onChange: (e) => {
1881
- options.filterCallback(
1882
- e.target.value || null,
1883
- options.index
1884
- );
1885
- },
1886
- className: "p-column-filter"
1887
- }
1888
- );
1889
- };
1890
-
1891
- // src/components/DataTableAdvancedFilter/filterModes.ts
1892
- var import_api3 = require("primereact/api");
1893
- var customMatchModes = {
1894
- notStartsWith: "notStartsWith",
1895
- notEndsWith: "notEndsWith",
1896
- empty: "empty",
1897
- notEmpty: "notEmpty",
1898
- dateBeforeAndEquals: "dateBeforeAndEquals",
1899
- dateAfterAndEquals: "dateAfterAndEquals"
1900
- };
1901
- var getDefaultFilterMatchOptionsString = (isLanguagePtBr = true, isNullable = true) => {
1902
- const baseOptions = [
1903
- {
1904
- label: isLanguagePtBr ? "Cont\xE9m" : "Contains",
1905
- value: import_api3.FilterMatchMode.CONTAINS
1906
- },
1907
- {
1908
- label: isLanguagePtBr ? "N\xE3o cont\xE9m" : "Does not contain",
1909
- value: import_api3.FilterMatchMode.NOT_CONTAINS
1910
- },
1911
- {
1912
- label: isLanguagePtBr ? "Igual" : "Equals",
1913
- value: import_api3.FilterMatchMode.EQUALS
1914
- },
1915
- {
1916
- label: isLanguagePtBr ? "Diferente" : "Not equals",
1917
- value: import_api3.FilterMatchMode.NOT_EQUALS
1918
- },
1919
- {
1920
- label: isLanguagePtBr ? "Come\xE7a com" : "Starts with",
1921
- value: import_api3.FilterMatchMode.STARTS_WITH
1922
- },
1923
- {
1924
- label: isLanguagePtBr ? "N\xE3o come\xE7a com" : "Does not start with",
1925
- value: customMatchModes.notStartsWith
1926
- },
1927
- {
1928
- label: isLanguagePtBr ? "Termina com" : "Ends with",
1929
- value: import_api3.FilterMatchMode.ENDS_WITH
1930
- },
1931
- {
1932
- label: isLanguagePtBr ? "N\xE3o termina com" : "Does not end with",
1933
- value: customMatchModes.notEndsWith
1934
- }
1935
- ];
1936
- return isNullable ? [...baseOptions, ...getNullable(isLanguagePtBr)] : baseOptions;
1937
- };
1938
- var getDefaultFilterMatchOptionsNumber = (isLanguagePtBr = true, isNullable = true) => {
1939
- const baseOptions = [
1940
- {
1941
- label: isLanguagePtBr ? "Igual" : "Equals",
1942
- value: import_api3.FilterMatchMode.EQUALS
1943
- },
1944
- {
1945
- label: isLanguagePtBr ? "Diferente" : "Not equals",
1946
- value: import_api3.FilterMatchMode.NOT_EQUALS
1947
- },
1948
- {
1949
- label: isLanguagePtBr ? "Menor que" : "Less than",
1950
- value: import_api3.FilterMatchMode.LESS_THAN
1951
- },
1952
- {
1953
- label: isLanguagePtBr ? "Menor ou igual a" : "Less than or equal to",
1954
- value: import_api3.FilterMatchMode.LESS_THAN_OR_EQUAL_TO
1955
- },
1956
- {
1957
- label: isLanguagePtBr ? "Maior que" : "Greater than",
1958
- value: import_api3.FilterMatchMode.GREATER_THAN
1959
- },
1960
- {
1961
- label: isLanguagePtBr ? "Maior ou igual a" : "Greater than or equal to",
1962
- value: import_api3.FilterMatchMode.GREATER_THAN_OR_EQUAL_TO
1963
- }
1964
- ];
1965
- return isNullable ? [...baseOptions, ...getNullable(isLanguagePtBr)] : baseOptions;
1966
- };
1967
- var getDefaultFilterMatchOptionsStringArray = (isLanguagePtBr = true, isNullable = true) => {
1968
- const baseOptions = [
1969
- {
1970
- label: isLanguagePtBr ? "Cont\xE9m" : "Contains",
1971
- value: import_api3.FilterMatchMode.CONTAINS
1972
- },
1973
- {
1974
- label: isLanguagePtBr ? "N\xE3o cont\xE9m" : "Does not contain",
1975
- value: import_api3.FilterMatchMode.NOT_CONTAINS
1976
- }
1977
- ];
1978
- return isNullable ? [...baseOptions, ...getNullable(isLanguagePtBr)] : baseOptions;
1979
- };
1980
- var getDefaultFilterMatchOptionsDate = (isLanguagePtBr, isNullable = true) => {
1981
- const baseOptions = [
1982
- {
1983
- label: isLanguagePtBr ? "Data anterior a" : "Date before",
1984
- value: import_api3.FilterMatchMode.DATE_BEFORE
1985
- },
1986
- {
1987
- label: isLanguagePtBr ? "Data anterior ou igual a" : "Date prior to or equal to",
1988
- value: customMatchModes.dateBeforeAndEquals
1989
- },
1990
- {
1991
- label: isLanguagePtBr ? "Data posterior a" : "Date after",
1992
- value: import_api3.FilterMatchMode.DATE_AFTER
1993
- },
1994
- {
1995
- label: isLanguagePtBr ? "Data posterior ou igual a" : "Date later than or equal to",
1996
- value: customMatchModes.dateAfterAndEquals
1997
- }
1998
- ];
1999
- return isNullable ? [...baseOptions, ...getNullable(isLanguagePtBr)] : baseOptions;
2000
- };
2001
- var getDefaultFilterMatchOptionsEnum = (isLanguagePtBr, isNullable = true) => {
2002
- const baseOptions = [
2003
- {
2004
- label: isLanguagePtBr ? "Igual" : "Equals",
2005
- value: import_api3.FilterMatchMode.EQUALS
2006
- },
2007
- {
2008
- label: isLanguagePtBr ? "Diferente" : "Not equals",
2009
- value: import_api3.FilterMatchMode.NOT_EQUALS
2010
- }
2011
- ];
2012
- return isNullable ? [...baseOptions, ...getNullable(isLanguagePtBr)] : baseOptions;
2013
- };
2014
- var getNullable = (isLanguagePtBr) => [
2015
- {
2016
- label: isLanguagePtBr ? "Vazio" : "Empty",
2017
- value: customMatchModes.empty
2018
- },
2019
- {
2020
- label: isLanguagePtBr ? "N\xE3o Vazio" : "NotEmpty",
2021
- value: customMatchModes.notEmpty
2022
- }
2023
- ];
2024
1764
 
2025
1765
  // src/components/DataTableAdvancedFilter/utils/DataTableUtils.tsx
2026
- var import_api4 = require("primereact/api");
1766
+ var import_api3 = require("primereact/api");
2027
1767
  var mapMatchMode = (mode) => {
2028
1768
  switch (mode) {
2029
1769
  case "startsWith":
@@ -2056,6 +1796,12 @@ var mapMatchMode = (mode) => {
2056
1796
  };
2057
1797
  var buildFilterPayload = (fieldName, matchMode, rawValue) => {
2058
1798
  const normalized = normalizeFilterValue(rawValue);
1799
+ if (matchMode === "any") {
1800
+ return { __collectionOperator: "any" };
1801
+ }
1802
+ if (matchMode === "none") {
1803
+ return { __collectionOperator: "none" };
1804
+ }
2059
1805
  if (matchMode === "empty") {
2060
1806
  return {
2061
1807
  field: fieldName,
@@ -2171,7 +1917,13 @@ var mapPrimeToBackendFilters = (filters, globalFilterFields) => {
2171
1917
  }
2172
1918
  return;
2173
1919
  }
2174
- const constraints = Array.isArray(config.constraints) ? config.constraints.filter((c) => normalizeFilterValue(c.value) !== null || normalizeFilterValue(c.value) === "__NULL__") : [];
1920
+ const constraints = Array.isArray(config.constraints) ? config.constraints.filter((c) => {
1921
+ if (isSpecialMatchMode(c.matchMode)) {
1922
+ return true;
1923
+ }
1924
+ const normalized = normalizeFilterValue(c.value);
1925
+ return normalized !== null || normalized === "__NULL__";
1926
+ }) : [];
2175
1927
  if (!constraints.length) return;
2176
1928
  const colOperator = config.operator === "or" ? "or" : "and";
2177
1929
  if (config.collection === "campos" && config.fieldId) {
@@ -2190,6 +1942,18 @@ var mapPrimeToBackendFilters = (filters, globalFilterFields) => {
2190
1942
  ).filter(Boolean);
2191
1943
  if (!columnPayloads.length) return;
2192
1944
  if (config.collection) {
1945
+ const collectionExistence = columnPayloads.find(
1946
+ (p) => p.__collectionOperator
1947
+ );
1948
+ if (collectionExistence) {
1949
+ const rootNode = buildCollectionExistenceNode(config.collection);
1950
+ if (collectionExistence.__collectionOperator === "none") {
1951
+ finalAnd.push({ not: rootNode });
1952
+ } else {
1953
+ finalAnd.push(rootNode);
1954
+ }
1955
+ return;
1956
+ }
2193
1957
  const rootCollections = [];
2194
1958
  columnPayloads.forEach((payload) => {
2195
1959
  pushIntoCollectionTree(
@@ -2222,6 +1986,7 @@ function pushIntoCollectionTree(root, collectionPath, fieldName, payloadBase) {
2222
1986
  const collections = collectionPath.split(".");
2223
1987
  let current = root;
2224
1988
  collections.forEach((collection) => {
1989
+ var _a;
2225
1990
  let node = current.find(
2226
1991
  (n) => n.collection === collection && n.any
2227
1992
  );
@@ -2232,6 +1997,8 @@ function pushIntoCollectionTree(root, collectionPath, fieldName, payloadBase) {
2232
1997
  };
2233
1998
  current.push(node);
2234
1999
  }
2000
+ node.any ?? (node.any = {});
2001
+ (_a = node.any).or ?? (_a.or = []);
2235
2002
  current = node.any.or;
2236
2003
  });
2237
2004
  current.push({
@@ -2243,15 +2010,15 @@ function getMatchModeByTipo(tipo) {
2243
2010
  switch (tipo) {
2244
2011
  case "NumeroInteiro":
2245
2012
  case "NumeroDecimal":
2246
- return import_api4.FilterMatchMode.EQUALS;
2013
+ return import_api3.FilterMatchMode.EQUALS;
2247
2014
  default:
2248
- return import_api4.FilterMatchMode.CONTAINS;
2015
+ return import_api3.FilterMatchMode.CONTAINS;
2249
2016
  }
2250
2017
  }
2251
2018
  function buildDynamicCampoFilters(campos) {
2252
2019
  return campos?.reduce((acc, campo) => {
2253
2020
  acc[`${campo.id}`] = {
2254
- operator: import_api4.FilterOperator.AND,
2021
+ operator: import_api3.FilterOperator.AND,
2255
2022
  constraints: [
2256
2023
  {
2257
2024
  value: null,
@@ -2266,6 +2033,27 @@ function buildDynamicCampoFilters(campos) {
2266
2033
  return acc;
2267
2034
  }, {});
2268
2035
  }
2036
+ function buildCollectionExistenceNode(collectionPath) {
2037
+ const collections = collectionPath.split(".");
2038
+ let root = null;
2039
+ let current = null;
2040
+ collections.forEach((collection) => {
2041
+ const node = {
2042
+ collection,
2043
+ any: {}
2044
+ };
2045
+ if (!root) {
2046
+ root = node;
2047
+ } else {
2048
+ if (!current.any.or) {
2049
+ current.any.or = [];
2050
+ }
2051
+ current.any.or.push(node);
2052
+ }
2053
+ current = node;
2054
+ });
2055
+ return root;
2056
+ }
2269
2057
  var getUrlParams = (sortFieldInitial, sortOrderInitial) => {
2270
2058
  const params = new URLSearchParams(
2271
2059
  typeof window !== "undefined" ? window.location.search : ""
@@ -2335,6 +2123,337 @@ function resolveMatchMode(constraintMatchMode, rawValue) {
2335
2123
  }
2336
2124
  return constraintMatchMode;
2337
2125
  }
2126
+ var SPECIAL_MATCH_MODES = /* @__PURE__ */ new Set([
2127
+ "empty",
2128
+ "notEmpty",
2129
+ "any",
2130
+ "none"
2131
+ ]);
2132
+ var isSpecialMatchMode = (matchMode) => !!matchMode && SPECIAL_MATCH_MODES.has(matchMode);
2133
+
2134
+ // src/components/DataTableAdvancedFilter/FilterTemplates.tsx
2135
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2136
+ var DateFilterTemplate = (options, mask) => {
2137
+ const matchMode = options.filterModel?.matchMode;
2138
+ const value = options.filterModel?.value;
2139
+ const isSpecial = isSpecialMatchMode(matchMode);
2140
+ if (!isSpecial && value === true) {
2141
+ options.filterCallback(
2142
+ "",
2143
+ options.index
2144
+ );
2145
+ }
2146
+ const parsedValue = typeof options.filterModel?.value === "string" ? /* @__PURE__ */ new Date(options.filterModel.value + "T00:00:00") : null;
2147
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2148
+ import_calendar.Calendar,
2149
+ {
2150
+ value: parsedValue,
2151
+ onChange: (e) => {
2152
+ const date = e.value;
2153
+ if (!date) {
2154
+ options.filterCallback(null, options.index);
2155
+ return;
2156
+ }
2157
+ const valueToFilter = mask ? mask(date) : `${date.getFullYear()}-${String(
2158
+ date.getMonth() + 1
2159
+ ).padStart(2, "0")}-${String(
2160
+ date.getDate()
2161
+ ).padStart(2, "0")}`;
2162
+ options.filterCallback(valueToFilter, options.index);
2163
+ },
2164
+ dateFormat: "dd/mm/yy",
2165
+ placeholder: "dd/mm/yyyy",
2166
+ mask: "99/99/9999",
2167
+ inputClassName: "p-column-filter"
2168
+ }
2169
+ ) });
2170
+ };
2171
+ var DateTimeFilterTemplate = (options, mask) => {
2172
+ const matchMode = options.filterModel?.matchMode;
2173
+ const value = options.filterModel?.value ? (0, import_moment2.default)(options.filterModel.value).toDate() : null;
2174
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecialMatchMode(matchMode) && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2175
+ import_calendar.Calendar,
2176
+ {
2177
+ value,
2178
+ showTime: true,
2179
+ showSeconds: true,
2180
+ hourFormat: "24",
2181
+ dateFormat: "dd/mm/yy",
2182
+ placeholder: "dd/mm/yyyy 00:00:00",
2183
+ readOnlyInput: true,
2184
+ inputClassName: "p-column-filter",
2185
+ onChange: (e) => {
2186
+ const selectedDate = e.value;
2187
+ if (!selectedDate) {
2188
+ options.filterCallback(null, options.index);
2189
+ return;
2190
+ }
2191
+ const formatted = mask ? mask(selectedDate) : (0, import_moment2.default)(selectedDate).utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
2192
+ options.filterCallback(formatted, options.index);
2193
+ }
2194
+ }
2195
+ ) });
2196
+ };
2197
+ var ValueFilterTemplate = (options, mask) => {
2198
+ const parsedValue = options.value !== null && options.value !== void 0 ? centsToReal(options.value) : null;
2199
+ const handleChange = (e) => {
2200
+ const rawValue = e.value;
2201
+ if (rawValue === null || rawValue === void 0) {
2202
+ options.filterCallback(null, options.index);
2203
+ return;
2204
+ }
2205
+ const valueToFilter = mask ? mask(rawValue) : rawValue;
2206
+ options.filterCallback(String(valueToFilter), options.index);
2207
+ };
2208
+ const matchMode = options.filterModel?.matchMode;
2209
+ const value = options.filterModel?.value;
2210
+ const isSpecial = isSpecialMatchMode(matchMode);
2211
+ if (!isSpecial && value === true) {
2212
+ options.filterCallback(
2213
+ "",
2214
+ options.index
2215
+ );
2216
+ }
2217
+ return !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2218
+ import_inputnumber.InputNumber,
2219
+ {
2220
+ value: parsedValue,
2221
+ placeholder: "R$ 0,00",
2222
+ onValueChange: handleChange,
2223
+ mode: "currency",
2224
+ currency: "BRL",
2225
+ locale: "pt-BR",
2226
+ inputClassName: "custom-input"
2227
+ }
2228
+ );
2229
+ };
2230
+ var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
2231
+ const selectOptions = items.length > 0 ? items : [
2232
+ { label: isLanguagePtBr ? "Sim" : "Yes", value: true },
2233
+ { label: isLanguagePtBr ? "N\xE3o" : "No", value: false }
2234
+ ];
2235
+ const matchMode = options.filterModel?.matchMode;
2236
+ const value = options.filterModel?.value;
2237
+ const isSpecial = isSpecialMatchMode(matchMode);
2238
+ if (!isSpecial && value === true) {
2239
+ options.filterCallback(
2240
+ "",
2241
+ options.index
2242
+ );
2243
+ }
2244
+ const currentValue = selectOptions.find(
2245
+ (opt) => opt.value === options.filterModel?.value
2246
+ ) || null;
2247
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2248
+ import_react_select2.default,
2249
+ {
2250
+ options: selectOptions,
2251
+ value: currentValue,
2252
+ onChange: (selected) => {
2253
+ options.filterCallback(
2254
+ selected ? selected.value : null,
2255
+ options.index
2256
+ );
2257
+ },
2258
+ placeholder: isLanguagePtBr ? "Selecione..." : "Select...",
2259
+ isClearable: true,
2260
+ isSearchable: false,
2261
+ className: "custom-select-filtro",
2262
+ classNamePrefix: "custom-select-filtro"
2263
+ }
2264
+ ) });
2265
+ };
2266
+ var CustomFilterElement = (options, isLanguagePtBr = true) => {
2267
+ const matchMode = options.filterModel?.matchMode;
2268
+ const value = options.filterModel?.value;
2269
+ const isSpecial = isSpecialMatchMode(matchMode);
2270
+ if (!isSpecial && value === true) {
2271
+ options.filterCallback(
2272
+ "",
2273
+ options.index
2274
+ );
2275
+ }
2276
+ return !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2277
+ import_inputtext.InputText,
2278
+ {
2279
+ value: options.filterModel?.value ?? "",
2280
+ placeholder: isLanguagePtBr ? "Pesquisar" : "Search",
2281
+ onChange: (e) => {
2282
+ options.filterCallback(
2283
+ e.target.value || null,
2284
+ options.index
2285
+ );
2286
+ },
2287
+ className: "p-column-filter"
2288
+ }
2289
+ );
2290
+ };
2291
+
2292
+ // src/components/DataTableAdvancedFilter/filterModes.ts
2293
+ var import_api4 = require("primereact/api");
2294
+ var customMatchModes = {
2295
+ notStartsWith: "notStartsWith",
2296
+ notEndsWith: "notEndsWith",
2297
+ empty: "empty",
2298
+ notEmpty: "notEmpty",
2299
+ dateBeforeAndEquals: "dateBeforeAndEquals",
2300
+ dateAfterAndEquals: "dateAfterAndEquals",
2301
+ any: "any",
2302
+ none: "none"
2303
+ };
2304
+ var getDefaultFilterMatchOptionsString = (isLanguagePtBr = true, isNullable = true, isCollection = false) => {
2305
+ const baseOptions = [
2306
+ {
2307
+ label: isLanguagePtBr ? "Cont\xE9m" : "Contains",
2308
+ value: import_api4.FilterMatchMode.CONTAINS
2309
+ },
2310
+ {
2311
+ label: isLanguagePtBr ? "N\xE3o cont\xE9m" : "Does not contain",
2312
+ value: import_api4.FilterMatchMode.NOT_CONTAINS
2313
+ },
2314
+ {
2315
+ label: isLanguagePtBr ? "Igual" : "Equals",
2316
+ value: import_api4.FilterMatchMode.EQUALS
2317
+ },
2318
+ {
2319
+ label: isLanguagePtBr ? "Diferente" : "Not equals",
2320
+ value: import_api4.FilterMatchMode.NOT_EQUALS
2321
+ },
2322
+ {
2323
+ label: isLanguagePtBr ? "Come\xE7a com" : "Starts with",
2324
+ value: import_api4.FilterMatchMode.STARTS_WITH
2325
+ },
2326
+ {
2327
+ label: isLanguagePtBr ? "N\xE3o come\xE7a com" : "Does not start with",
2328
+ value: customMatchModes.notStartsWith
2329
+ },
2330
+ {
2331
+ label: isLanguagePtBr ? "Termina com" : "Ends with",
2332
+ value: import_api4.FilterMatchMode.ENDS_WITH
2333
+ },
2334
+ {
2335
+ label: isLanguagePtBr ? "N\xE3o termina com" : "Does not end with",
2336
+ value: customMatchModes.notEndsWith
2337
+ }
2338
+ ];
2339
+ return [
2340
+ ...baseOptions,
2341
+ ...isCollection ? getNullableCollection(isLanguagePtBr) : [],
2342
+ ...isNullable ? getNullable(isLanguagePtBr) : []
2343
+ ];
2344
+ };
2345
+ var getDefaultFilterMatchOptionsNumber = (isLanguagePtBr = true, isNullable = true, isCollection = false) => {
2346
+ const baseOptions = [
2347
+ {
2348
+ label: isLanguagePtBr ? "Igual" : "Equals",
2349
+ value: import_api4.FilterMatchMode.EQUALS
2350
+ },
2351
+ {
2352
+ label: isLanguagePtBr ? "Diferente" : "Not equals",
2353
+ value: import_api4.FilterMatchMode.NOT_EQUALS
2354
+ },
2355
+ {
2356
+ label: isLanguagePtBr ? "Menor que" : "Less than",
2357
+ value: import_api4.FilterMatchMode.LESS_THAN
2358
+ },
2359
+ {
2360
+ label: isLanguagePtBr ? "Menor ou igual a" : "Less than or equal to",
2361
+ value: import_api4.FilterMatchMode.LESS_THAN_OR_EQUAL_TO
2362
+ },
2363
+ {
2364
+ label: isLanguagePtBr ? "Maior que" : "Greater than",
2365
+ value: import_api4.FilterMatchMode.GREATER_THAN
2366
+ },
2367
+ {
2368
+ label: isLanguagePtBr ? "Maior ou igual a" : "Greater than or equal to",
2369
+ value: import_api4.FilterMatchMode.GREATER_THAN_OR_EQUAL_TO
2370
+ }
2371
+ ];
2372
+ return [
2373
+ ...baseOptions,
2374
+ ...isCollection ? getNullableCollection(isLanguagePtBr) : [],
2375
+ ...isNullable ? getNullable(isLanguagePtBr) : []
2376
+ ];
2377
+ };
2378
+ var getDefaultFilterMatchOptionsStringArray = (isLanguagePtBr = true, isNullable = true, isCollection = false) => {
2379
+ const baseOptions = [
2380
+ {
2381
+ label: isLanguagePtBr ? "Cont\xE9m" : "Contains",
2382
+ value: import_api4.FilterMatchMode.CONTAINS
2383
+ },
2384
+ {
2385
+ label: isLanguagePtBr ? "N\xE3o cont\xE9m" : "Does not contain",
2386
+ value: import_api4.FilterMatchMode.NOT_CONTAINS
2387
+ }
2388
+ ];
2389
+ return [
2390
+ ...baseOptions,
2391
+ ...isCollection ? getNullableCollection(isLanguagePtBr) : [],
2392
+ ...isNullable ? getNullable(isLanguagePtBr) : []
2393
+ ];
2394
+ };
2395
+ var getDefaultFilterMatchOptionsDate = (isLanguagePtBr, isNullable = true, isCollection = false) => {
2396
+ const baseOptions = [
2397
+ {
2398
+ label: isLanguagePtBr ? "Data anterior a" : "Date before",
2399
+ value: import_api4.FilterMatchMode.DATE_BEFORE
2400
+ },
2401
+ {
2402
+ label: isLanguagePtBr ? "Data anterior ou igual a" : "Date prior to or equal to",
2403
+ value: customMatchModes.dateBeforeAndEquals
2404
+ },
2405
+ {
2406
+ label: isLanguagePtBr ? "Data posterior a" : "Date after",
2407
+ value: import_api4.FilterMatchMode.DATE_AFTER
2408
+ },
2409
+ {
2410
+ label: isLanguagePtBr ? "Data posterior ou igual a" : "Date later than or equal to",
2411
+ value: customMatchModes.dateAfterAndEquals
2412
+ }
2413
+ ];
2414
+ return [
2415
+ ...baseOptions,
2416
+ ...isCollection ? getNullableCollection(isLanguagePtBr) : [],
2417
+ ...isNullable ? getNullable(isLanguagePtBr) : []
2418
+ ];
2419
+ };
2420
+ var getDefaultFilterMatchOptionsEnum = (isLanguagePtBr, isNullable = true, isCollection = false) => {
2421
+ const baseOptions = [
2422
+ {
2423
+ label: isLanguagePtBr ? "Igual" : "Equals",
2424
+ value: import_api4.FilterMatchMode.EQUALS
2425
+ },
2426
+ {
2427
+ label: isLanguagePtBr ? "Diferente" : "Not equals",
2428
+ value: import_api4.FilterMatchMode.NOT_EQUALS
2429
+ }
2430
+ ];
2431
+ return [
2432
+ ...baseOptions,
2433
+ ...isCollection ? getNullableCollection(isLanguagePtBr) : [],
2434
+ ...isNullable ? getNullable(isLanguagePtBr) : []
2435
+ ];
2436
+ };
2437
+ var getNullable = (isLanguagePtBr) => [
2438
+ {
2439
+ label: isLanguagePtBr ? "Vazio" : "Empty",
2440
+ value: customMatchModes.empty
2441
+ },
2442
+ {
2443
+ label: isLanguagePtBr ? "N\xE3o Vazio" : "NotEmpty",
2444
+ value: customMatchModes.notEmpty
2445
+ }
2446
+ ];
2447
+ var getNullableCollection = (isLanguagePtBr) => [
2448
+ {
2449
+ label: isLanguagePtBr ? "Algum" : "Any",
2450
+ value: customMatchModes.any
2451
+ },
2452
+ {
2453
+ label: isLanguagePtBr ? "Nenhum" : "None",
2454
+ value: customMatchModes.none
2455
+ }
2456
+ ];
2338
2457
 
2339
2458
  // src/index.tsx
2340
2459
  var import_api5 = require("primereact/api");
@@ -2365,6 +2484,8 @@ var import_api5 = require("primereact/api");
2365
2484
  getDefaultFilterMatchOptionsString,
2366
2485
  getDefaultFilterMatchOptionsStringArray,
2367
2486
  getNullable,
2487
+ getNullableCollection,
2368
2488
  getUrlParams,
2489
+ isSpecialMatchMode,
2369
2490
  mapPrimeToBackendFilters
2370
2491
  });