@ssplib/react-components 0.0.234 → 0.0.236

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.
@@ -31,6 +31,7 @@ const lodash_get_1 = __importDefault(require("lodash.get"));
31
31
  const react_1 = __importStar(require("react"));
32
32
  const auth_1 = require("../../../context/auth");
33
33
  const form_1 = require("../../../context/form");
34
+ let useDefault = true;
34
35
  function FetchAutoComplete({ name, url, title, customLoadingText, shouldRefetch = true, required = false, defaultValue, route = '', onChange = () => { }, xs = 12, sm, watchValue, md, }) {
35
36
  const context = (0, react_1.useContext)(form_1.FormContext);
36
37
  const [loading, setLoading] = (0, react_1.useState)(true);
@@ -69,7 +70,7 @@ function FetchAutoComplete({ name, url, title, customLoadingText, shouldRefetch
69
70
  }
70
71
  }, []);
71
72
  (0, react_1.useEffect)(() => {
72
- if (watchValue) {
73
+ if (watchValue && useDefault) {
73
74
  setValue(watchValue);
74
75
  context.formSetValue(name, watchValue.id);
75
76
  onChange(watchValue.id);
@@ -99,6 +100,7 @@ function FetchAutoComplete({ name, url, title, customLoadingText, shouldRefetch
99
100
  });
100
101
  }
101
102
  function handleAutoCompleteChange(value) {
103
+ useDefault = false;
102
104
  if (value) {
103
105
  setValue(value);
104
106
  context.formSetValue(name, value.id);
@@ -31,6 +31,7 @@ const material_1 = require("@mui/material");
31
31
  const lodash_get_1 = __importDefault(require("lodash.get"));
32
32
  const react_1 = __importStar(require("react"));
33
33
  const form_1 = require("../../../context/form");
34
+ let useDefault = true;
34
35
  function FixedAutoComplete({ name, title, required = false, list, defaultValue, onChange = () => { }, xs = 12, sm, watchValue, md, }) {
35
36
  const context = (0, react_1.useContext)(form_1.FormContext);
36
37
  const [value, setValue] = (0, react_1.useState)(null);
@@ -39,13 +40,14 @@ function FixedAutoComplete({ name, title, required = false, list, defaultValue,
39
40
  context === null || context === void 0 ? void 0 : context.formSetValue(name, defaultValue.id);
40
41
  }, []);
41
42
  (0, react_1.useEffect)(() => {
42
- if (watchValue) {
43
+ if (watchValue && useDefault) {
43
44
  setValue(watchValue);
44
45
  context.formSetValue(name, watchValue.id);
45
46
  onChange(watchValue.id);
46
47
  }
47
48
  }, [watchValue]);
48
49
  function handleAutoCompleteChange(value) {
50
+ useDefault = false;
49
51
  if (value) {
50
52
  setValue(value);
51
53
  context.formSetValue(name, value.id);
@@ -515,8 +515,15 @@ hideTitleCSV = false, csvExcludeUpper = [], multipleDataPath = '', expandTextMax
515
515
  case 'igual':
516
516
  currentData.forEach((cd) => {
517
517
  const value = (0, lodash_get_1.default)(cd, dt.keyName, '');
518
- if (formatarString(value) === formatarString(dt.value)) {
519
- filteredData.push(cd);
518
+ if (dt.useList) {
519
+ if (formatarString(value) === formatarString(dt.value.id)) {
520
+ filteredData.push(cd);
521
+ }
522
+ }
523
+ else {
524
+ if (formatarString(value) === formatarString(dt.value)) {
525
+ filteredData.push(cd);
526
+ }
520
527
  }
521
528
  });
522
529
  break;
@@ -958,6 +965,7 @@ function FilterField({ filterValue, operator, onChange }) {
958
965
  onChange(value);
959
966
  }, options: filterValue.useList, defaultValue: Array.isArray(filterValue.value) ? filterValue.value : [], renderInput: (params) => react_1.default.createElement(TextField_1.default, Object.assign({}, params, { variant: 'standard', placeholder: 'Escolha os valores', fullWidth: true })), fullWidth: true }));
960
967
  case 'contem':
968
+ case 'igual':
961
969
  return (react_1.default.createElement(material_1.Box, { width: '100%' },
962
970
  react_1.default.createElement(material_1.Autocomplete, { options: filterValue.useList, onChange: (e, value) => {
963
971
  onChange(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.234",
3
+ "version": "0.0.236",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",