@charlesgomes/leafcode-shared-lib-react 1.0.77 → 1.0.78

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 CHANGED
@@ -206,20 +206,11 @@ interface IItemProps {
206
206
  label: string;
207
207
  }
208
208
 
209
- type FilterMatchModeSelectProps = {
210
- options: any;
211
- items: {
212
- label: string;
213
- value: string;
214
- }[];
215
- placeholder?: string;
216
- };
217
- declare const FilterMatchModeSelect: ({ options, items, placeholder, }: FilterMatchModeSelectProps) => react_jsx_runtime.JSX.Element;
218
- declare const DateFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: any[], mask?: (value: Date) => string) => react_jsx_runtime.JSX.Element;
219
- declare const DateTimeFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, mask?: (date: Date) => string) => react_jsx_runtime.JSX.Element;
209
+ declare const DateFilterTemplate: (options: any, mask?: (value: Date) => string) => react_jsx_runtime.JSX.Element;
210
+ declare const DateTimeFilterTemplate: (options: any, mask?: (date: Date) => string) => react_jsx_runtime.JSX.Element;
220
211
  declare const ValueFilterTemplate: (options: any, mask?: (value: any) => string | number) => react_jsx_runtime.JSX.Element;
221
- declare const SelectFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: IItemProps[]) => react_jsx_runtime.JSX.Element;
222
- declare const CustomFilterElement: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: any[]) => react_jsx_runtime.JSX.Element;
212
+ declare const SelectFilterTemplate: (options: any, isLanguagePtBr?: boolean, items?: IItemProps[]) => react_jsx_runtime.JSX.Element;
213
+ declare const CustomFilterElement: (options: any, isLanguagePtBr?: boolean) => false | react_jsx_runtime.JSX.Element;
223
214
 
224
215
  declare const customMatchModes: {
225
216
  notStartsWith: string;
@@ -359,4 +350,4 @@ declare const LeafcodeThemeProvider: ({ children, theme, }: LeafcodeThemeProvide
359
350
 
360
351
  declare const defaultTheme: LeafcodeTheme;
361
352
 
362
- export { Button, type ColumnCustom, CustomFilterElement, DataTableAdvancedFilter, DateFilterTemplate, DateTimeFilterTemplate, FilterMatchModeSelect, type IDataTableProps, type IItemProps, Input, InputAutoComplete, type InputAutoCompleteProps, InputSelect, LeafcodeThemeProvider, ModalBase, type PaginatedResponse$1 as PaginatedResponse, SelectFilterTemplate, type ServiceParams, TextArea, ValueFilterTemplate, buildDynamicCampoFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getUrlParams, mapPrimeToBackendFilters };
353
+ export { Button, type ColumnCustom, CustomFilterElement, DataTableAdvancedFilter, DateFilterTemplate, DateTimeFilterTemplate, type IDataTableProps, type IItemProps, Input, InputAutoComplete, type InputAutoCompleteProps, InputSelect, LeafcodeThemeProvider, ModalBase, type PaginatedResponse$1 as PaginatedResponse, SelectFilterTemplate, type ServiceParams, TextArea, ValueFilterTemplate, buildDynamicCampoFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getUrlParams, mapPrimeToBackendFilters };
package/dist/index.d.ts CHANGED
@@ -206,20 +206,11 @@ interface IItemProps {
206
206
  label: string;
207
207
  }
208
208
 
209
- type FilterMatchModeSelectProps = {
210
- options: any;
211
- items: {
212
- label: string;
213
- value: string;
214
- }[];
215
- placeholder?: string;
216
- };
217
- declare const FilterMatchModeSelect: ({ options, items, placeholder, }: FilterMatchModeSelectProps) => react_jsx_runtime.JSX.Element;
218
- declare const DateFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: any[], mask?: (value: Date) => string) => react_jsx_runtime.JSX.Element;
219
- declare const DateTimeFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, mask?: (date: Date) => string) => react_jsx_runtime.JSX.Element;
209
+ declare const DateFilterTemplate: (options: any, mask?: (value: Date) => string) => react_jsx_runtime.JSX.Element;
210
+ declare const DateTimeFilterTemplate: (options: any, mask?: (date: Date) => string) => react_jsx_runtime.JSX.Element;
220
211
  declare const ValueFilterTemplate: (options: any, mask?: (value: any) => string | number) => react_jsx_runtime.JSX.Element;
221
- declare const SelectFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: IItemProps[]) => react_jsx_runtime.JSX.Element;
222
- declare const CustomFilterElement: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: any[]) => react_jsx_runtime.JSX.Element;
212
+ declare const SelectFilterTemplate: (options: any, isLanguagePtBr?: boolean, items?: IItemProps[]) => react_jsx_runtime.JSX.Element;
213
+ declare const CustomFilterElement: (options: any, isLanguagePtBr?: boolean) => false | react_jsx_runtime.JSX.Element;
223
214
 
224
215
  declare const customMatchModes: {
225
216
  notStartsWith: string;
@@ -359,4 +350,4 @@ declare const LeafcodeThemeProvider: ({ children, theme, }: LeafcodeThemeProvide
359
350
 
360
351
  declare const defaultTheme: LeafcodeTheme;
361
352
 
362
- export { Button, type ColumnCustom, CustomFilterElement, DataTableAdvancedFilter, DateFilterTemplate, DateTimeFilterTemplate, FilterMatchModeSelect, type IDataTableProps, type IItemProps, Input, InputAutoComplete, type InputAutoCompleteProps, InputSelect, LeafcodeThemeProvider, ModalBase, type PaginatedResponse$1 as PaginatedResponse, SelectFilterTemplate, type ServiceParams, TextArea, ValueFilterTemplate, buildDynamicCampoFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getUrlParams, mapPrimeToBackendFilters };
353
+ export { Button, type ColumnCustom, CustomFilterElement, DataTableAdvancedFilter, DateFilterTemplate, DateTimeFilterTemplate, type IDataTableProps, type IItemProps, Input, InputAutoComplete, type InputAutoCompleteProps, InputSelect, LeafcodeThemeProvider, ModalBase, type PaginatedResponse$1 as PaginatedResponse, SelectFilterTemplate, type ServiceParams, TextArea, ValueFilterTemplate, buildDynamicCampoFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getUrlParams, mapPrimeToBackendFilters };
package/dist/index.js CHANGED
@@ -36,7 +36,6 @@ __export(index_exports, {
36
36
  DateFilterTemplate: () => DateFilterTemplate,
37
37
  DateTimeFilterTemplate: () => DateTimeFilterTemplate,
38
38
  FilterMatchMode: () => import_api5.FilterMatchMode,
39
- FilterMatchModeSelect: () => FilterMatchModeSelect,
40
39
  FilterOperator: () => import_api5.FilterOperator,
41
40
  Input: () => Input,
42
41
  InputAutoComplete: () => InputAutoComplete,
@@ -1147,6 +1146,7 @@ function ActionsColumn({
1147
1146
  }
1148
1147
 
1149
1148
  // src/components/DataTableAdvancedFilter/DynamicColumns.tsx
1149
+ var import_button = require("primereact/button");
1150
1150
  var import_jsx_runtime15 = require("react/jsx-runtime");
1151
1151
  function DynamicColumns({
1152
1152
  columns,
@@ -1187,6 +1187,20 @@ function DynamicColumns({
1187
1187
  showFilterMatchModes: col.showFilterMatchModes,
1188
1188
  dataType: col.dataType,
1189
1189
  hidden: col.hidden,
1190
+ filterApply: (options) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1191
+ import_button.Button,
1192
+ {
1193
+ label: isLanguagePtBr ? "Aplicar" : "Apply",
1194
+ size: "small",
1195
+ onClick: () => {
1196
+ const constraint = options.filterModel.constraints[0];
1197
+ if (constraint.matchMode === "empty" || constraint.matchMode === "notEmpty") {
1198
+ constraint.value = true;
1199
+ }
1200
+ options.filterApplyCallback(constraint.value, 0);
1201
+ }
1202
+ }
1203
+ ),
1190
1204
  filterElement: col.filterElement ? (options) => col.filterElement?.(options, col.mask) ?? void 0 : void 0,
1191
1205
  filterMatchModeOptions: col.filterMatchModeOptions,
1192
1206
  filterPlaceholder: !isActionsCol ? placeholder : void 0,
@@ -1404,6 +1418,7 @@ function DataTableAdvancedFilterWrapper({
1404
1418
  customActions
1405
1419
  ]
1406
1420
  );
1421
+ const DEFAULT_MATCH_MODE = "contains";
1407
1422
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: isClient && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { children: [
1408
1423
  disablePagination && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "disablePagination", children: TableHeaderAndTableActions }),
1409
1424
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
@@ -1424,6 +1439,7 @@ function DataTableAdvancedFilterWrapper({
1424
1439
  dataKey: "id",
1425
1440
  size: "small",
1426
1441
  rowClassName: () => "box-row-table",
1442
+ filterDisplay: "menu",
1427
1443
  filters,
1428
1444
  selection: selectedRowsData,
1429
1445
  onSelectionChange: (e) => setSelectedRowsData(e.value),
@@ -1742,129 +1758,62 @@ function DataTableAdvancedFilter({
1742
1758
 
1743
1759
  // src/components/DataTableAdvancedFilter/FilterTemplates.tsx
1744
1760
  var import_react_select2 = __toESM(require("react-select"));
1745
- var import_dropdown = require("primereact/dropdown");
1746
1761
  var import_moment2 = __toESM(require("moment"));
1747
1762
  var import_jsx_runtime18 = require("react/jsx-runtime");
1748
- var FilterMatchModeSelect = ({
1749
- options,
1750
- items,
1751
- placeholder = "Tipo de filtro"
1752
- }) => {
1753
- const rawFilter = options.value ?? {};
1754
- const currentMatchMode = rawFilter.matchMode ?? items[0]?.value;
1755
- const isSpecial = (mode) => mode === customMatchModes.empty || mode === customMatchModes.notEmpty;
1756
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1757
- import_dropdown.Dropdown,
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,
1758
1769
  {
1759
- value: currentMatchMode,
1760
- options: items,
1761
- optionLabel: "label",
1762
- optionValue: "value",
1763
- placeholder,
1764
- style: { width: "100%" },
1770
+ value: parsedValue,
1765
1771
  onChange: (e) => {
1766
- const newMatchMode = e.value;
1767
- if (isSpecial(newMatchMode)) {
1768
- options.filterCallback({
1769
- text: null,
1770
- matchMode: newMatchMode
1771
- });
1772
+ const date = e.value;
1773
+ if (!date) {
1774
+ options.filterCallback(null, options.index);
1772
1775
  return;
1773
1776
  }
1774
- options.filterCallback({
1775
- text: null,
1776
- matchMode: newMatchMode
1777
- });
1778
- }
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"
1779
1788
  }
1780
- );
1781
- };
1782
- var DateFilterTemplate = (options, isLanguagePtBr = true, isNullable = true, items, mask) => {
1783
- const resolvedItems = items ?? getDefaultFilterMatchOptionsDate(isLanguagePtBr, isNullable);
1784
- const rawFilter = options.value ?? {};
1785
- const currentMatchMode = rawFilter.matchMode;
1786
- const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1787
- const parsedValue = options.value?.text && typeof options.value.text === "string" ? /* @__PURE__ */ new Date(options.value.text + "T00:00:00") : null;
1788
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1789
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1790
- FilterMatchModeSelect,
1791
- {
1792
- options,
1793
- items: resolvedItems
1794
- }
1795
- ),
1796
- !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1797
- import_calendar.Calendar,
1798
- {
1799
- value: parsedValue,
1800
- onChange: (e) => {
1801
- if (!e.value) {
1802
- options.filterCallback({
1803
- text: null,
1804
- matchMode: currentMatchMode
1805
- });
1806
- return;
1807
- }
1808
- const date = e.value;
1809
- const valueToFilter = mask ? mask(date) : `${date.getFullYear()}-${String(
1810
- date.getMonth() + 1
1811
- ).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
1812
- options.filterCallback({
1813
- text: valueToFilter,
1814
- matchMode: currentMatchMode
1815
- });
1816
- },
1817
- dateFormat: "dd/mm/yy",
1818
- placeholder: "dd/mm/yyyy",
1819
- mask: "99/99/9999",
1820
- inputClassName: "p-column-filter"
1821
- }
1822
- )
1823
- ] });
1789
+ ) });
1824
1790
  };
1825
- var DateTimeFilterTemplate = (options, isLanguagePtBr = true, isNullable = true, mask) => {
1826
- const items = getDefaultFilterMatchOptionsDate(isLanguagePtBr, isNullable);
1827
- const rawFilter = options.value ?? {};
1828
- const currentMatchMode = rawFilter.matchMode;
1829
- const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1830
- const value = typeof rawFilter.text === "string" ? (0, import_moment2.default)(rawFilter.text).toDate() : null;
1831
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1832
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1833
- FilterMatchModeSelect,
1834
- {
1835
- options,
1836
- items
1837
- }
1838
- ),
1839
- !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1840
- import_calendar.Calendar,
1841
- {
1842
- value,
1843
- showTime: true,
1844
- showSeconds: true,
1845
- hourFormat: "24",
1846
- dateFormat: "dd/mm/yy",
1847
- placeholder: "dd/mm/yyyy 00:00:00",
1848
- readOnlyInput: true,
1849
- inputClassName: "p-column-filter",
1850
- onChange: (e) => {
1851
- const selectedDate = e.value;
1852
- if (!selectedDate) {
1853
- options.filterCallback({
1854
- text: null,
1855
- matchMode: currentMatchMode
1856
- });
1857
- return;
1858
- }
1859
- const formatted = mask ? mask(selectedDate) : (0, import_moment2.default)(selectedDate).utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
1860
- options.filterCallback({
1861
- text: formatted,
1862
- matchMode: currentMatchMode
1863
- });
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;
1864
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);
1865
1814
  }
1866
- )
1867
- ] });
1815
+ }
1816
+ ) });
1868
1817
  };
1869
1818
  var ValueFilterTemplate = (options, mask) => {
1870
1819
  const parsedValue = options.value !== null && options.value !== void 0 ? centsToReal(options.value) : null;
@@ -1890,115 +1839,53 @@ var ValueFilterTemplate = (options, mask) => {
1890
1839
  }
1891
1840
  );
1892
1841
  };
1893
- var SelectFilterTemplate = (options, isLanguagePtBr = true, isNullable = true, items = []) => {
1894
- const matchModeItems = getDefaultFilterMatchOptionsEnum(isLanguagePtBr, isNullable);
1842
+ var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
1895
1843
  const selectOptions = items.length > 0 ? items : [
1896
1844
  { label: isLanguagePtBr ? "Sim" : "Yes", value: true },
1897
1845
  { label: isLanguagePtBr ? "N\xE3o" : "No", value: false }
1898
1846
  ];
1899
- const rawFilter = options.value ?? {};
1900
- const currentMatchMode = rawFilter.matchMode;
1901
- const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1902
- const currentValue = selectOptions.find((opt) => opt.value === rawFilter.text) || null;
1903
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1904
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1905
- FilterMatchModeSelect,
1906
- {
1907
- options,
1908
- items: matchModeItems
1909
- }
1910
- ),
1911
- !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1912
- import_react_select2.default,
1913
- {
1914
- options: selectOptions,
1915
- value: currentValue,
1916
- onChange: (selected) => {
1917
- if (!selected) {
1918
- options.filterCallback({
1919
- text: null,
1920
- matchMode: currentMatchMode
1921
- });
1922
- return;
1923
- }
1924
- options.filterCallback({
1925
- text: selected.value,
1926
- matchMode: currentMatchMode
1927
- });
1928
- },
1929
- placeholder: isLanguagePtBr ? "Selecione..." : "Select...",
1930
- isClearable: false,
1931
- isSearchable: false,
1932
- className: "custom-select-filtro",
1933
- classNamePrefix: "custom-select-filtro",
1934
- styles: {
1935
- control: (baseStyles, state) => ({
1936
- ...baseStyles,
1937
- "&:hover": {
1938
- borderColor: state.isFocused ? "#094394" : ""
1939
- },
1940
- borderRadius: "6px"
1941
- }),
1942
- menuList: (base) => ({
1943
- ...base,
1944
- "::-webkit-scrollbar": {
1945
- width: "6px"
1946
- },
1947
- "::-webkit-scrollbar-track": {
1948
- background: "#fff"
1949
- },
1950
- "::-webkit-scrollbar-thumb": {
1951
- background: "#888",
1952
- borderRadius: "2rem"
1953
- },
1954
- "::-webkit-scrollbar-thumb:hover": {
1955
- background: "#555"
1956
- }
1957
- }),
1958
- option: (provided, state) => ({
1959
- ...provided,
1960
- backgroundColor: state.isFocused ? "#094394" : "#ffffff",
1961
- color: state.isFocused ? "#ffffff" : "black",
1962
- "&:hover": {
1963
- backgroundColor: "#094394",
1964
- color: "#ffffff"
1965
- }
1966
- })
1967
- }
1968
- }
1969
- )
1970
- ] });
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
+ ) });
1971
1871
  };
1972
- var CustomFilterElement = (options, isLanguagePtBr = true, isNullable = true, items) => {
1973
- const resolvedItems = items ?? getDefaultFilterMatchOptionsString(isLanguagePtBr, isNullable);
1974
- const rawFilter = options.value ?? {};
1975
- const currentMatchMode = rawFilter.matchMode ?? "contains";
1976
- const currentValue = typeof rawFilter.text === "string" ? rawFilter.text : "";
1977
- const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1978
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "filter-wrapper", style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1979
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1980
- FilterMatchModeSelect,
1981
- {
1982
- options,
1983
- items: resolvedItems
1984
- }
1985
- ),
1986
- !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1987
- import_inputtext.InputText,
1988
- {
1989
- value: currentValue,
1990
- placeholder: isLanguagePtBr ? "Pesquisar" : "Search",
1991
- className: "p-column-filter",
1992
- onChange: (e) => {
1993
- const value = e.target.value;
1994
- options.filterCallback({
1995
- text: value.trim() ? value : null,
1996
- matchMode: currentMatchMode
1997
- });
1998
- }
1999
- }
2000
- )
2001
- ] });
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
+ );
2002
1889
  };
2003
1890
 
2004
1891
  // src/components/DataTableAdvancedFilter/filterModes.ts
@@ -2427,7 +2314,6 @@ var import_api5 = require("primereact/api");
2427
2314
  DateFilterTemplate,
2428
2315
  DateTimeFilterTemplate,
2429
2316
  FilterMatchMode,
2430
- FilterMatchModeSelect,
2431
2317
  FilterOperator,
2432
2318
  Input,
2433
2319
  InputAutoComplete,
package/dist/index.mjs CHANGED
@@ -1097,6 +1097,7 @@ function ActionsColumn({
1097
1097
  }
1098
1098
 
1099
1099
  // src/components/DataTableAdvancedFilter/DynamicColumns.tsx
1100
+ import { Button as Button2 } from "primereact/button";
1100
1101
  import { jsx as jsx15 } from "react/jsx-runtime";
1101
1102
  function DynamicColumns({
1102
1103
  columns,
@@ -1137,6 +1138,20 @@ function DynamicColumns({
1137
1138
  showFilterMatchModes: col.showFilterMatchModes,
1138
1139
  dataType: col.dataType,
1139
1140
  hidden: col.hidden,
1141
+ filterApply: (options) => /* @__PURE__ */ jsx15(
1142
+ Button2,
1143
+ {
1144
+ label: isLanguagePtBr ? "Aplicar" : "Apply",
1145
+ size: "small",
1146
+ onClick: () => {
1147
+ const constraint = options.filterModel.constraints[0];
1148
+ if (constraint.matchMode === "empty" || constraint.matchMode === "notEmpty") {
1149
+ constraint.value = true;
1150
+ }
1151
+ options.filterApplyCallback(constraint.value, 0);
1152
+ }
1153
+ }
1154
+ ),
1140
1155
  filterElement: col.filterElement ? (options) => col.filterElement?.(options, col.mask) ?? void 0 : void 0,
1141
1156
  filterMatchModeOptions: col.filterMatchModeOptions,
1142
1157
  filterPlaceholder: !isActionsCol ? placeholder : void 0,
@@ -1354,6 +1369,7 @@ function DataTableAdvancedFilterWrapper({
1354
1369
  customActions
1355
1370
  ]
1356
1371
  );
1372
+ const DEFAULT_MATCH_MODE = "contains";
1357
1373
  return /* @__PURE__ */ jsx16(Fragment6, { children: isClient && /* @__PURE__ */ jsxs11("div", { children: [
1358
1374
  disablePagination && /* @__PURE__ */ jsx16("div", { className: "disablePagination", children: TableHeaderAndTableActions }),
1359
1375
  /* @__PURE__ */ jsxs11(
@@ -1374,6 +1390,7 @@ function DataTableAdvancedFilterWrapper({
1374
1390
  dataKey: "id",
1375
1391
  size: "small",
1376
1392
  rowClassName: () => "box-row-table",
1393
+ filterDisplay: "menu",
1377
1394
  filters,
1378
1395
  selection: selectedRowsData,
1379
1396
  onSelectionChange: (e) => setSelectedRowsData(e.value),
@@ -1692,129 +1709,62 @@ function DataTableAdvancedFilter({
1692
1709
 
1693
1710
  // src/components/DataTableAdvancedFilter/FilterTemplates.tsx
1694
1711
  import Select2 from "react-select";
1695
- import { Dropdown } from "primereact/dropdown";
1696
1712
  import moment2 from "moment";
1697
- import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
1698
- var FilterMatchModeSelect = ({
1699
- options,
1700
- items,
1701
- placeholder = "Tipo de filtro"
1702
- }) => {
1703
- const rawFilter = options.value ?? {};
1704
- const currentMatchMode = rawFilter.matchMode ?? items[0]?.value;
1705
- const isSpecial = (mode) => mode === customMatchModes.empty || mode === customMatchModes.notEmpty;
1706
- return /* @__PURE__ */ jsx18(
1707
- Dropdown,
1713
+ import { jsx as jsx18 } from "react/jsx-runtime";
1714
+ var DateFilterTemplate = (options, mask) => {
1715
+ const matchMode = options.filterModel?.matchMode;
1716
+ const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
1717
+ const parsedValue = typeof options.filterModel?.value === "string" ? /* @__PURE__ */ new Date(options.filterModel.value + "T00:00:00") : null;
1718
+ return /* @__PURE__ */ jsx18("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ jsx18(
1719
+ Calendar,
1708
1720
  {
1709
- value: currentMatchMode,
1710
- options: items,
1711
- optionLabel: "label",
1712
- optionValue: "value",
1713
- placeholder,
1714
- style: { width: "100%" },
1721
+ value: parsedValue,
1715
1722
  onChange: (e) => {
1716
- const newMatchMode = e.value;
1717
- if (isSpecial(newMatchMode)) {
1718
- options.filterCallback({
1719
- text: null,
1720
- matchMode: newMatchMode
1721
- });
1723
+ const date = e.value;
1724
+ if (!date) {
1725
+ options.filterCallback(null, options.index);
1722
1726
  return;
1723
1727
  }
1724
- options.filterCallback({
1725
- text: null,
1726
- matchMode: newMatchMode
1727
- });
1728
- }
1728
+ const valueToFilter = mask ? mask(date) : `${date.getFullYear()}-${String(
1729
+ date.getMonth() + 1
1730
+ ).padStart(2, "0")}-${String(
1731
+ date.getDate()
1732
+ ).padStart(2, "0")}`;
1733
+ options.filterCallback(valueToFilter, options.index);
1734
+ },
1735
+ dateFormat: "dd/mm/yy",
1736
+ placeholder: "dd/mm/yyyy",
1737
+ mask: "99/99/9999",
1738
+ inputClassName: "p-column-filter"
1729
1739
  }
1730
- );
1731
- };
1732
- var DateFilterTemplate = (options, isLanguagePtBr = true, isNullable = true, items, mask) => {
1733
- const resolvedItems = items ?? getDefaultFilterMatchOptionsDate(isLanguagePtBr, isNullable);
1734
- const rawFilter = options.value ?? {};
1735
- const currentMatchMode = rawFilter.matchMode;
1736
- const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1737
- const parsedValue = options.value?.text && typeof options.value.text === "string" ? /* @__PURE__ */ new Date(options.value.text + "T00:00:00") : null;
1738
- return /* @__PURE__ */ jsxs12("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1739
- /* @__PURE__ */ jsx18(
1740
- FilterMatchModeSelect,
1741
- {
1742
- options,
1743
- items: resolvedItems
1744
- }
1745
- ),
1746
- !isSpecial && /* @__PURE__ */ jsx18(
1747
- Calendar,
1748
- {
1749
- value: parsedValue,
1750
- onChange: (e) => {
1751
- if (!e.value) {
1752
- options.filterCallback({
1753
- text: null,
1754
- matchMode: currentMatchMode
1755
- });
1756
- return;
1757
- }
1758
- const date = e.value;
1759
- const valueToFilter = mask ? mask(date) : `${date.getFullYear()}-${String(
1760
- date.getMonth() + 1
1761
- ).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
1762
- options.filterCallback({
1763
- text: valueToFilter,
1764
- matchMode: currentMatchMode
1765
- });
1766
- },
1767
- dateFormat: "dd/mm/yy",
1768
- placeholder: "dd/mm/yyyy",
1769
- mask: "99/99/9999",
1770
- inputClassName: "p-column-filter"
1771
- }
1772
- )
1773
- ] });
1740
+ ) });
1774
1741
  };
1775
- var DateTimeFilterTemplate = (options, isLanguagePtBr = true, isNullable = true, mask) => {
1776
- const items = getDefaultFilterMatchOptionsDate(isLanguagePtBr, isNullable);
1777
- const rawFilter = options.value ?? {};
1778
- const currentMatchMode = rawFilter.matchMode;
1779
- const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1780
- const value = typeof rawFilter.text === "string" ? moment2(rawFilter.text).toDate() : null;
1781
- return /* @__PURE__ */ jsxs12("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1782
- /* @__PURE__ */ jsx18(
1783
- FilterMatchModeSelect,
1784
- {
1785
- options,
1786
- items
1787
- }
1788
- ),
1789
- !isSpecial && /* @__PURE__ */ jsx18(
1790
- Calendar,
1791
- {
1792
- value,
1793
- showTime: true,
1794
- showSeconds: true,
1795
- hourFormat: "24",
1796
- dateFormat: "dd/mm/yy",
1797
- placeholder: "dd/mm/yyyy 00:00:00",
1798
- readOnlyInput: true,
1799
- inputClassName: "p-column-filter",
1800
- onChange: (e) => {
1801
- const selectedDate = e.value;
1802
- if (!selectedDate) {
1803
- options.filterCallback({
1804
- text: null,
1805
- matchMode: currentMatchMode
1806
- });
1807
- return;
1808
- }
1809
- const formatted = mask ? mask(selectedDate) : moment2(selectedDate).utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
1810
- options.filterCallback({
1811
- text: formatted,
1812
- matchMode: currentMatchMode
1813
- });
1742
+ var DateTimeFilterTemplate = (options, mask) => {
1743
+ const matchMode = options.filterModel?.matchMode;
1744
+ const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
1745
+ const value = options.filterModel?.value ? moment2(options.filterModel.value).toDate() : null;
1746
+ return /* @__PURE__ */ jsx18("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ jsx18(
1747
+ Calendar,
1748
+ {
1749
+ value,
1750
+ showTime: true,
1751
+ showSeconds: true,
1752
+ hourFormat: "24",
1753
+ dateFormat: "dd/mm/yy",
1754
+ placeholder: "dd/mm/yyyy 00:00:00",
1755
+ readOnlyInput: true,
1756
+ inputClassName: "p-column-filter",
1757
+ onChange: (e) => {
1758
+ const selectedDate = e.value;
1759
+ if (!selectedDate) {
1760
+ options.filterCallback(null, options.index);
1761
+ return;
1814
1762
  }
1763
+ const formatted = mask ? mask(selectedDate) : moment2(selectedDate).utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
1764
+ options.filterCallback(formatted, options.index);
1815
1765
  }
1816
- )
1817
- ] });
1766
+ }
1767
+ ) });
1818
1768
  };
1819
1769
  var ValueFilterTemplate = (options, mask) => {
1820
1770
  const parsedValue = options.value !== null && options.value !== void 0 ? centsToReal(options.value) : null;
@@ -1840,115 +1790,53 @@ var ValueFilterTemplate = (options, mask) => {
1840
1790
  }
1841
1791
  );
1842
1792
  };
1843
- var SelectFilterTemplate = (options, isLanguagePtBr = true, isNullable = true, items = []) => {
1844
- const matchModeItems = getDefaultFilterMatchOptionsEnum(isLanguagePtBr, isNullable);
1793
+ var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
1845
1794
  const selectOptions = items.length > 0 ? items : [
1846
1795
  { label: isLanguagePtBr ? "Sim" : "Yes", value: true },
1847
1796
  { label: isLanguagePtBr ? "N\xE3o" : "No", value: false }
1848
1797
  ];
1849
- const rawFilter = options.value ?? {};
1850
- const currentMatchMode = rawFilter.matchMode;
1851
- const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1852
- const currentValue = selectOptions.find((opt) => opt.value === rawFilter.text) || null;
1853
- return /* @__PURE__ */ jsxs12("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1854
- /* @__PURE__ */ jsx18(
1855
- FilterMatchModeSelect,
1856
- {
1857
- options,
1858
- items: matchModeItems
1859
- }
1860
- ),
1861
- !isSpecial && /* @__PURE__ */ jsx18(
1862
- Select2,
1863
- {
1864
- options: selectOptions,
1865
- value: currentValue,
1866
- onChange: (selected) => {
1867
- if (!selected) {
1868
- options.filterCallback({
1869
- text: null,
1870
- matchMode: currentMatchMode
1871
- });
1872
- return;
1873
- }
1874
- options.filterCallback({
1875
- text: selected.value,
1876
- matchMode: currentMatchMode
1877
- });
1878
- },
1879
- placeholder: isLanguagePtBr ? "Selecione..." : "Select...",
1880
- isClearable: false,
1881
- isSearchable: false,
1882
- className: "custom-select-filtro",
1883
- classNamePrefix: "custom-select-filtro",
1884
- styles: {
1885
- control: (baseStyles, state) => ({
1886
- ...baseStyles,
1887
- "&:hover": {
1888
- borderColor: state.isFocused ? "#094394" : ""
1889
- },
1890
- borderRadius: "6px"
1891
- }),
1892
- menuList: (base) => ({
1893
- ...base,
1894
- "::-webkit-scrollbar": {
1895
- width: "6px"
1896
- },
1897
- "::-webkit-scrollbar-track": {
1898
- background: "#fff"
1899
- },
1900
- "::-webkit-scrollbar-thumb": {
1901
- background: "#888",
1902
- borderRadius: "2rem"
1903
- },
1904
- "::-webkit-scrollbar-thumb:hover": {
1905
- background: "#555"
1906
- }
1907
- }),
1908
- option: (provided, state) => ({
1909
- ...provided,
1910
- backgroundColor: state.isFocused ? "#094394" : "#ffffff",
1911
- color: state.isFocused ? "#ffffff" : "black",
1912
- "&:hover": {
1913
- backgroundColor: "#094394",
1914
- color: "#ffffff"
1915
- }
1916
- })
1917
- }
1918
- }
1919
- )
1920
- ] });
1798
+ const matchMode = options.filterModel?.matchMode;
1799
+ const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
1800
+ const currentValue = selectOptions.find(
1801
+ (opt) => opt.value === options.filterModel?.value
1802
+ ) || null;
1803
+ return /* @__PURE__ */ jsx18("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ jsx18(
1804
+ Select2,
1805
+ {
1806
+ options: selectOptions,
1807
+ value: currentValue,
1808
+ onChange: (selected) => {
1809
+ options.filterCallback(
1810
+ selected ? selected.value : null,
1811
+ options.index
1812
+ // 🔥 ESSENCIAL
1813
+ );
1814
+ },
1815
+ placeholder: isLanguagePtBr ? "Selecione..." : "Select...",
1816
+ isClearable: true,
1817
+ isSearchable: false,
1818
+ className: "custom-select-filtro",
1819
+ classNamePrefix: "custom-select-filtro"
1820
+ }
1821
+ ) });
1921
1822
  };
1922
- var CustomFilterElement = (options, isLanguagePtBr = true, isNullable = true, items) => {
1923
- const resolvedItems = items ?? getDefaultFilterMatchOptionsString(isLanguagePtBr, isNullable);
1924
- const rawFilter = options.value ?? {};
1925
- const currentMatchMode = rawFilter.matchMode ?? "contains";
1926
- const currentValue = typeof rawFilter.text === "string" ? rawFilter.text : "";
1927
- const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1928
- return /* @__PURE__ */ jsxs12("div", { className: "filter-wrapper", style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1929
- /* @__PURE__ */ jsx18(
1930
- FilterMatchModeSelect,
1931
- {
1932
- options,
1933
- items: resolvedItems
1934
- }
1935
- ),
1936
- !isSpecial && /* @__PURE__ */ jsx18(
1937
- InputText,
1938
- {
1939
- value: currentValue,
1940
- placeholder: isLanguagePtBr ? "Pesquisar" : "Search",
1941
- className: "p-column-filter",
1942
- onChange: (e) => {
1943
- const value = e.target.value;
1944
- options.filterCallback({
1945
- text: value.trim() ? value : null,
1946
- matchMode: currentMatchMode
1947
- });
1948
- }
1949
- }
1950
- )
1951
- ] });
1823
+ var CustomFilterElement = (options, isLanguagePtBr = true) => {
1824
+ const matchMode = options.filterModel?.matchMode;
1825
+ const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
1826
+ return !isSpecial && /* @__PURE__ */ jsx18(
1827
+ InputText,
1828
+ {
1829
+ value: options.filterModel?.value ?? "",
1830
+ placeholder: isLanguagePtBr ? "Pesquisar" : "Search",
1831
+ onChange: (e) => {
1832
+ options.filterCallback(
1833
+ e.target.value || null,
1834
+ options.index
1835
+ );
1836
+ },
1837
+ className: "p-column-filter"
1838
+ }
1839
+ );
1952
1840
  };
1953
1841
 
1954
1842
  // src/components/DataTableAdvancedFilter/filterModes.ts
@@ -2376,7 +2264,6 @@ export {
2376
2264
  DateFilterTemplate,
2377
2265
  DateTimeFilterTemplate,
2378
2266
  FilterMatchMode5 as FilterMatchMode,
2379
- FilterMatchModeSelect,
2380
2267
  FilterOperator2 as FilterOperator,
2381
2268
  Input,
2382
2269
  InputAutoComplete,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charlesgomes/leafcode-shared-lib-react",
3
- "version": "1.0.77",
3
+ "version": "1.0.78",
4
4
  "description": "Lib de componentes react",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",