@flozy/editor 9.9.2 → 9.9.3
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.
@@ -30,6 +30,7 @@ const SearchButton = /*#__PURE__*/forwardRef((props, ref) => {
|
|
30
30
|
const [skip, setSkip] = useState(0);
|
31
31
|
const [search, setSearch] = useState("");
|
32
32
|
const [isLoading, setIsLoading] = useState(false);
|
33
|
+
const [total, setTotal] = useState(0);
|
33
34
|
const [debouncedSearch] = useDebounce(search, 300);
|
34
35
|
const limit = 20;
|
35
36
|
const observer = useRef();
|
@@ -63,24 +64,24 @@ const SearchButton = /*#__PURE__*/forwardRef((props, ref) => {
|
|
63
64
|
}
|
64
65
|
};
|
65
66
|
useEffect(() => {
|
66
|
-
getDocs(
|
67
|
-
debouncedSearch,
|
68
|
-
skip,
|
69
|
-
limit,
|
70
|
-
current_doc_id: currentId
|
71
|
-
});
|
67
|
+
getDocs();
|
72
68
|
}, [skip, debouncedSearch]);
|
73
69
|
const getDocs = async () => {
|
70
|
+
if (isLoading) return;
|
71
|
+
if (total > 0 && mapData?.length >= total) return;
|
74
72
|
setIsLoading(true);
|
75
73
|
try {
|
76
74
|
if (otherProps?.services) {
|
77
75
|
const result = await otherProps?.services("getDocs", {
|
78
76
|
skip,
|
79
77
|
limit,
|
80
|
-
search,
|
78
|
+
search: debouncedSearch,
|
81
79
|
current_doc_id: currentId
|
82
80
|
});
|
83
|
-
|
81
|
+
const docs = result?.data?.docs || [];
|
82
|
+
const totalCount = result?.data?.total || 0;
|
83
|
+
setMapData(prev => skip === 0 ? docs : [...prev, ...docs]);
|
84
|
+
setTotal(totalCount);
|
84
85
|
}
|
85
86
|
} catch (error) {
|
86
87
|
console.error("Error fetching documents:", error);
|
@@ -259,7 +259,7 @@ const SearchAndDocList = ({
|
|
259
259
|
xs: 12,
|
260
260
|
children: /*#__PURE__*/_jsx(Typography, {
|
261
261
|
sx: {
|
262
|
-
display: mapData?.length === 0 ? 'flex' : 'none',
|
262
|
+
display: mapData?.length === 0 && !isLoading ? 'flex' : 'none',
|
263
263
|
alignItems: "center",
|
264
264
|
justifyContent: "center",
|
265
265
|
color: theme?.palette?.text?.secondary,
|
@@ -269,15 +269,17 @@ const SearchAndDocList = ({
|
|
269
269
|
},
|
270
270
|
children: "No docs"
|
271
271
|
})
|
272
|
-
}),
|
272
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
273
273
|
item: true,
|
274
|
+
xs: 12,
|
274
275
|
sx: {
|
275
|
-
display:
|
276
|
+
display: isLoading ? 'flex' : 'none',
|
277
|
+
alignItems: "center",
|
276
278
|
justifyContent: "center",
|
277
|
-
|
278
|
-
|
279
|
-
padding: '
|
280
|
-
|
279
|
+
color: theme?.palette?.text?.secondary,
|
280
|
+
fontSize: '12px',
|
281
|
+
padding: '20px',
|
282
|
+
fontWeight: 700
|
281
283
|
},
|
282
284
|
children: /*#__PURE__*/_jsx(CircularProgress, {})
|
283
285
|
})]
|