@ssplib/react-components 0.0.235 → 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);
|