@charlesgomes/leafcode-shared-lib-react 1.0.65 → 1.0.68

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
@@ -190,8 +190,17 @@ interface IItemProps {
190
190
  label: string;
191
191
  }
192
192
 
193
- declare const DateFilterTemplate: (options: any, mask?: (value: any) => string | number) => react_jsx_runtime.JSX.Element;
194
- declare const DateTimeFilterTemplate: (options: any, mask?: (date: Date) => string) => react_jsx_runtime.JSX.Element;
193
+ type FilterMatchModeSelectProps = {
194
+ options: any;
195
+ items: {
196
+ label: string;
197
+ value: string;
198
+ }[];
199
+ placeholder?: string;
200
+ };
201
+ declare const FilterMatchModeSelect: ({ options, items, placeholder, }: FilterMatchModeSelectProps) => react_jsx_runtime.JSX.Element;
202
+ declare const DateFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: any[], mask?: (value: Date) => string) => react_jsx_runtime.JSX.Element;
203
+ declare const DateTimeFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, mask?: (date: Date) => string) => react_jsx_runtime.JSX.Element;
195
204
  declare const ValueFilterTemplate: (options: any, mask?: (value: any) => string | number) => react_jsx_runtime.JSX.Element;
196
205
  declare const SelectFilterTemplate: (options: any, isLanguagePtBr?: boolean, items?: IItemProps[]) => react_jsx_runtime.JSX.Element;
197
206
  declare const CustomFilterElement: (options: any, isLanguagePtBr?: boolean, items?: any[]) => react_jsx_runtime.JSX.Element;
@@ -331,4 +340,4 @@ declare const LeafcodeThemeProvider: ({ children, theme, }: LeafcodeThemeProvide
331
340
 
332
341
  declare const defaultTheme: LeafcodeTheme;
333
342
 
334
- export { Button, type ColumnCustom, CustomFilterElement, DataTableAdvancedFilter, DateFilterTemplate, DateTimeFilterTemplate, type IDataTableProps, type IItemProps, Input, InputAutoComplete, InputSelect, LeafcodeThemeProvider, ModalBase, SelectFilterTemplate, TextArea, ValueFilterTemplate, buildDynamicCampoFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getUrlParams, mapPrimeToBackendFilters };
343
+ export { Button, type ColumnCustom, CustomFilterElement, DataTableAdvancedFilter, DateFilterTemplate, DateTimeFilterTemplate, FilterMatchModeSelect, type IDataTableProps, type IItemProps, Input, InputAutoComplete, InputSelect, LeafcodeThemeProvider, ModalBase, SelectFilterTemplate, TextArea, ValueFilterTemplate, buildDynamicCampoFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getUrlParams, mapPrimeToBackendFilters };
package/dist/index.d.ts CHANGED
@@ -190,8 +190,17 @@ interface IItemProps {
190
190
  label: string;
191
191
  }
192
192
 
193
- declare const DateFilterTemplate: (options: any, mask?: (value: any) => string | number) => react_jsx_runtime.JSX.Element;
194
- declare const DateTimeFilterTemplate: (options: any, mask?: (date: Date) => string) => react_jsx_runtime.JSX.Element;
193
+ type FilterMatchModeSelectProps = {
194
+ options: any;
195
+ items: {
196
+ label: string;
197
+ value: string;
198
+ }[];
199
+ placeholder?: string;
200
+ };
201
+ declare const FilterMatchModeSelect: ({ options, items, placeholder, }: FilterMatchModeSelectProps) => react_jsx_runtime.JSX.Element;
202
+ declare const DateFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: any[], mask?: (value: Date) => string) => react_jsx_runtime.JSX.Element;
203
+ declare const DateTimeFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, mask?: (date: Date) => string) => react_jsx_runtime.JSX.Element;
195
204
  declare const ValueFilterTemplate: (options: any, mask?: (value: any) => string | number) => react_jsx_runtime.JSX.Element;
196
205
  declare const SelectFilterTemplate: (options: any, isLanguagePtBr?: boolean, items?: IItemProps[]) => react_jsx_runtime.JSX.Element;
197
206
  declare const CustomFilterElement: (options: any, isLanguagePtBr?: boolean, items?: any[]) => react_jsx_runtime.JSX.Element;
@@ -331,4 +340,4 @@ declare const LeafcodeThemeProvider: ({ children, theme, }: LeafcodeThemeProvide
331
340
 
332
341
  declare const defaultTheme: LeafcodeTheme;
333
342
 
334
- export { Button, type ColumnCustom, CustomFilterElement, DataTableAdvancedFilter, DateFilterTemplate, DateTimeFilterTemplate, type IDataTableProps, type IItemProps, Input, InputAutoComplete, InputSelect, LeafcodeThemeProvider, ModalBase, SelectFilterTemplate, TextArea, ValueFilterTemplate, buildDynamicCampoFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getUrlParams, mapPrimeToBackendFilters };
343
+ export { Button, type ColumnCustom, CustomFilterElement, DataTableAdvancedFilter, DateFilterTemplate, DateTimeFilterTemplate, FilterMatchModeSelect, type IDataTableProps, type IItemProps, Input, InputAutoComplete, InputSelect, LeafcodeThemeProvider, ModalBase, SelectFilterTemplate, TextArea, ValueFilterTemplate, buildDynamicCampoFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getUrlParams, mapPrimeToBackendFilters };
package/dist/index.js CHANGED
@@ -36,6 +36,7 @@ __export(index_exports, {
36
36
  DateFilterTemplate: () => DateFilterTemplate,
37
37
  DateTimeFilterTemplate: () => DateTimeFilterTemplate,
38
38
  FilterMatchMode: () => import_api5.FilterMatchMode,
39
+ FilterMatchModeSelect: () => FilterMatchModeSelect,
39
40
  FilterOperator: () => import_api5.FilterOperator,
40
41
  Input: () => Input,
41
42
  InputAutoComplete: () => InputAutoComplete,
@@ -693,25 +694,24 @@ var import_react_query = require("@tanstack/react-query");
693
694
  // src/components/Loading/Loading.tsx
694
695
  var import_react10 = require("react");
695
696
  var import_jsx_runtime9 = require("react/jsx-runtime");
696
- var LoadingSpinner = (0, import_react10.memo)(
697
- ({ size = 20, color = "#00875F" }) => {
698
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
699
- "span",
700
- {
701
- style: {
702
- width: size,
703
- height: size,
704
- border: `3px solid ${color}33`,
705
- borderTopColor: color,
706
- borderRadius: "50%",
707
- display: "inline-block",
708
- animation: "leafcode-spin 0.8s linear infinite"
709
- },
710
- "aria-label": "Carregando"
711
- }
712
- );
713
- }
714
- );
697
+ var LoadingSpinner = (0, import_react10.memo)(({ size = 20 }) => {
698
+ const theme = useLeafcodeTheme();
699
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
700
+ "span",
701
+ {
702
+ style: {
703
+ width: size,
704
+ height: size,
705
+ border: `3px solid ${theme.components.input.colors.focusBorder}33`,
706
+ borderTopColor: theme.components.input.colors.focusBorder,
707
+ borderRadius: "50%",
708
+ display: "inline-block",
709
+ animation: "leafcode-spin 0.8s linear infinite"
710
+ },
711
+ "aria-label": "Carregando"
712
+ }
713
+ );
714
+ });
715
715
  LoadingSpinner.displayName = "LoadingSpinner";
716
716
 
717
717
  // src/components/Input/InputAutocomplete.tsx
@@ -1731,55 +1731,126 @@ var import_react_select2 = __toESM(require("react-select"));
1731
1731
  var import_dropdown = require("primereact/dropdown");
1732
1732
  var import_moment2 = __toESM(require("moment"));
1733
1733
  var import_jsx_runtime18 = require("react/jsx-runtime");
1734
- var DateFilterTemplate = (options, mask) => {
1735
- const parsedValue = options.value && typeof options.value === "string" ? /* @__PURE__ */ new Date(options.value + "T00:00:00") : options.value;
1734
+ var FilterMatchModeSelect = ({
1735
+ options,
1736
+ items,
1737
+ placeholder = "Tipo de filtro"
1738
+ }) => {
1739
+ const rawFilter = options.value ?? {};
1740
+ const currentMatchMode = rawFilter.matchMode ?? items[0]?.value;
1741
+ const isSpecial = (mode) => mode === customMatchModes.empty || mode === customMatchModes.notEmpty;
1736
1742
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1737
- import_calendar.Calendar,
1743
+ import_dropdown.Dropdown,
1738
1744
  {
1739
- value: parsedValue,
1745
+ value: currentMatchMode,
1746
+ options: items,
1747
+ optionLabel: "label",
1748
+ optionValue: "value",
1749
+ placeholder,
1750
+ style: { width: "100%" },
1740
1751
  onChange: (e) => {
1741
- if (!e.value) {
1742
- options.filterCallback(null, options.index);
1752
+ const newMatchMode = e.value;
1753
+ if (isSpecial(newMatchMode)) {
1754
+ options.filterCallback({
1755
+ text: null,
1756
+ matchMode: newMatchMode
1757
+ });
1743
1758
  return;
1744
1759
  }
1745
- const date = e.value;
1746
- const valueToFilter = mask ? mask(date) : `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(
1747
- 2,
1748
- "0"
1749
- )}-${String(date.getDate()).padStart(2, "0")}`;
1750
- options.filterCallback(valueToFilter, options.index);
1751
- },
1752
- dateFormat: "dd/mm/yy",
1753
- placeholder: "dd/mm/yyyy",
1754
- mask: "99/99/9999",
1755
- inputClassName: "p-column-filter"
1760
+ options.filterCallback({
1761
+ text: null,
1762
+ matchMode: newMatchMode
1763
+ });
1764
+ }
1756
1765
  }
1757
1766
  );
1758
1767
  };
1759
- var DateTimeFilterTemplate = (options, mask) => {
1760
- const value = typeof options.value === "string" ? (0, import_moment2.default)(options.value).toDate() : options.value ?? null;
1761
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1762
- import_calendar.Calendar,
1763
- {
1764
- value,
1765
- showTime: true,
1766
- showSeconds: true,
1767
- hourFormat: "24",
1768
- dateFormat: "dd/mm/yy",
1769
- placeholder: "dd/mm/yyyy 00:00:00",
1770
- readOnlyInput: true,
1771
- inputClassName: "p-column-filter",
1772
- onChange: (e) => {
1773
- const selectedDate = e.value;
1774
- if (!selectedDate) {
1775
- options.filterCallback(null, options.index);
1776
- return;
1768
+ var DateFilterTemplate = (options, isLanguagePtBr = true, isNullable = true, items, mask) => {
1769
+ const resolvedItems = items ?? getDefaultFilterMatchOptionsDate(isLanguagePtBr, isNullable);
1770
+ const rawFilter = options.value ?? {};
1771
+ const currentMatchMode = rawFilter.matchMode;
1772
+ const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1773
+ const parsedValue = options.value?.text && typeof options.value.text === "string" ? /* @__PURE__ */ new Date(options.value.text + "T00:00:00") : null;
1774
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1775
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1776
+ FilterMatchModeSelect,
1777
+ {
1778
+ options,
1779
+ items: resolvedItems
1780
+ }
1781
+ ),
1782
+ !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1783
+ import_calendar.Calendar,
1784
+ {
1785
+ value: parsedValue,
1786
+ onChange: (e) => {
1787
+ if (!e.value) {
1788
+ options.filterCallback({
1789
+ text: null,
1790
+ matchMode: currentMatchMode
1791
+ });
1792
+ return;
1793
+ }
1794
+ const date = e.value;
1795
+ const valueToFilter = mask ? mask(date) : `${date.getFullYear()}-${String(
1796
+ date.getMonth() + 1
1797
+ ).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
1798
+ options.filterCallback({
1799
+ text: valueToFilter,
1800
+ matchMode: currentMatchMode
1801
+ });
1802
+ },
1803
+ dateFormat: "dd/mm/yy",
1804
+ placeholder: "dd/mm/yyyy",
1805
+ mask: "99/99/9999",
1806
+ inputClassName: "p-column-filter"
1807
+ }
1808
+ )
1809
+ ] });
1810
+ };
1811
+ var DateTimeFilterTemplate = (options, isLanguagePtBr = true, isNullable = true, mask) => {
1812
+ const items = getDefaultFilterMatchOptionsDate(isLanguagePtBr, isNullable);
1813
+ const rawFilter = options.value ?? {};
1814
+ const currentMatchMode = rawFilter.matchMode;
1815
+ const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1816
+ const value = typeof rawFilter.text === "string" ? (0, import_moment2.default)(rawFilter.text).toDate() : null;
1817
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1818
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1819
+ FilterMatchModeSelect,
1820
+ {
1821
+ options,
1822
+ items
1823
+ }
1824
+ ),
1825
+ !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1826
+ import_calendar.Calendar,
1827
+ {
1828
+ value,
1829
+ showTime: true,
1830
+ showSeconds: true,
1831
+ hourFormat: "24",
1832
+ dateFormat: "dd/mm/yy",
1833
+ placeholder: "dd/mm/yyyy 00:00:00",
1834
+ readOnlyInput: true,
1835
+ inputClassName: "p-column-filter",
1836
+ onChange: (e) => {
1837
+ const selectedDate = e.value;
1838
+ if (!selectedDate) {
1839
+ options.filterCallback({
1840
+ text: null,
1841
+ matchMode: currentMatchMode
1842
+ });
1843
+ return;
1844
+ }
1845
+ const formatted = mask ? mask(selectedDate) : (0, import_moment2.default)(selectedDate).utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
1846
+ options.filterCallback({
1847
+ text: formatted,
1848
+ matchMode: currentMatchMode
1849
+ });
1777
1850
  }
1778
- const formatted = mask ? mask(selectedDate) : (0, import_moment2.default)(selectedDate).utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
1779
- options.filterCallback(formatted, options.index);
1780
1851
  }
1781
- }
1782
- );
1852
+ )
1853
+ ] });
1783
1854
  };
1784
1855
  var ValueFilterTemplate = (options, mask) => {
1785
1856
  const parsedValue = options.value !== null && options.value !== void 0 ? centsToReal(options.value) : null;
@@ -1806,7 +1877,6 @@ var ValueFilterTemplate = (options, mask) => {
1806
1877
  };
1807
1878
  var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
1808
1879
  const selectOptions = items.length > 0 ? items : [
1809
- { label: isLanguagePtBr ? "Todos" : "All", value: null },
1810
1880
  { label: isLanguagePtBr ? "Sim" : "Yes", value: true },
1811
1881
  { label: isLanguagePtBr ? "N\xE3o" : "No", value: false }
1812
1882
  ];
@@ -1817,7 +1887,7 @@ var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
1817
1887
  options: selectOptions,
1818
1888
  value: currentValue,
1819
1889
  onChange: (selected) => options.filterCallback(selected?.value),
1820
- placeholder: "Todos",
1890
+ placeholder: "Selecione...",
1821
1891
  isClearable: false,
1822
1892
  isSearchable: false,
1823
1893
  className: "custom-select-filtro",
@@ -1870,69 +1940,30 @@ var CustomFilterElement = (options, isLanguagePtBr = true, items) => {
1870
1940
  const currentMatchMode = rawFilter.matchMode ?? "contains";
1871
1941
  const currentValue = typeof rawFilter.text === "string" ? rawFilter.text : "";
1872
1942
  const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1873
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1874
- "div",
1875
- {
1876
- className: "filter-wrapper",
1877
- style: {
1878
- display: "flex",
1879
- flexDirection: "column",
1880
- gap: "8px",
1881
- minWidth: "200px"
1882
- },
1883
- children: [
1884
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1885
- import_dropdown.Dropdown,
1886
- {
1887
- value: currentMatchMode,
1888
- options: resolvedItems,
1889
- optionLabel: "label",
1890
- optionValue: "value",
1891
- placeholder: "Tipo de filtro",
1892
- style: { width: "100%" },
1893
- onChange: (e) => {
1894
- const newMatchMode = e.value;
1895
- const isNewSpecial = newMatchMode === customMatchModes.empty || newMatchMode === customMatchModes.notEmpty;
1896
- if (isNewSpecial) {
1897
- options.filterCallback({
1898
- text: null,
1899
- matchMode: newMatchMode
1900
- });
1901
- return;
1902
- }
1903
- options.filterCallback({
1904
- text: null,
1905
- matchMode: newMatchMode
1906
- });
1907
- }
1908
- }
1909
- ),
1910
- !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1911
- import_inputtext.InputText,
1912
- {
1913
- value: currentValue,
1914
- placeholder: isLanguagePtBr ? "Pesquisar" : "Search",
1915
- style: { width: "100%" },
1916
- className: "p-column-filter",
1917
- onChange: (e) => {
1918
- const value = e.target.value;
1919
- if (value.trim()) {
1920
- options.filterCallback({
1921
- text: value,
1922
- matchMode: currentMatchMode
1923
- });
1924
- } else {
1925
- options.filterCallback({
1926
- text: null,
1927
- matchMode: currentMatchMode
1928
- });
1929
- }
1930
- }
1931
- }
1932
- )
1933
- ]
1934
- }
1935
- );
1943
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "filter-wrapper", style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1944
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1945
+ FilterMatchModeSelect,
1946
+ {
1947
+ options,
1948
+ items: resolvedItems
1949
+ }
1950
+ ),
1951
+ !isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1952
+ import_inputtext.InputText,
1953
+ {
1954
+ value: currentValue,
1955
+ placeholder: isLanguagePtBr ? "Pesquisar" : "Search",
1956
+ className: "p-column-filter",
1957
+ onChange: (e) => {
1958
+ const value = e.target.value;
1959
+ options.filterCallback({
1960
+ text: value.trim() ? value : null,
1961
+ matchMode: currentMatchMode
1962
+ });
1963
+ }
1964
+ }
1965
+ )
1966
+ ] });
1936
1967
  };
1937
1968
 
1938
1969
  // src/components/DataTableAdvancedFilter/filterModes.ts
@@ -2085,6 +2116,40 @@ var buildFilterPayload = (fieldName, matchMode, rawValue) => {
2085
2116
  }
2086
2117
  };
2087
2118
  }
2119
+ if (matchMode === "dateBeforeAndEquals") {
2120
+ if (normalized === null) return null;
2121
+ return {
2122
+ or: [
2123
+ {
2124
+ field: fieldName,
2125
+ operator: "LessThan",
2126
+ value: normalized
2127
+ },
2128
+ {
2129
+ field: fieldName,
2130
+ operator: "Equals",
2131
+ value: normalized
2132
+ }
2133
+ ]
2134
+ };
2135
+ }
2136
+ if (matchMode === "dateAfterAndEquals") {
2137
+ if (normalized === null) return null;
2138
+ return {
2139
+ or: [
2140
+ {
2141
+ field: fieldName,
2142
+ operator: "GreaterThan",
2143
+ value: normalized
2144
+ },
2145
+ {
2146
+ field: fieldName,
2147
+ operator: "Equals",
2148
+ value: normalized
2149
+ }
2150
+ ]
2151
+ };
2152
+ }
2088
2153
  if (normalized === null) return null;
2089
2154
  if (matchMode === "notStartsWith" || matchMode === "notEndsWith" || matchMode === "notEquals" || // <- notEquals
2090
2155
  matchMode === "dateIsNot" || matchMode === "notContains") {
@@ -2120,11 +2185,9 @@ var buildFilterPayload = (fieldName, matchMode, rawValue) => {
2120
2185
  };
2121
2186
  var mapPrimeToBackendFilters = (filters, globalFilterFields) => {
2122
2187
  const finalAnd = [];
2123
- const globalOr = [];
2124
2188
  const camposMap = {};
2125
2189
  Object.entries(filters).forEach(([field, config]) => {
2126
2190
  if (!config) return;
2127
- const value = config?.value?.text ?? config?.value;
2128
2191
  if (field === "global" && typeof config.value === "string" && config.value.trim() !== "") {
2129
2192
  const globalOrNodes = [];
2130
2193
  globalFilterFields.forEach((globalField) => {
@@ -2329,6 +2392,7 @@ var import_api5 = require("primereact/api");
2329
2392
  DateFilterTemplate,
2330
2393
  DateTimeFilterTemplate,
2331
2394
  FilterMatchMode,
2395
+ FilterMatchModeSelect,
2332
2396
  FilterOperator,
2333
2397
  Input,
2334
2398
  InputAutoComplete,
package/dist/index.mjs CHANGED
@@ -644,25 +644,24 @@ import { useQuery } from "@tanstack/react-query";
644
644
  // src/components/Loading/Loading.tsx
645
645
  import { memo } from "react";
646
646
  import { jsx as jsx9 } from "react/jsx-runtime";
647
- var LoadingSpinner = memo(
648
- ({ size = 20, color = "#00875F" }) => {
649
- return /* @__PURE__ */ jsx9(
650
- "span",
651
- {
652
- style: {
653
- width: size,
654
- height: size,
655
- border: `3px solid ${color}33`,
656
- borderTopColor: color,
657
- borderRadius: "50%",
658
- display: "inline-block",
659
- animation: "leafcode-spin 0.8s linear infinite"
660
- },
661
- "aria-label": "Carregando"
662
- }
663
- );
664
- }
665
- );
647
+ var LoadingSpinner = memo(({ size = 20 }) => {
648
+ const theme = useLeafcodeTheme();
649
+ return /* @__PURE__ */ jsx9(
650
+ "span",
651
+ {
652
+ style: {
653
+ width: size,
654
+ height: size,
655
+ border: `3px solid ${theme.components.input.colors.focusBorder}33`,
656
+ borderTopColor: theme.components.input.colors.focusBorder,
657
+ borderRadius: "50%",
658
+ display: "inline-block",
659
+ animation: "leafcode-spin 0.8s linear infinite"
660
+ },
661
+ "aria-label": "Carregando"
662
+ }
663
+ );
664
+ });
666
665
  LoadingSpinner.displayName = "LoadingSpinner";
667
666
 
668
667
  // src/components/Input/InputAutocomplete.tsx
@@ -1682,55 +1681,126 @@ import Select2 from "react-select";
1682
1681
  import { Dropdown } from "primereact/dropdown";
1683
1682
  import moment2 from "moment";
1684
1683
  import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
1685
- var DateFilterTemplate = (options, mask) => {
1686
- const parsedValue = options.value && typeof options.value === "string" ? /* @__PURE__ */ new Date(options.value + "T00:00:00") : options.value;
1684
+ var FilterMatchModeSelect = ({
1685
+ options,
1686
+ items,
1687
+ placeholder = "Tipo de filtro"
1688
+ }) => {
1689
+ const rawFilter = options.value ?? {};
1690
+ const currentMatchMode = rawFilter.matchMode ?? items[0]?.value;
1691
+ const isSpecial = (mode) => mode === customMatchModes.empty || mode === customMatchModes.notEmpty;
1687
1692
  return /* @__PURE__ */ jsx18(
1688
- Calendar,
1693
+ Dropdown,
1689
1694
  {
1690
- value: parsedValue,
1695
+ value: currentMatchMode,
1696
+ options: items,
1697
+ optionLabel: "label",
1698
+ optionValue: "value",
1699
+ placeholder,
1700
+ style: { width: "100%" },
1691
1701
  onChange: (e) => {
1692
- if (!e.value) {
1693
- options.filterCallback(null, options.index);
1702
+ const newMatchMode = e.value;
1703
+ if (isSpecial(newMatchMode)) {
1704
+ options.filterCallback({
1705
+ text: null,
1706
+ matchMode: newMatchMode
1707
+ });
1694
1708
  return;
1695
1709
  }
1696
- const date = e.value;
1697
- const valueToFilter = mask ? mask(date) : `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(
1698
- 2,
1699
- "0"
1700
- )}-${String(date.getDate()).padStart(2, "0")}`;
1701
- options.filterCallback(valueToFilter, options.index);
1702
- },
1703
- dateFormat: "dd/mm/yy",
1704
- placeholder: "dd/mm/yyyy",
1705
- mask: "99/99/9999",
1706
- inputClassName: "p-column-filter"
1710
+ options.filterCallback({
1711
+ text: null,
1712
+ matchMode: newMatchMode
1713
+ });
1714
+ }
1707
1715
  }
1708
1716
  );
1709
1717
  };
1710
- var DateTimeFilterTemplate = (options, mask) => {
1711
- const value = typeof options.value === "string" ? moment2(options.value).toDate() : options.value ?? null;
1712
- return /* @__PURE__ */ jsx18(
1713
- Calendar,
1714
- {
1715
- value,
1716
- showTime: true,
1717
- showSeconds: true,
1718
- hourFormat: "24",
1719
- dateFormat: "dd/mm/yy",
1720
- placeholder: "dd/mm/yyyy 00:00:00",
1721
- readOnlyInput: true,
1722
- inputClassName: "p-column-filter",
1723
- onChange: (e) => {
1724
- const selectedDate = e.value;
1725
- if (!selectedDate) {
1726
- options.filterCallback(null, options.index);
1727
- return;
1718
+ var DateFilterTemplate = (options, isLanguagePtBr = true, isNullable = true, items, mask) => {
1719
+ const resolvedItems = items ?? getDefaultFilterMatchOptionsDate(isLanguagePtBr, isNullable);
1720
+ const rawFilter = options.value ?? {};
1721
+ const currentMatchMode = rawFilter.matchMode;
1722
+ const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1723
+ const parsedValue = options.value?.text && typeof options.value.text === "string" ? /* @__PURE__ */ new Date(options.value.text + "T00:00:00") : null;
1724
+ return /* @__PURE__ */ jsxs12("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1725
+ /* @__PURE__ */ jsx18(
1726
+ FilterMatchModeSelect,
1727
+ {
1728
+ options,
1729
+ items: resolvedItems
1730
+ }
1731
+ ),
1732
+ !isSpecial && /* @__PURE__ */ jsx18(
1733
+ Calendar,
1734
+ {
1735
+ value: parsedValue,
1736
+ onChange: (e) => {
1737
+ if (!e.value) {
1738
+ options.filterCallback({
1739
+ text: null,
1740
+ matchMode: currentMatchMode
1741
+ });
1742
+ return;
1743
+ }
1744
+ const date = e.value;
1745
+ const valueToFilter = mask ? mask(date) : `${date.getFullYear()}-${String(
1746
+ date.getMonth() + 1
1747
+ ).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
1748
+ options.filterCallback({
1749
+ text: valueToFilter,
1750
+ matchMode: currentMatchMode
1751
+ });
1752
+ },
1753
+ dateFormat: "dd/mm/yy",
1754
+ placeholder: "dd/mm/yyyy",
1755
+ mask: "99/99/9999",
1756
+ inputClassName: "p-column-filter"
1757
+ }
1758
+ )
1759
+ ] });
1760
+ };
1761
+ var DateTimeFilterTemplate = (options, isLanguagePtBr = true, isNullable = true, mask) => {
1762
+ const items = getDefaultFilterMatchOptionsDate(isLanguagePtBr, isNullable);
1763
+ const rawFilter = options.value ?? {};
1764
+ const currentMatchMode = rawFilter.matchMode;
1765
+ const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1766
+ const value = typeof rawFilter.text === "string" ? moment2(rawFilter.text).toDate() : null;
1767
+ return /* @__PURE__ */ jsxs12("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1768
+ /* @__PURE__ */ jsx18(
1769
+ FilterMatchModeSelect,
1770
+ {
1771
+ options,
1772
+ items
1773
+ }
1774
+ ),
1775
+ !isSpecial && /* @__PURE__ */ jsx18(
1776
+ Calendar,
1777
+ {
1778
+ value,
1779
+ showTime: true,
1780
+ showSeconds: true,
1781
+ hourFormat: "24",
1782
+ dateFormat: "dd/mm/yy",
1783
+ placeholder: "dd/mm/yyyy 00:00:00",
1784
+ readOnlyInput: true,
1785
+ inputClassName: "p-column-filter",
1786
+ onChange: (e) => {
1787
+ const selectedDate = e.value;
1788
+ if (!selectedDate) {
1789
+ options.filterCallback({
1790
+ text: null,
1791
+ matchMode: currentMatchMode
1792
+ });
1793
+ return;
1794
+ }
1795
+ const formatted = mask ? mask(selectedDate) : moment2(selectedDate).utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
1796
+ options.filterCallback({
1797
+ text: formatted,
1798
+ matchMode: currentMatchMode
1799
+ });
1728
1800
  }
1729
- const formatted = mask ? mask(selectedDate) : moment2(selectedDate).utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
1730
- options.filterCallback(formatted, options.index);
1731
1801
  }
1732
- }
1733
- );
1802
+ )
1803
+ ] });
1734
1804
  };
1735
1805
  var ValueFilterTemplate = (options, mask) => {
1736
1806
  const parsedValue = options.value !== null && options.value !== void 0 ? centsToReal(options.value) : null;
@@ -1757,7 +1827,6 @@ var ValueFilterTemplate = (options, mask) => {
1757
1827
  };
1758
1828
  var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
1759
1829
  const selectOptions = items.length > 0 ? items : [
1760
- { label: isLanguagePtBr ? "Todos" : "All", value: null },
1761
1830
  { label: isLanguagePtBr ? "Sim" : "Yes", value: true },
1762
1831
  { label: isLanguagePtBr ? "N\xE3o" : "No", value: false }
1763
1832
  ];
@@ -1768,7 +1837,7 @@ var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
1768
1837
  options: selectOptions,
1769
1838
  value: currentValue,
1770
1839
  onChange: (selected) => options.filterCallback(selected?.value),
1771
- placeholder: "Todos",
1840
+ placeholder: "Selecione...",
1772
1841
  isClearable: false,
1773
1842
  isSearchable: false,
1774
1843
  className: "custom-select-filtro",
@@ -1821,69 +1890,30 @@ var CustomFilterElement = (options, isLanguagePtBr = true, items) => {
1821
1890
  const currentMatchMode = rawFilter.matchMode ?? "contains";
1822
1891
  const currentValue = typeof rawFilter.text === "string" ? rawFilter.text : "";
1823
1892
  const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
1824
- return /* @__PURE__ */ jsxs12(
1825
- "div",
1826
- {
1827
- className: "filter-wrapper",
1828
- style: {
1829
- display: "flex",
1830
- flexDirection: "column",
1831
- gap: "8px",
1832
- minWidth: "200px"
1833
- },
1834
- children: [
1835
- /* @__PURE__ */ jsx18(
1836
- Dropdown,
1837
- {
1838
- value: currentMatchMode,
1839
- options: resolvedItems,
1840
- optionLabel: "label",
1841
- optionValue: "value",
1842
- placeholder: "Tipo de filtro",
1843
- style: { width: "100%" },
1844
- onChange: (e) => {
1845
- const newMatchMode = e.value;
1846
- const isNewSpecial = newMatchMode === customMatchModes.empty || newMatchMode === customMatchModes.notEmpty;
1847
- if (isNewSpecial) {
1848
- options.filterCallback({
1849
- text: null,
1850
- matchMode: newMatchMode
1851
- });
1852
- return;
1853
- }
1854
- options.filterCallback({
1855
- text: null,
1856
- matchMode: newMatchMode
1857
- });
1858
- }
1859
- }
1860
- ),
1861
- !isSpecial && /* @__PURE__ */ jsx18(
1862
- InputText,
1863
- {
1864
- value: currentValue,
1865
- placeholder: isLanguagePtBr ? "Pesquisar" : "Search",
1866
- style: { width: "100%" },
1867
- className: "p-column-filter",
1868
- onChange: (e) => {
1869
- const value = e.target.value;
1870
- if (value.trim()) {
1871
- options.filterCallback({
1872
- text: value,
1873
- matchMode: currentMatchMode
1874
- });
1875
- } else {
1876
- options.filterCallback({
1877
- text: null,
1878
- matchMode: currentMatchMode
1879
- });
1880
- }
1881
- }
1882
- }
1883
- )
1884
- ]
1885
- }
1886
- );
1893
+ return /* @__PURE__ */ jsxs12("div", { className: "filter-wrapper", style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
1894
+ /* @__PURE__ */ jsx18(
1895
+ FilterMatchModeSelect,
1896
+ {
1897
+ options,
1898
+ items: resolvedItems
1899
+ }
1900
+ ),
1901
+ !isSpecial && /* @__PURE__ */ jsx18(
1902
+ InputText,
1903
+ {
1904
+ value: currentValue,
1905
+ placeholder: isLanguagePtBr ? "Pesquisar" : "Search",
1906
+ className: "p-column-filter",
1907
+ onChange: (e) => {
1908
+ const value = e.target.value;
1909
+ options.filterCallback({
1910
+ text: value.trim() ? value : null,
1911
+ matchMode: currentMatchMode
1912
+ });
1913
+ }
1914
+ }
1915
+ )
1916
+ ] });
1887
1917
  };
1888
1918
 
1889
1919
  // src/components/DataTableAdvancedFilter/filterModes.ts
@@ -2036,6 +2066,40 @@ var buildFilterPayload = (fieldName, matchMode, rawValue) => {
2036
2066
  }
2037
2067
  };
2038
2068
  }
2069
+ if (matchMode === "dateBeforeAndEquals") {
2070
+ if (normalized === null) return null;
2071
+ return {
2072
+ or: [
2073
+ {
2074
+ field: fieldName,
2075
+ operator: "LessThan",
2076
+ value: normalized
2077
+ },
2078
+ {
2079
+ field: fieldName,
2080
+ operator: "Equals",
2081
+ value: normalized
2082
+ }
2083
+ ]
2084
+ };
2085
+ }
2086
+ if (matchMode === "dateAfterAndEquals") {
2087
+ if (normalized === null) return null;
2088
+ return {
2089
+ or: [
2090
+ {
2091
+ field: fieldName,
2092
+ operator: "GreaterThan",
2093
+ value: normalized
2094
+ },
2095
+ {
2096
+ field: fieldName,
2097
+ operator: "Equals",
2098
+ value: normalized
2099
+ }
2100
+ ]
2101
+ };
2102
+ }
2039
2103
  if (normalized === null) return null;
2040
2104
  if (matchMode === "notStartsWith" || matchMode === "notEndsWith" || matchMode === "notEquals" || // <- notEquals
2041
2105
  matchMode === "dateIsNot" || matchMode === "notContains") {
@@ -2071,11 +2135,9 @@ var buildFilterPayload = (fieldName, matchMode, rawValue) => {
2071
2135
  };
2072
2136
  var mapPrimeToBackendFilters = (filters, globalFilterFields) => {
2073
2137
  const finalAnd = [];
2074
- const globalOr = [];
2075
2138
  const camposMap = {};
2076
2139
  Object.entries(filters).forEach(([field, config]) => {
2077
2140
  if (!config) return;
2078
- const value = config?.value?.text ?? config?.value;
2079
2141
  if (field === "global" && typeof config.value === "string" && config.value.trim() !== "") {
2080
2142
  const globalOrNodes = [];
2081
2143
  globalFilterFields.forEach((globalField) => {
@@ -2279,6 +2341,7 @@ export {
2279
2341
  DateFilterTemplate,
2280
2342
  DateTimeFilterTemplate,
2281
2343
  FilterMatchMode5 as FilterMatchMode,
2344
+ FilterMatchModeSelect,
2282
2345
  FilterOperator2 as FilterOperator,
2283
2346
  Input,
2284
2347
  InputAutoComplete,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charlesgomes/leafcode-shared-lib-react",
3
- "version": "1.0.65",
3
+ "version": "1.0.68",
4
4
  "description": "Lib de componentes react",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",