@sqrzro/ui 4.0.0-alpha.15 → 4.0.0-alpha.16

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.
@@ -4,6 +4,7 @@ import type { EmptyMessageProps } from '../EmptyMessage';
4
4
  import type { ListFunctionConfig, Paginated } from '../interfaces';
5
5
  export interface CollectionComponentProps<Item, Transformed, Filters = null> {
6
6
  readonly data?: Item[] | Paginated<Item>;
7
+ readonly defaultFilters?: Partial<Filters>;
7
8
  readonly emptyMessageProps?: EmptyMessageProps;
8
9
  readonly filterMap?: FilterMap<Filters>;
9
10
  readonly fn?: (config: ListFunctionConfig<Filters>) => Promise<Item[]> | Promise<Paginated<Item>>;
@@ -10,7 +10,7 @@ import EmptyMessage from '../EmptyMessage';
10
10
  import Pagination from '../Pagination';
11
11
  import isPaginated from '../utility/is-paginated';
12
12
  import { messages } from '../lang';
13
- async function CollectionComponent({ data, emptyMessageProps, filterMap, fn, pageProps, render, transformer, }) {
13
+ async function CollectionComponent({ data, defaultFilters, emptyMessageProps, filterMap, fn, pageProps, render, transformer, }) {
14
14
  const EmptyIcon = getIcon('collection.empty');
15
15
  const awaitedParams = pageProps?.params ? await pageProps.params : null;
16
16
  const awaitedSearchParams = pageProps?.searchParams ? await pageProps.searchParams : null;
@@ -23,7 +23,7 @@ async function CollectionComponent({ data, emptyMessageProps, filterMap, fn, pag
23
23
  }
24
24
  const filters = parseFilters(awaitedSearchParams, filterMap);
25
25
  const page = parsePage(awaitedSearchParams);
26
- return fn({ filters, page, params: awaitedParams });
26
+ return fn({ filters: { ...defaultFilters, ...filters }, page, params: awaitedParams });
27
27
  }
28
28
  const response = await getResponse();
29
29
  const dynamicData = (isPaginated(response) ? response.data : response).map(transformer);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqrzro/ui",
3
3
  "type": "module",
4
- "version": "4.0.0-alpha.15",
4
+ "version": "4.0.0-alpha.16",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "ISC",