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

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,
@@ -1424,6 +1438,7 @@ function DataTableAdvancedFilterWrapper({
1424
1438
  dataKey: "id",
1425
1439
  size: "small",
1426
1440
  rowClassName: () => "box-row-table",
1441
+ filterDisplay: "menu",
1427
1442
  filters,
1428
1443
  selection: selectedRowsData,
1429
1444
  onSelectionChange: (e) => setSelectedRowsData(e.value),
@@ -1714,7 +1729,7 @@ function DataTableAdvancedFilter({
1714
1729
  import_api2.PrimeReactProvider,
1715
1730
  {
1716
1731
  value: isLanguagePtBr ? { locale: "pt" } : { locale: "en" },
1717
- children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1732
+ children: state && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1718
1733
  DataTableAdvancedFilterWrapper,
1719
1734
  {
1720
1735
  rowsPerPageOptions,
@@ -1742,129 +1757,62 @@ function DataTableAdvancedFilter({
1742
1757
 
1743
1758
  // src/components/DataTableAdvancedFilter/FilterTemplates.tsx
1744
1759
  var import_react_select2 = __toESM(require("react-select"));
1745
- var import_dropdown = require("primereact/dropdown");
1746
1760
  var import_moment2 = __toESM(require("moment"));
1747
1761
  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,
1762
+ var DateFilterTemplate = (options, mask) => {
1763
+ const matchMode = options.filterModel?.matchMode;
1764
+ const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
1765
+ const parsedValue = typeof options.filterModel?.value === "string" ? /* @__PURE__ */ new Date(options.filterModel.value + "T00:00:00") : null;
1766
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1767
+ import_calendar.Calendar,
1758
1768
  {
1759
- value: currentMatchMode,
1760
- options: items,
1761
- optionLabel: "label",
1762
- optionValue: "value",
1763
- placeholder,
1764
- style: { width: "100%" },
1769
+ value: parsedValue,
1765
1770
  onChange: (e) => {
1766
- const newMatchMode = e.value;
1767
- if (isSpecial(newMatchMode)) {
1768
- options.filterCallback({
1769
- text: null,
1770
- matchMode: newMatchMode
1771
- });
1771
+ const date = e.value;
1772
+ if (!date) {
1773
+ options.filterCallback(null, options.index);
1772
1774
  return;
1773
1775
  }
1774
- options.filterCallback({
1775
- text: null,
1776
- matchMode: newMatchMode
1777
- });
1778
- }
1776
+ const valueToFilter = mask ? mask(date) : `${date.getFullYear()}-${String(
1777
+ date.getMonth() + 1
1778
+ ).padStart(2, "0")}-${String(
1779
+ date.getDate()
1780
+ ).padStart(2, "0")}`;
1781
+ options.filterCallback(valueToFilter, options.index);
1782
+ },
1783
+ dateFormat: "dd/mm/yy",
1784
+ placeholder: "dd/mm/yyyy",
1785
+ mask: "99/99/9999",
1786
+ inputClassName: "p-column-filter"
1779
1787
  }
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
- ] });
1788
+ ) });
1824
1789
  };
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
- });
1790
+ var DateTimeFilterTemplate = (options, mask) => {
1791
+ const matchMode = options.filterModel?.matchMode;
1792
+ const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
1793
+ const value = options.filterModel?.value ? (0, import_moment2.default)(options.filterModel.value).toDate() : null;
1794
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1795
+ import_calendar.Calendar,
1796
+ {
1797
+ value,
1798
+ showTime: true,
1799
+ showSeconds: true,
1800
+ hourFormat: "24",
1801
+ dateFormat: "dd/mm/yy",
1802
+ placeholder: "dd/mm/yyyy 00:00:00",
1803
+ readOnlyInput: true,
1804
+ inputClassName: "p-column-filter",
1805
+ onChange: (e) => {
1806
+ const selectedDate = e.value;
1807
+ if (!selectedDate) {
1808
+ options.filterCallback(null, options.index);
1809
+ return;
1864
1810
  }
1811
+ const formatted = mask ? mask(selectedDate) : (0, import_moment2.default)(selectedDate).utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
1812
+ options.filterCallback(formatted, options.index);
1865
1813
  }
1866
- )
1867
- ] });
1814
+ }
1815
+ ) });
1868
1816
  };
1869
1817
  var ValueFilterTemplate = (options, mask) => {
1870
1818
  const parsedValue = options.value !== null && options.value !== void 0 ? centsToReal(options.value) : null;
@@ -1890,115 +1838,53 @@ var ValueFilterTemplate = (options, mask) => {
1890
1838
  }
1891
1839
  );
1892
1840
  };
1893
- var SelectFilterTemplate = (options, isLanguagePtBr = true, isNullable = true, items = []) => {
1894
- const matchModeItems = getDefaultFilterMatchOptionsEnum(isLanguagePtBr, isNullable);
1841
+ var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
1895
1842
  const selectOptions = items.length > 0 ? items : [
1896
1843
  { label: isLanguagePtBr ? "Sim" : "Yes", value: true },
1897
1844
  { label: isLanguagePtBr ? "N\xE3o" : "No", value: false }
1898
1845
  ];
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
- ] });
1846
+ const matchMode = options.filterModel?.matchMode;
1847
+ const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
1848
+ const currentValue = selectOptions.find(
1849
+ (opt) => opt.value === options.filterModel?.value
1850
+ ) || null;
1851
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1852
+ import_react_select2.default,
1853
+ {
1854
+ options: selectOptions,
1855
+ value: currentValue,
1856
+ onChange: (selected) => {
1857
+ options.filterCallback(
1858
+ selected ? selected.value : null,
1859
+ options.index
1860
+ // 🔥 ESSENCIAL
1861
+ );
1862
+ },
1863
+ placeholder: isLanguagePtBr ? "Selecione..." : "Select...",
1864
+ isClearable: true,
1865
+ isSearchable: false,
1866
+ className: "custom-select-filtro",
1867
+ classNamePrefix: "custom-select-filtro"
1868
+ }
1869
+ ) });
1971
1870
  };
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
- ] });
1871
+ var CustomFilterElement = (options, isLanguagePtBr = true) => {
1872
+ const matchMode = options.filterModel?.matchMode;
1873
+ const isSpecial = matchMode === "empty" || matchMode === "notEmpty";
1874
+ return !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1875
+ import_inputtext.InputText,
1876
+ {
1877
+ value: options.filterModel?.value ?? "",
1878
+ placeholder: isLanguagePtBr ? "Pesquisar" : "Search",
1879
+ onChange: (e) => {
1880
+ options.filterCallback(
1881
+ e.target.value || null,
1882
+ options.index
1883
+ );
1884
+ },
1885
+ className: "p-column-filter"
1886
+ }
1887
+ );
2002
1888
  };
2003
1889
 
2004
1890
  // src/components/DataTableAdvancedFilter/filterModes.ts
@@ -2427,7 +2313,6 @@ var import_api5 = require("primereact/api");
2427
2313
  DateFilterTemplate,
2428
2314
  DateTimeFilterTemplate,
2429
2315
  FilterMatchMode,
2430
- FilterMatchModeSelect,
2431
2316
  FilterOperator,
2432
2317
  Input,
2433
2318
  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,
@@ -1374,6 +1389,7 @@ function DataTableAdvancedFilterWrapper({
1374
1389
  dataKey: "id",
1375
1390
  size: "small",
1376
1391
  rowClassName: () => "box-row-table",
1392
+ filterDisplay: "menu",
1377
1393
  filters,
1378
1394
  selection: selectedRowsData,
1379
1395
  onSelectionChange: (e) => setSelectedRowsData(e.value),
@@ -1664,7 +1680,7 @@ function DataTableAdvancedFilter({
1664
1680
  PrimeReactProvider,
1665
1681
  {
1666
1682
  value: isLanguagePtBr ? { locale: "pt" } : { locale: "en" },
1667
- children: /* @__PURE__ */ jsx17(
1683
+ children: state && /* @__PURE__ */ jsx17(
1668
1684
  DataTableAdvancedFilterWrapper,
1669
1685
  {
1670
1686
  rowsPerPageOptions,
@@ -1692,129 +1708,62 @@ function DataTableAdvancedFilter({
1692
1708
 
1693
1709
  // src/components/DataTableAdvancedFilter/FilterTemplates.tsx
1694
1710
  import Select2 from "react-select";
1695
- import { Dropdown } from "primereact/dropdown";
1696
1711
  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,
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,
1708
1719
  {
1709
- value: currentMatchMode,
1710
- options: items,
1711
- optionLabel: "label",
1712
- optionValue: "value",
1713
- placeholder,
1714
- style: { width: "100%" },
1720
+ value: parsedValue,
1715
1721
  onChange: (e) => {
1716
- const newMatchMode = e.value;
1717
- if (isSpecial(newMatchMode)) {
1718
- options.filterCallback({
1719
- text: null,
1720
- matchMode: newMatchMode
1721
- });
1722
+ const date = e.value;
1723
+ if (!date) {
1724
+ options.filterCallback(null, options.index);
1722
1725
  return;
1723
1726
  }
1724
- options.filterCallback({
1725
- text: null,
1726
- matchMode: newMatchMode
1727
- });
1728
- }
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"
1729
1738
  }
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
- ] });
1739
+ ) });
1774
1740
  };
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
- });
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;
1814
1761
  }
1762
+ const formatted = mask ? mask(selectedDate) : moment2(selectedDate).utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
1763
+ options.filterCallback(formatted, options.index);
1815
1764
  }
1816
- )
1817
- ] });
1765
+ }
1766
+ ) });
1818
1767
  };
1819
1768
  var ValueFilterTemplate = (options, mask) => {
1820
1769
  const parsedValue = options.value !== null && options.value !== void 0 ? centsToReal(options.value) : null;
@@ -1840,115 +1789,53 @@ var ValueFilterTemplate = (options, mask) => {
1840
1789
  }
1841
1790
  );
1842
1791
  };
1843
- var SelectFilterTemplate = (options, isLanguagePtBr = true, isNullable = true, items = []) => {
1844
- const matchModeItems = getDefaultFilterMatchOptionsEnum(isLanguagePtBr, isNullable);
1792
+ var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
1845
1793
  const selectOptions = items.length > 0 ? items : [
1846
1794
  { label: isLanguagePtBr ? "Sim" : "Yes", value: true },
1847
1795
  { label: isLanguagePtBr ? "N\xE3o" : "No", value: false }
1848
1796
  ];
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
- ] });
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
+ ) });
1921
1821
  };
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
- ] });
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
+ );
1952
1839
  };
1953
1840
 
1954
1841
  // src/components/DataTableAdvancedFilter/filterModes.ts
@@ -2376,7 +2263,6 @@ export {
2376
2263
  DateFilterTemplate,
2377
2264
  DateTimeFilterTemplate,
2378
2265
  FilterMatchMode5 as FilterMatchMode,
2379
- FilterMatchModeSelect,
2380
2266
  FilterOperator2 as FilterOperator,
2381
2267
  Input,
2382
2268
  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.79",
4
4
  "description": "Lib de componentes react",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",