@charlesgomes/leafcode-shared-lib-react 1.0.85 → 1.0.87

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
@@ -253,11 +253,11 @@ declare const getNullableCollection: (isLanguagePtBr: boolean) => {
253
253
  declare const mapPrimeToBackendFilters: (filters: any, globalFilterFields: string[]) => {
254
254
  and: any[];
255
255
  } | undefined;
256
- type CampoDinamico = {
256
+ type DynamicField = {
257
257
  id: string;
258
- tipoDado: string;
258
+ documentType: string;
259
259
  };
260
- declare function buildDynamicCampoFilters(campos: CampoDinamico[]): Record<string, any>;
260
+ declare function buildDynamicFieldFilters(fields: DynamicField[]): Record<string, any>;
261
261
  declare const getUrlParams: (sortFieldInitial: string, sortOrderInitial: 1 | -1) => {
262
262
  page: number;
263
263
  rows: number;
@@ -360,4 +360,4 @@ declare const LeafcodeThemeProvider: ({ children, theme, }: LeafcodeThemeProvide
360
360
 
361
361
  declare const defaultTheme: LeafcodeTheme;
362
362
 
363
- 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, getDefaultFilterMatchOptionsNumber, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getNullableCollection, getUrlParams, isSpecialMatchMode, mapPrimeToBackendFilters };
363
+ 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, buildDynamicFieldFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsNumber, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getNullableCollection, getUrlParams, isSpecialMatchMode, mapPrimeToBackendFilters };
package/dist/index.d.ts CHANGED
@@ -253,11 +253,11 @@ declare const getNullableCollection: (isLanguagePtBr: boolean) => {
253
253
  declare const mapPrimeToBackendFilters: (filters: any, globalFilterFields: string[]) => {
254
254
  and: any[];
255
255
  } | undefined;
256
- type CampoDinamico = {
256
+ type DynamicField = {
257
257
  id: string;
258
- tipoDado: string;
258
+ documentType: string;
259
259
  };
260
- declare function buildDynamicCampoFilters(campos: CampoDinamico[]): Record<string, any>;
260
+ declare function buildDynamicFieldFilters(fields: DynamicField[]): Record<string, any>;
261
261
  declare const getUrlParams: (sortFieldInitial: string, sortOrderInitial: 1 | -1) => {
262
262
  page: number;
263
263
  rows: number;
@@ -360,4 +360,4 @@ declare const LeafcodeThemeProvider: ({ children, theme, }: LeafcodeThemeProvide
360
360
 
361
361
  declare const defaultTheme: LeafcodeTheme;
362
362
 
363
- 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, getDefaultFilterMatchOptionsNumber, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getNullableCollection, getUrlParams, isSpecialMatchMode, mapPrimeToBackendFilters };
363
+ 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, buildDynamicFieldFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsNumber, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getNullableCollection, getUrlParams, isSpecialMatchMode, mapPrimeToBackendFilters };
package/dist/index.js CHANGED
@@ -45,7 +45,7 @@ __export(index_exports, {
45
45
  SelectFilterTemplate: () => SelectFilterTemplate,
46
46
  TextArea: () => TextArea,
47
47
  ValueFilterTemplate: () => ValueFilterTemplate,
48
- buildDynamicCampoFilters: () => buildDynamicCampoFilters,
48
+ buildDynamicFieldFilters: () => buildDynamicFieldFilters,
49
49
  buildSortingWithFilters: () => buildSortingWithFilters,
50
50
  customMatchModes: () => customMatchModes,
51
51
  defaultTheme: () => defaultTheme,
@@ -1885,7 +1885,7 @@ var buildFilterPayload = (fieldName, matchMode, rawValue) => {
1885
1885
  };
1886
1886
  var mapPrimeToBackendFilters = (filters, globalFilterFields) => {
1887
1887
  const finalAnd = [];
1888
- const camposMap = {};
1888
+ const fieldsMap = {};
1889
1889
  Object.entries(filters).forEach(([field, config]) => {
1890
1890
  if (!config) return;
1891
1891
  if (field === "global" && typeof config.value === "string" && config.value.trim() !== "") {
@@ -1918,22 +1918,22 @@ var mapPrimeToBackendFilters = (filters, globalFilterFields) => {
1918
1918
  return;
1919
1919
  }
1920
1920
  const constraints = Array.isArray(config.constraints) ? config.constraints.filter((c) => {
1921
- if (isSpecialMatchMode(c.matchMode)) {
1921
+ const normalized = normalizeFilterValue(c.value);
1922
+ if (normalized === "__NULL__") {
1922
1923
  return true;
1923
1924
  }
1924
- const normalized = normalizeFilterValue(c.value);
1925
- return normalized !== null || normalized === "__NULL__";
1925
+ return normalized !== null;
1926
1926
  }) : [];
1927
1927
  if (!constraints.length) return;
1928
1928
  const colOperator = config.operator === "or" ? "or" : "and";
1929
- if (config.collection === "campos" && config.fieldId) {
1930
- if (!camposMap[config.fieldId]) {
1931
- camposMap[config.fieldId] = { operator: colOperator, values: [] };
1929
+ if (config.collection === "fields" && config.fieldId) {
1930
+ if (!fieldsMap[config.fieldId]) {
1931
+ fieldsMap[config.fieldId] = { operator: colOperator, values: [] };
1932
1932
  }
1933
1933
  constraints.forEach((c) => {
1934
1934
  const effectiveMatchMode = resolveMatchMode(c.matchMode, c.value);
1935
- const payload = buildFilterPayload(config.filterFieldCollection ?? "valor", effectiveMatchMode, c.value);
1936
- if (payload) camposMap[config.fieldId].values.push(payload);
1935
+ const payload = buildFilterPayload(config.filterFieldCollection ?? "value", effectiveMatchMode, c.value);
1936
+ if (payload) fieldsMap[config.fieldId].values.push(payload);
1937
1937
  });
1938
1938
  return;
1939
1939
  }
@@ -1968,13 +1968,13 @@ var mapPrimeToBackendFilters = (filters, globalFilterFields) => {
1968
1968
  }
1969
1969
  finalAnd.push({ [colOperator]: columnPayloads });
1970
1970
  });
1971
- Object.entries(camposMap).forEach(([fieldId, config]) => {
1971
+ Object.entries(fieldsMap).forEach(([fieldId, config]) => {
1972
1972
  if (!config.values.length) return;
1973
1973
  finalAnd.push({
1974
- collection: "campos",
1974
+ collection: "fields",
1975
1975
  any: {
1976
1976
  and: [
1977
- { field: "tipocampo.id", operator: "Equals", value: fieldId },
1977
+ { field: "fieldType.id", operator: "Equals", value: fieldId },
1978
1978
  { [config.operator]: config.values }
1979
1979
  ]
1980
1980
  }
@@ -2006,29 +2006,28 @@ function pushIntoCollectionTree(root, collectionPath, fieldName, payloadBase) {
2006
2006
  field: fieldName
2007
2007
  });
2008
2008
  }
2009
- function getMatchModeByTipo(tipo) {
2010
- switch (tipo) {
2011
- case "NumeroInteiro":
2012
- case "NumeroDecimal":
2009
+ function getMatchModeByTipo(type) {
2010
+ switch (type) {
2011
+ case "Integer":
2012
+ case "Decimal":
2013
2013
  return import_api3.FilterMatchMode.EQUALS;
2014
2014
  default:
2015
2015
  return import_api3.FilterMatchMode.CONTAINS;
2016
2016
  }
2017
2017
  }
2018
- function buildDynamicCampoFilters(campos) {
2019
- return campos?.reduce((acc, campo) => {
2020
- acc[`${campo.id}`] = {
2018
+ function buildDynamicFieldFilters(fields) {
2019
+ return fields?.reduce((acc, field) => {
2020
+ acc[`${field.id}`] = {
2021
2021
  operator: import_api3.FilterOperator.AND,
2022
2022
  constraints: [
2023
2023
  {
2024
2024
  value: null,
2025
- matchMode: getMatchModeByTipo(campo.tipoDado)
2025
+ matchMode: getMatchModeByTipo(field.documentType)
2026
2026
  }
2027
2027
  ],
2028
- collection: "campos",
2029
- filterFieldCollection: "valor",
2030
- fieldId: campo.id
2031
- // opcional (útil pro backend)
2028
+ collection: "fields",
2029
+ filterFieldCollection: "value",
2030
+ fieldId: field.id
2032
2031
  };
2033
2032
  return acc;
2034
2033
  }, {});
@@ -2081,14 +2080,14 @@ function buildSortingWithFilters(filters, sortField, order) {
2081
2080
  if (sortFilter?.fieldId) {
2082
2081
  sorting = [
2083
2082
  {
2084
- collection: "campos",
2083
+ collection: "fields",
2085
2084
  filter: {
2086
- field: "tipocampo.id",
2085
+ field: "fieldType.id",
2087
2086
  operator: "equals",
2088
2087
  value: sortFilter.fieldId
2089
2088
  },
2090
2089
  first: {
2091
- field: "valor",
2090
+ field: "value",
2092
2091
  direction
2093
2092
  }
2094
2093
  }
@@ -2139,7 +2138,7 @@ var DateFilterTemplate = (options, mask) => {
2139
2138
  const isSpecial = isSpecialMatchMode(matchMode);
2140
2139
  if (!isSpecial && value === true) {
2141
2140
  options.filterCallback(
2142
- "",
2141
+ null,
2143
2142
  options.index
2144
2143
  );
2145
2144
  }
@@ -2210,7 +2209,7 @@ var ValueFilterTemplate = (options, mask) => {
2210
2209
  const isSpecial = isSpecialMatchMode(matchMode);
2211
2210
  if (!isSpecial && value === true) {
2212
2211
  options.filterCallback(
2213
- "",
2212
+ null,
2214
2213
  options.index
2215
2214
  );
2216
2215
  }
@@ -2237,7 +2236,7 @@ var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
2237
2236
  const isSpecial = isSpecialMatchMode(matchMode);
2238
2237
  if (!isSpecial && value === true) {
2239
2238
  options.filterCallback(
2240
- "",
2239
+ null,
2241
2240
  options.index
2242
2241
  );
2243
2242
  }
@@ -2269,7 +2268,7 @@ var CustomFilterElement = (options, isLanguagePtBr = true) => {
2269
2268
  const isSpecial = isSpecialMatchMode(matchMode);
2270
2269
  if (!isSpecial && value === true) {
2271
2270
  options.filterCallback(
2272
- "",
2271
+ null,
2273
2272
  options.index
2274
2273
  );
2275
2274
  }
@@ -2474,7 +2473,7 @@ var import_api5 = require("primereact/api");
2474
2473
  SelectFilterTemplate,
2475
2474
  TextArea,
2476
2475
  ValueFilterTemplate,
2477
- buildDynamicCampoFilters,
2476
+ buildDynamicFieldFilters,
2478
2477
  buildSortingWithFilters,
2479
2478
  customMatchModes,
2480
2479
  defaultTheme,
package/dist/index.mjs CHANGED
@@ -1833,7 +1833,7 @@ var buildFilterPayload = (fieldName, matchMode, rawValue) => {
1833
1833
  };
1834
1834
  var mapPrimeToBackendFilters = (filters, globalFilterFields) => {
1835
1835
  const finalAnd = [];
1836
- const camposMap = {};
1836
+ const fieldsMap = {};
1837
1837
  Object.entries(filters).forEach(([field, config]) => {
1838
1838
  if (!config) return;
1839
1839
  if (field === "global" && typeof config.value === "string" && config.value.trim() !== "") {
@@ -1866,22 +1866,22 @@ var mapPrimeToBackendFilters = (filters, globalFilterFields) => {
1866
1866
  return;
1867
1867
  }
1868
1868
  const constraints = Array.isArray(config.constraints) ? config.constraints.filter((c) => {
1869
- if (isSpecialMatchMode(c.matchMode)) {
1869
+ const normalized = normalizeFilterValue(c.value);
1870
+ if (normalized === "__NULL__") {
1870
1871
  return true;
1871
1872
  }
1872
- const normalized = normalizeFilterValue(c.value);
1873
- return normalized !== null || normalized === "__NULL__";
1873
+ return normalized !== null;
1874
1874
  }) : [];
1875
1875
  if (!constraints.length) return;
1876
1876
  const colOperator = config.operator === "or" ? "or" : "and";
1877
- if (config.collection === "campos" && config.fieldId) {
1878
- if (!camposMap[config.fieldId]) {
1879
- camposMap[config.fieldId] = { operator: colOperator, values: [] };
1877
+ if (config.collection === "fields" && config.fieldId) {
1878
+ if (!fieldsMap[config.fieldId]) {
1879
+ fieldsMap[config.fieldId] = { operator: colOperator, values: [] };
1880
1880
  }
1881
1881
  constraints.forEach((c) => {
1882
1882
  const effectiveMatchMode = resolveMatchMode(c.matchMode, c.value);
1883
- const payload = buildFilterPayload(config.filterFieldCollection ?? "valor", effectiveMatchMode, c.value);
1884
- if (payload) camposMap[config.fieldId].values.push(payload);
1883
+ const payload = buildFilterPayload(config.filterFieldCollection ?? "value", effectiveMatchMode, c.value);
1884
+ if (payload) fieldsMap[config.fieldId].values.push(payload);
1885
1885
  });
1886
1886
  return;
1887
1887
  }
@@ -1916,13 +1916,13 @@ var mapPrimeToBackendFilters = (filters, globalFilterFields) => {
1916
1916
  }
1917
1917
  finalAnd.push({ [colOperator]: columnPayloads });
1918
1918
  });
1919
- Object.entries(camposMap).forEach(([fieldId, config]) => {
1919
+ Object.entries(fieldsMap).forEach(([fieldId, config]) => {
1920
1920
  if (!config.values.length) return;
1921
1921
  finalAnd.push({
1922
- collection: "campos",
1922
+ collection: "fields",
1923
1923
  any: {
1924
1924
  and: [
1925
- { field: "tipocampo.id", operator: "Equals", value: fieldId },
1925
+ { field: "fieldType.id", operator: "Equals", value: fieldId },
1926
1926
  { [config.operator]: config.values }
1927
1927
  ]
1928
1928
  }
@@ -1954,29 +1954,28 @@ function pushIntoCollectionTree(root, collectionPath, fieldName, payloadBase) {
1954
1954
  field: fieldName
1955
1955
  });
1956
1956
  }
1957
- function getMatchModeByTipo(tipo) {
1958
- switch (tipo) {
1959
- case "NumeroInteiro":
1960
- case "NumeroDecimal":
1957
+ function getMatchModeByTipo(type) {
1958
+ switch (type) {
1959
+ case "Integer":
1960
+ case "Decimal":
1961
1961
  return FilterMatchMode3.EQUALS;
1962
1962
  default:
1963
1963
  return FilterMatchMode3.CONTAINS;
1964
1964
  }
1965
1965
  }
1966
- function buildDynamicCampoFilters(campos) {
1967
- return campos?.reduce((acc, campo) => {
1968
- acc[`${campo.id}`] = {
1966
+ function buildDynamicFieldFilters(fields) {
1967
+ return fields?.reduce((acc, field) => {
1968
+ acc[`${field.id}`] = {
1969
1969
  operator: FilterOperator.AND,
1970
1970
  constraints: [
1971
1971
  {
1972
1972
  value: null,
1973
- matchMode: getMatchModeByTipo(campo.tipoDado)
1973
+ matchMode: getMatchModeByTipo(field.documentType)
1974
1974
  }
1975
1975
  ],
1976
- collection: "campos",
1977
- filterFieldCollection: "valor",
1978
- fieldId: campo.id
1979
- // opcional (útil pro backend)
1976
+ collection: "fields",
1977
+ filterFieldCollection: "value",
1978
+ fieldId: field.id
1980
1979
  };
1981
1980
  return acc;
1982
1981
  }, {});
@@ -2029,14 +2028,14 @@ function buildSortingWithFilters(filters, sortField, order) {
2029
2028
  if (sortFilter?.fieldId) {
2030
2029
  sorting = [
2031
2030
  {
2032
- collection: "campos",
2031
+ collection: "fields",
2033
2032
  filter: {
2034
- field: "tipocampo.id",
2033
+ field: "fieldType.id",
2035
2034
  operator: "equals",
2036
2035
  value: sortFilter.fieldId
2037
2036
  },
2038
2037
  first: {
2039
- field: "valor",
2038
+ field: "value",
2040
2039
  direction
2041
2040
  }
2042
2041
  }
@@ -2087,7 +2086,7 @@ var DateFilterTemplate = (options, mask) => {
2087
2086
  const isSpecial = isSpecialMatchMode(matchMode);
2088
2087
  if (!isSpecial && value === true) {
2089
2088
  options.filterCallback(
2090
- "",
2089
+ null,
2091
2090
  options.index
2092
2091
  );
2093
2092
  }
@@ -2158,7 +2157,7 @@ var ValueFilterTemplate = (options, mask) => {
2158
2157
  const isSpecial = isSpecialMatchMode(matchMode);
2159
2158
  if (!isSpecial && value === true) {
2160
2159
  options.filterCallback(
2161
- "",
2160
+ null,
2162
2161
  options.index
2163
2162
  );
2164
2163
  }
@@ -2185,7 +2184,7 @@ var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
2185
2184
  const isSpecial = isSpecialMatchMode(matchMode);
2186
2185
  if (!isSpecial && value === true) {
2187
2186
  options.filterCallback(
2188
- "",
2187
+ null,
2189
2188
  options.index
2190
2189
  );
2191
2190
  }
@@ -2217,7 +2216,7 @@ var CustomFilterElement = (options, isLanguagePtBr = true) => {
2217
2216
  const isSpecial = isSpecialMatchMode(matchMode);
2218
2217
  if (!isSpecial && value === true) {
2219
2218
  options.filterCallback(
2220
- "",
2219
+ null,
2221
2220
  options.index
2222
2221
  );
2223
2222
  }
@@ -2421,7 +2420,7 @@ export {
2421
2420
  SelectFilterTemplate,
2422
2421
  TextArea,
2423
2422
  ValueFilterTemplate,
2424
- buildDynamicCampoFilters,
2423
+ buildDynamicFieldFilters,
2425
2424
  buildSortingWithFilters,
2426
2425
  customMatchModes,
2427
2426
  defaultTheme,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charlesgomes/leafcode-shared-lib-react",
3
- "version": "1.0.85",
3
+ "version": "1.0.87",
4
4
  "description": "Lib de componentes react",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",