Skip to content

Commit c9009a2

Browse files
authored
Merge pull request #129 from UW-Macrostrat/postgrest-scroll
Postgrest scroll 4.3.7
2 parents f22d9ea + 6e858d5 commit c9009a2

File tree

5 files changed

+55
-22
lines changed

5 files changed

+55
-22
lines changed

packages/ui-components/CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
# Changelog
22

3-
## [4.3.6] - 2025-07-10
3+
## [4.3.7] - 2025-07-09
4+
5+
For PostgRESTInfiniteScrollView
6+
7+
- Even better state management
8+
- Handle adding toggles to header
9+
10+
## [4.3.6] - 2025-07-09
11+
12+
For PostgRESTInfiniteScrollView
413

514
- Handle extra params and intitial items
615
- Better state management
716

817
## [4.3.5] - 2025-07-09
918

19+
For PostgRESTInfiniteScrollView
20+
1021
- Fix import issue
1122

1223
## [4.3.4] - 2025-07-09
1324

25+
For PostgRESTInfiniteScrollView
26+
1427
- Fix export issue
1528

1629
## [4.3.3] - 2025-07-03

packages/ui-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/ui-components",
3-
"version": "4.3.6",
3+
"version": "4.3.7",
44
"description": "UI components for React and Blueprint.js",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",

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

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import h from "@macrostrat/hyper";
1+
import hyper from "@macrostrat/hyper";
22
import { InfiniteScrollProps, InfiniteScrollView } from "./infinite-scroll";
33
import { useAPIResult } from "./api";
44
import { useMemo, useState } from "react";
55
import { MultiSelect, ItemRenderer, ItemPredicate } from "@blueprintjs/select";
66
import { MenuItem, Spinner, InputGroup } from "@blueprintjs/core";
7+
import styles from "./postgrest.module.sass";
8+
9+
const h = hyper.styled(styles);
710

811
interface PostgRESTInfiniteScrollProps extends InfiniteScrollProps<any> {
912
id_key: string;
@@ -13,7 +16,7 @@ interface PostgRESTInfiniteScrollProps extends InfiniteScrollProps<any> {
1316
filterable?: boolean;
1417
order_key?: string;
1518
key?: string;
16-
toggles: any;
19+
toggles?: any;
1720
SearchBarComponent?: React.ComponentType<{
1821
onChange: (value: string) => void;
1922
}>;
@@ -48,6 +51,7 @@ export function PostgRESTInfiniteScrollView(
4851
MultiSelectComponent,
4952
extraParams = {},
5053
key,
54+
toggles = null,
5155
...rest
5256
} = props;
5357

@@ -195,27 +199,30 @@ export function PostgRESTInfiniteScrollView(
195199
};
196200

197201
const newKey =
198-
key || `${filterValue}-${selectedItems.join(",")}-${props.toString()}`;
202+
key || `${filterValue}-${selectedItems.join(",")}-${JSON.stringify(props)}`;
199203

200204
return h("div.postgrest-infinite-scroll", [
201-
h.if(filterable)("div.search-bar", [
202-
h(SearchBarToUse, {
203-
onChange: (value) => setFilterValue(value || ""),
204-
}),
205-
h(MultiSelectToUse, {
206-
items: keys.filter((item) => !selectedItems.includes(item)),
207-
itemRenderer,
208-
itemPredicate: filterItem,
209-
selectedItems,
210-
onItemSelect: handleSelect,
211-
tagRenderer: (item) => item,
212-
onRemove: handleRemove,
213-
tagInputProps: {
205+
h("div.header", [
206+
h.if(filterable)("div.search-bar", [
207+
h(SearchBarToUse, {
208+
onChange: (value) => setFilterValue(value || ""),
209+
}),
210+
h(MultiSelectToUse, {
211+
items: keys.filter((item) => !selectedItems.includes(item)),
212+
itemRenderer,
213+
itemPredicate: filterItem,
214+
selectedItems,
215+
onItemSelect: handleSelect,
216+
tagRenderer: (item) => item,
214217
onRemove: handleRemove,
215-
placeholder: "Select a column(s) to filter by...",
216-
},
217-
popoverProps: { minimal: true },
218-
}),
218+
tagInputProps: {
219+
onRemove: handleRemove,
220+
placeholder: "Select a column(s) to filter by...",
221+
},
222+
popoverProps: { minimal: true },
223+
}),
224+
]),
225+
h.if(toggles)("div.toggles", toggles),
219226
]),
220227
h(InfiniteScrollView, {
221228
...rest,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.header
2+
display: flex
3+
width: 100%
4+
justify-content: space-between
5+
align-items: center
6+
gap: 1em
7+
8+
.search-bar
9+
flex: 1 1 auto
10+
11+
.toggles
12+
flex: 0 0 auto

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ Primary.args = {
2424
ascending: true,
2525
route: "https://dev.macrostrat.org/api/pg/sources_metadata",
2626
delay: 100,
27+
toggles: h("h1", "Toggles here"),
2728
};

0 commit comments

Comments
 (0)