Skip to content

Commit 71f84b0

Browse files
committed
Can pass their own search bar and multiselect
1 parent 6b0d986 commit 71f84b0

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

packages/ui-components/src/postgrest-infinite-scroll.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ interface PostgRESTInfiniteScrollProps extends InfiniteScrollProps<any> {
1212
ascending?: boolean;
1313
filterable?: boolean;
1414
order_key?: string;
15+
SearchBarComponent?: React.ComponentType<{ onChange: (value: string) => void }>;
16+
MultiSelectComponent?: React.ComponentType<{
17+
items: string[];
18+
itemRenderer: ItemRenderer<string>;
19+
itemPredicate: ItemPredicate<string>;
20+
selectedItems: string[];
21+
onItemSelect: (item: string) => void;
22+
tagRenderer: (item: string) => React.ReactNode;
23+
onRemove: (tag: React.ReactNode, index: number) => void;
24+
tagInputProps: any;
25+
popoverProps: any;
26+
}>;
1527
}
1628

1729
export function PostgRESTInfiniteScrollView(
@@ -28,6 +40,8 @@ export function PostgRESTInfiniteScrollView(
2840
params,
2941
route,
3042
order_key,
43+
SearchBarComponent,
44+
MultiSelectComponent,
3145
...rest
3246
} = props;
3347

@@ -36,6 +50,8 @@ export function PostgRESTInfiniteScrollView(
3650
}
3751

3852
const maxId = 2 ** 28; // max allowed with postgREST
53+
const SearchBarToUse = SearchBarComponent ?? SearchBar;
54+
const MultiSelectToUse = MultiSelectComponent ?? MultiSelect;
3955

4056
const res = useAPIResult(route, { limit: 1 });
4157
const [selectedItems, setSelectedItems] = useState<string[]>([]);
@@ -135,10 +151,10 @@ export function PostgRESTInfiniteScrollView(
135151

136152
return h("div.postgrest-infinite-scroll", [
137153
h.if(filterable)("div.search-bar", [
138-
h(SearchBar, {
154+
h(SearchBarToUse, {
139155
onChange: (value) => setFilterValue(value || ""),
140156
}),
141-
h(MultiSelect, {
157+
h(MultiSelectToUse, {
142158
items: keys.filter((item) => !selectedItems.includes(item)),
143159
itemRenderer,
144160
itemPredicate: filterItem,

0 commit comments

Comments
 (0)