feat(DataSource): Allow for dynamic data source configuration and creation (#3543)

This commit is contained in:
Joe Boccanfuso authored and GitHub committed 2023-07-20 11:43:05 -04:00
1 parent 6d88978710
commit 7bbc213f58
36 files changed
+640 -298

No files matched your search

+2 -3
View File
@@ -1,5 +1,4 @@
import useDebounce from './useDebounce.js';
import useQuery from './useQuery.js';
import useSearchParams from './useSearchParams.js';
import useSearchParams from './useSearchParams';
export { useDebounce, useQuery, useSearchParams };
export { useDebounce, useSearchParams };
-5
View File
@@ -1,5 +0,0 @@
import { useLocation } from 'react-router-dom';
export default function useQuery() {
return new URLSearchParams(useLocation().search);
}
-17
View File
@@ -1,17 +0,0 @@
import useQuery from './useQuery';
/**
* It returns a Map of the query parameters in the URL, where the keys are
* lowercase
* @returns A function that returns a Map of the query parameters.
*/
export default function useSearchParams() {
const query = useQuery();
// make query params case-insensitive
const searchParams = new Map();
for (const [key, value] of query) {
searchParams.set(key.toLowerCase(), value);
}
return searchParams;
}
+24
View File
@@ -0,0 +1,24 @@
import { useLocation } from 'react-router';
/**
* It returns a URLSearchParams of the query parameters in the URL, where the keys are
* either lowercase or maintain their case based on the lowerCaseKeys parameter.
* @param {lowerCaseKeys:boolean} true to return lower case keys; false (default) to maintain casing;
* @returns {URLSearchParams}
*/
export default function useSearchParams(options = { lowerCaseKeys: false }) {
const { lowerCaseKeys } = options;
const searchParams = new URLSearchParams(useLocation().search);
if (!lowerCaseKeys) {
return searchParams;
}
const lowerCaseSearchParams = new URLSearchParams();
for (const [key, value] of searchParams) {
lowerCaseSearchParams.set(key.toLowerCase(), value);
}
return lowerCaseSearchParams;
}