@ssplib/react-components 0.0.235 → 0.0.237

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);
@@ -619,6 +619,30 @@ hideTitleCSV = false, csvExcludeUpper = [], multipleDataPath = '', expandTextMax
619
619
  }
620
620
  });
621
621
  break;
622
+ case 'entre':
623
+ currentData.forEach((cd) => {
624
+ var _a;
625
+ const dates = (_a = filtersFuncData[dt.customFunc]((0, lodash_get_1.default)(cd, dt.keyName, ''))) !== null && _a !== void 0 ? _a : [];
626
+ const dateA = (0, dayjs_1.default)(dt.value, 'DD/MM/YYYY');
627
+ const dateB = (0, dayjs_1.default)(dt.value2, 'DD/MM/YYYY');
628
+ let isBetween = false;
629
+ if (!dateA.isValid() || !dateB.isValid())
630
+ return;
631
+ dates.forEach((dtStr) => {
632
+ if (isBetween)
633
+ return;
634
+ const dt = (0, dayjs_1.default)(dtStr, 'DD/MM/YYYY');
635
+ if (!dt.isValid())
636
+ return;
637
+ if ((dt.isAfter(dateA) || dt.isSame(dateA)) && (dt.isBefore(dateB) || dt.isSame(dateB))) {
638
+ isBetween = true;
639
+ }
640
+ });
641
+ if (isBetween) {
642
+ filteredData.push(cd);
643
+ }
644
+ });
645
+ break;
622
646
  }
623
647
  break;
624
648
  }
@@ -747,7 +771,9 @@ hideTitleCSV = false, csvExcludeUpper = [], multipleDataPath = '', expandTextMax
747
771
  ? x.value.map((x) => x.label).join(' - ')
748
772
  : typeof x.value === 'object'
749
773
  ? x.value.label
750
- : x.value.toString()),
774
+ : x.value2
775
+ ? `${x.value} e ${x.value2}`
776
+ : x.value.toString()),
751
777
  react_1.default.createElement(material_1.IconButton, { onClick: (e) => {
752
778
  var _a;
753
779
  let currentValue = JSON.parse((_a = localStorage.getItem(localTableName)) !== null && _a !== void 0 ? _a : '[]');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.235",
3
+ "version": "0.0.237",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",