@dartech/arsenal-ui 1.4.23 → 1.4.25
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/index.js +20 -11
- package/package.json +1 -1
package/index.js
CHANGED
@@ -810,7 +810,6 @@ const ControlAutocomplete = _a => {
|
|
810
810
|
};
|
811
811
|
|
812
812
|
function ControlQueryAutocomplete(_a) {
|
813
|
-
var _b;
|
814
813
|
var {
|
815
814
|
name,
|
816
815
|
label,
|
@@ -832,7 +831,7 @@ function ControlQueryAutocomplete(_a) {
|
|
832
831
|
requiredErrorText = ''
|
833
832
|
} = _a,
|
834
833
|
autocompleteProps = __rest(_a, ["name", "label", "control", "required", "searchBy", "labelKey", "multiple", "disabled", "valueKey", "sortBy", "hideErrorMessage", "disableCloseOnSelect", "textFieldProps", "onChange", "queryFunction", "validate", "itemQueryFunction", "requiredErrorText"]);
|
835
|
-
const
|
834
|
+
const _b = useController({
|
836
835
|
control,
|
837
836
|
name,
|
838
837
|
defaultValue: multiple ? [] : null,
|
@@ -841,19 +840,19 @@ function ControlQueryAutocomplete(_a) {
|
|
841
840
|
validate
|
842
841
|
}
|
843
842
|
}),
|
844
|
-
|
843
|
+
_c = _b.field,
|
845
844
|
{
|
846
845
|
ref,
|
847
846
|
onChange: setFieldValue,
|
848
847
|
value: formValue
|
849
|
-
} =
|
850
|
-
fieldProps = __rest(
|
848
|
+
} = _c,
|
849
|
+
fieldProps = __rest(_c, ["ref", "onChange", "value"]),
|
851
850
|
{
|
852
851
|
fieldState: {
|
853
852
|
error,
|
854
853
|
isDirty
|
855
854
|
}
|
856
|
-
} =
|
855
|
+
} = _b;
|
857
856
|
const {
|
858
857
|
getOptionLabel,
|
859
858
|
isOptionEqualToValue,
|
@@ -862,6 +861,7 @@ function ControlQueryAutocomplete(_a) {
|
|
862
861
|
valueKey,
|
863
862
|
labelKey
|
864
863
|
});
|
864
|
+
const [options, setOptions] = useState([]);
|
865
865
|
const [open, setOpen] = useState(false);
|
866
866
|
const [inputValue, setInputValue] = useState('');
|
867
867
|
const [searchValue, setSearchValue] = useState('');
|
@@ -880,6 +880,15 @@ function ControlQueryAutocomplete(_a) {
|
|
880
880
|
ignoreQueryPrefix: true
|
881
881
|
});
|
882
882
|
return queryFunction(params);
|
883
|
+
}, {
|
884
|
+
// keepPreviousData: true,
|
885
|
+
onSuccess(data) {
|
886
|
+
if (searchValue) {
|
887
|
+
setOptions(data.collection);
|
888
|
+
} else {
|
889
|
+
setOptions(state => state.length === 1 ? data.collection : [...state, ...data.collection]);
|
890
|
+
}
|
891
|
+
}
|
883
892
|
});
|
884
893
|
const debouncedChange = useDebounce(val => {
|
885
894
|
setPage(0);
|
@@ -895,6 +904,7 @@ function ControlQueryAutocomplete(_a) {
|
|
895
904
|
onChange(event, value);
|
896
905
|
}
|
897
906
|
}, [setFieldValue, onChange]);
|
907
|
+
console.log(isDirty, formValue, searchValue);
|
898
908
|
useEffect(() => {
|
899
909
|
if (!isDirty && formValue && itemQueryFunction) {
|
900
910
|
let requestValue = formValue;
|
@@ -904,15 +914,15 @@ function ControlQueryAutocomplete(_a) {
|
|
904
914
|
itemQueryFunction(requestValue).then(item => {
|
905
915
|
setFieldValue(item);
|
906
916
|
setInputValue(_get(item, labelKey));
|
907
|
-
}).catch();
|
917
|
+
}).catch(console.error);
|
908
918
|
}
|
909
919
|
}, [formValue, isDirty, valueKey, labelKey, itemQueryFunction, setFieldValue]);
|
910
920
|
const handleOnScroll = useCallback(event => {
|
911
921
|
const listboxNode = event.currentTarget;
|
912
|
-
if (listboxNode.scrollHeight - listboxNode.scrollTop - listboxNode.clientHeight <= 1 &&
|
922
|
+
if (listboxNode.scrollHeight - listboxNode.scrollTop - listboxNode.clientHeight <= 1 && options.length < (data === null || data === void 0 ? void 0 : data.totalItems)) {
|
913
923
|
setPage(page => page + 1);
|
914
924
|
}
|
915
|
-
}, [data]);
|
925
|
+
}, [data, options]);
|
916
926
|
const handleOpen = () => {
|
917
927
|
setOpen(true);
|
918
928
|
};
|
@@ -925,7 +935,7 @@ function ControlQueryAutocomplete(_a) {
|
|
925
935
|
disablePortal: true,
|
926
936
|
size: "small",
|
927
937
|
readOnly: disabled,
|
928
|
-
options:
|
938
|
+
options: options,
|
929
939
|
multiple: multiple,
|
930
940
|
getOptionLabel: getOptionLabel,
|
931
941
|
isOptionEqualToValue: isOptionEqualToValue,
|
@@ -2106,7 +2116,6 @@ const ControlDate = _a => {
|
|
2106
2116
|
rules: {
|
2107
2117
|
required: required ? requiredErrorText || DEFAULT_REQUIRED_ERROR_TEXT : false,
|
2108
2118
|
validate: val => {
|
2109
|
-
console.log('DATE', val);
|
2110
2119
|
if (val === '' || isMatch(val, localFormat)) {
|
2111
2120
|
return true;
|
2112
2121
|
}
|