@front10/utils
Advanced tools
Comparing version 0.100.2 to 0.101.0
@@ -6,2 +6,10 @@ # Change Log | ||
# [0.101.0](https://gitlab.com/front10-dev/front10-helpers/compare/v0.100.3...v0.101.0) (2021-07-28) | ||
**Note:** Version bump only for package @front10/utils | ||
# [0.100.0](https://gitlab.com/front10-dev/front10-helpers/compare/v0.99.1...v0.100.0) (2021-06-14) | ||
@@ -8,0 +16,0 @@ |
@@ -15,2 +15,3 @@ export declare function isPromise(result: Promise<unknown> | unknown): result is Promise<unknown>; | ||
}; | ||
export declare const defaultDataSource: DataSourceFn<any, any>; | ||
export declare const paginatedDataSource: <T>(data: T[], response?: Response | undefined) => DataSourceFn<any, DataSet<T>>; | ||
@@ -17,0 +18,0 @@ declare type DataSources<Props, Result> = DataSourceFn<Props, DataSet<Result>> | DataSet<Result> | Result[] | string; |
{ | ||
"name": "@front10/utils", | ||
"version": "0.100.2", | ||
"version": "0.101.0", | ||
"description": "Helpers for front10 components", | ||
@@ -58,3 +58,3 @@ "author": "Front10", | ||
}, | ||
"gitHead": "8da18e935f9f760599b47f6f7b70eea6ba9c61a1" | ||
"gitHead": "1fd813577ba6e6f3b7c09c7377b8c5d61d7e2cc9" | ||
} |
@@ -53,2 +53,11 @@ import * as React from "react"; | ||
export const defaultDataSource: DataSourceFn<any, any> = ({ | ||
integrationSettings: { url, ...integrationSettings }, | ||
}) => { | ||
const searchParams = new URLSearchParams(integrationSettings); | ||
return fetch(`${url}?${searchParams.toString()}`).then((response) => | ||
response.json() | ||
); | ||
}; | ||
export const paginatedDataSource = <T>( | ||
@@ -113,3 +122,6 @@ data: T[], | ||
const fn = getDataSource(transformedDataSource); | ||
if (typeof transformedDataSource === "string") { | ||
if ( | ||
typeof transformedDataSource === "string" || | ||
typeof transformedDataSource === "function" | ||
) { | ||
const fnData = async ({ query, ...props }: any) => { | ||
@@ -126,5 +138,7 @@ const result = await fn(props); | ||
const [key] = React.useState(() => | ||
typeof dataSource === "string" ? dataSource : nanoid() | ||
); | ||
const [key] = React.useState(() => { | ||
if (typeof dataSource === "string") return dataSource; | ||
if (props.integrationSettings?.url) return ""; | ||
return nanoid(); | ||
}); | ||
@@ -131,0 +145,0 @@ return useInfiniteQuery( |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
333895
9008
6