@algorithm-shift/design-system 1.2.970 → 1.2.971
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/dist/index.js +45 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27887,14 +27887,46 @@ function useLazyDropdown(config) {
|
|
|
27887
27887
|
};
|
|
27888
27888
|
});
|
|
27889
27889
|
}, []);
|
|
27890
|
+
function extractAndEnforceUrlParams(apiUrl, enforceStrict) {
|
|
27891
|
+
const urlObj = new URL(
|
|
27892
|
+
apiUrl,
|
|
27893
|
+
typeof window !== "undefined" ? window.location.origin : "http://localhost"
|
|
27894
|
+
);
|
|
27895
|
+
const cleaned = {};
|
|
27896
|
+
let hasEmpty = false;
|
|
27897
|
+
const baseUrl = urlObj.origin + urlObj.pathname;
|
|
27898
|
+
urlObj.searchParams.forEach((value, key) => {
|
|
27899
|
+
const isEmpty = value === "" || value === void 0 || value === null;
|
|
27900
|
+
if (isEmpty) {
|
|
27901
|
+
hasEmpty = true;
|
|
27902
|
+
if (enforceStrict) return;
|
|
27903
|
+
return;
|
|
27904
|
+
}
|
|
27905
|
+
cleaned[key] = value;
|
|
27906
|
+
});
|
|
27907
|
+
return {
|
|
27908
|
+
baseUrl,
|
|
27909
|
+
shouldAbort: enforceStrict && hasEmpty,
|
|
27910
|
+
params: cleaned
|
|
27911
|
+
};
|
|
27912
|
+
}
|
|
27890
27913
|
const fetchApiData = (0, import_react19.useCallback)(async (pageNum, term) => {
|
|
27891
27914
|
if (!configRef.current.apiUrl) return [];
|
|
27892
27915
|
const limit = PAGE_SIZE;
|
|
27893
27916
|
const params = { page: pageNum, limit };
|
|
27894
27917
|
if (term) params[configRef.current.dataLabel ? `${configRef.current.dataLabel}[ilike]` : "search[ilike]"] = term;
|
|
27918
|
+
const { baseUrl, shouldAbort, params: urlParams } = extractAndEnforceUrlParams(
|
|
27919
|
+
configRef.current.apiUrl,
|
|
27920
|
+
configRef.current.enforceStrictQueryParams ?? false
|
|
27921
|
+
);
|
|
27922
|
+
if (shouldAbort) {
|
|
27923
|
+
setLoading(false);
|
|
27924
|
+
return [];
|
|
27925
|
+
}
|
|
27926
|
+
const finalParams = { ...urlParams, ...params };
|
|
27895
27927
|
const axiosClient = configRef.current.axiosInstance ?? import_axios.default;
|
|
27896
|
-
const res = await axiosClient.get(
|
|
27897
|
-
params,
|
|
27928
|
+
const res = await axiosClient.get(baseUrl, {
|
|
27929
|
+
params: finalParams,
|
|
27898
27930
|
withCredentials: true
|
|
27899
27931
|
});
|
|
27900
27932
|
if (res.data?.success && Array.isArray(res.data.data)) {
|
|
@@ -27957,8 +27989,17 @@ function useLazyDropdown(config) {
|
|
|
27957
27989
|
[`${configRef.current.dataKey}[in]`]: configRef.current.value.join(",")
|
|
27958
27990
|
};
|
|
27959
27991
|
}
|
|
27960
|
-
const
|
|
27961
|
-
|
|
27992
|
+
const { baseUrl, shouldAbort, params: urlParams } = extractAndEnforceUrlParams(
|
|
27993
|
+
configRef.current.apiUrl,
|
|
27994
|
+
configRef.current.enforceStrictQueryParams ?? false
|
|
27995
|
+
);
|
|
27996
|
+
if (shouldAbort) {
|
|
27997
|
+
setLoading(false);
|
|
27998
|
+
return;
|
|
27999
|
+
}
|
|
28000
|
+
const finalParams = { ...urlParams, ...params };
|
|
28001
|
+
const res = await axiosClient.get(baseUrl, {
|
|
28002
|
+
params: finalParams,
|
|
27962
28003
|
withCredentials: true
|
|
27963
28004
|
});
|
|
27964
28005
|
if (res.data?.success && Array.isArray(res.data.data) && res.data.data.length > 0) {
|