Skip to content

Commit 60c5ab1

Browse files
authored
Merge pull request #200 from UW-Macrostrat/data-sheet-fixes
Package updates
2 parents 8967a8d + 13ee84b commit 60c5ab1

File tree

22 files changed

+418
-415
lines changed

22 files changed

+418
-415
lines changed

packages/column-components/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format
44
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
55
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.5.1] - 2026-01-17
8+
9+
- Modernized color picker component
10+
- Remove last `findDOMNode` usage for React 19 compatibility
11+
712
## [1.5.0] - 2026-01-17
813

914
Remove outdated `react-images` dependency and convert `PhotoViewer` component to

packages/column-components/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/column-components",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"description": "React rendering primitives for stratigraphic columns",
55
"keywords": [
66
"geology",
@@ -52,6 +52,7 @@
5252
"@macrostrat/stratigraphy-utils": "workspace:^",
5353
"@macrostrat/timescale": "workspace:^",
5454
"@macrostrat/ui-components": "workspace:^",
55+
"@uiw/react-color-swatch": "^2.9.2",
5556
"chroma-js": "^2.1.0",
5657
"classnames": "^2.2.6",
5758
"d3-axis": "^3.0.0",
@@ -61,7 +62,6 @@
6162
"d3-selection": "^3.0.0",
6263
"immutability-helper": "^3.0.2",
6364
"labella": "^1.1.4",
64-
"react-color": "^2.18.0",
6565
"react-draggable": "^4.4.5",
6666
"react-scroll": "^1.7.16",
6767
"react-select": "^3.0.8",

packages/column-components/src/edit-overlay.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
import { findDOMNode } from "react-dom";
21
import { format } from "d3-format";
3-
import { Component, useContext, MouseEvent, ReactNode } from "react";
2+
import {
3+
Component,
4+
useContext,
5+
MouseEvent,
6+
ReactNode,
7+
createRef,
8+
RefObject,
9+
} from "react";
410
import h from "./hyper";
511
import { Popover, Position, Button, Intent } from "@blueprintjs/core";
612
import {
@@ -138,6 +144,8 @@ export class DivisionEditOverlay extends Component<
138144
popoverWidth: 340,
139145
};
140146

147+
elementRef: RefObject<HTMLDivElement>;
148+
141149
timeout: any;
142150
declare context: ColumnLayoutCtx<ColumnDivision>;
143151
constructor(props: DivisionEditOverlayProps) {
@@ -156,12 +164,14 @@ export class DivisionEditOverlay extends Component<
156164
popoverIsOpen: false,
157165
};
158166
this.timeout = null;
167+
168+
this.elementRef = createRef();
159169
}
160170

161171
onHoverInterval(event) {
162172
event.stopPropagation();
163173
// findDOMNode might be slow but I'm not sure
164-
if (findDOMNode(this) !== event.target) {
174+
if (this.elementRef.current !== event.target) {
165175
return;
166176
}
167177
const height = this.heightForEvent(event);
@@ -344,6 +354,7 @@ export class DivisionEditOverlay extends Component<
344354
className: "edit-overlay",
345355
width,
346356
height: pixelHeight,
357+
ref: this.elementRef,
347358
style: {
348359
left,
349360
top,

packages/column-components/src/editor/facies/color-picker.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
/*
2-
* decaffeinate suggestions:
3-
* DS102: Remove unnecessary code created because of implicit returns
4-
* DS206: Consider reworking classes to avoid initClass
5-
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
6-
*/
71
import { Component } from "react";
82
import h from "@macrostrat/hyper";
9-
import { SwatchesPicker } from "react-color";
3+
import Swatch from "@uiw/react-color-swatch";
104
import { Popover } from "@blueprintjs/core";
115
import { FaciesContext } from "../../context";
126

@@ -25,15 +19,11 @@ class FaciesColorPicker extends Component<FaciesColorPickerProps> {
2519
const { setFaciesColor } = this.context;
2620
const { facies: d } = this.props;
2721
return h("div", [
28-
h(SwatchesPicker, {
22+
h(Swatch, {
2923
color: d.color || "black",
30-
onChangeComplete(color) {
24+
onChange(color) {
3125
return setFaciesColor(d.id, color.hex);
3226
},
33-
styles: {
34-
width: 500,
35-
height: 570,
36-
},
3727
}),
3828
]);
3929
}
Lines changed: 63 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { Component, Context } from "react";
2-
import { findDOMNode } from "react-dom";
1+
import { useCallback, useEffect, useRef } from "react";
32
import Box from "ui-box";
43
import h from "@macrostrat/hyper";
5-
6-
import { ColumnContext, ColumnCtx, ColumnDivision } from "../context";
4+
import { useColumn } from "../context";
75

86
interface ColumnScrollerProps {
97
scrollToHeight: number;
@@ -19,101 +17,74 @@ interface ScrollToOpts {
1917
alignment?: "center" | "top" | "bottom";
2018
}
2119

22-
const splitProps = function (keys, props) {
23-
const obj = {};
24-
const rest = {};
25-
for (let k in props) {
26-
const v = props[k];
27-
if (keys.includes(k)) {
28-
obj[k] = v;
29-
} else {
30-
rest[k] = v;
31-
}
32-
}
33-
return [obj, rest];
34-
};
35-
36-
export class ColumnScroller extends Component<ColumnScrollerProps> {
37-
constructor(props) {
38-
super(props);
39-
this.scrollTo = this.scrollTo.bind(this);
40-
}
41-
42-
private static defaultProps: Partial<ColumnScrollerProps> = {
43-
animated: true,
44-
alignment: "center",
45-
onScrolled(height) {
46-
return console.log(`Scrolled to ${height} m`);
47-
},
48-
scrollContainer() {
49-
return document.querySelector(".panel-container");
50-
},
51-
};
20+
export function ColumnScroller(props: ColumnScrollerProps) {
21+
const {
22+
onScrolled = defaultOnScrolled,
23+
scrollContainer = defaultGetScrollContainer,
24+
scrollToHeight,
25+
paddingTop,
26+
animated,
27+
alignment,
28+
...rest
29+
} = props;
5230

53-
static contextType: Context<ColumnCtx<ColumnDivision>> = ColumnContext;
31+
const ref = useRef(null);
32+
const ctx = useColumn();
33+
const columnScale = ctx?.scale;
5434

55-
declare context: ColumnCtx<ColumnDivision>;
35+
const scrollTo = useCallback(
36+
(height: number, opts: ScrollToOpts) => {
37+
let node = ref.current;
38+
if (node == null || columnScale == null) return;
39+
let { animated, alignment } = opts;
40+
if (animated == null) {
41+
animated = false;
42+
}
43+
const pixelOffset = columnScale(height);
44+
const { top } = node.getBoundingClientRect();
5645

57-
render() {
58-
const keys = [
59-
"scrollToHeight",
60-
"alignment",
61-
"animated",
62-
"onScrolled",
63-
"paddingTop",
64-
"scrollContainer",
65-
];
66-
const [props, rest] = splitProps(keys, this.props);
67-
const { pixelHeight } = this.context;
68-
return h(Box, {
69-
height: pixelHeight,
70-
position: "absolute",
71-
...rest,
72-
});
73-
}
74-
75-
scrollTo(height, opts: ScrollToOpts = {}) {
76-
let node = findDOMNode(this) as HTMLElement;
77-
let { animated, alignment, ...rest } = opts;
78-
if (animated == null) {
79-
animated = false;
80-
}
81-
const { paddingTop } = this.props;
82-
const { scale } = this.context;
83-
const pixelOffset = scale(height);
84-
const { top } = node.getBoundingClientRect();
85-
86-
node = this.props.scrollContainer();
87-
let pos = pixelOffset + top + paddingTop;
88-
const screenHeight = window.innerHeight;
89-
90-
if (this.props.alignment === "center") {
91-
pos -= screenHeight / 2;
92-
} else if (this.props.alignment === "bottom") {
93-
pos -= screenHeight;
94-
}
46+
node = scrollContainer();
47+
let pos = pixelOffset + top + paddingTop;
48+
const screenHeight = window.innerHeight;
9549

96-
return (node.scrollTop = pos);
97-
}
50+
if (alignment === "center") {
51+
pos -= screenHeight / 2;
52+
} else if (alignment === "bottom") {
53+
pos -= screenHeight;
54+
}
55+
if (animated && "scrollBehavior" in document.documentElement.style) {
56+
node.scrollTo({ top: pos, behavior: "smooth" });
57+
} else {
58+
node.scrollTop = pos;
59+
}
60+
},
61+
[onScrolled, scrollContainer, ref.current, columnScale, paddingTop],
62+
);
9863

99-
componentDidMount() {
100-
const { scrollToHeight, alignment } = this.props;
64+
useEffect(() => {
65+
const { scrollToHeight, alignment } = props;
10166
if (scrollToHeight == null) {
10267
return;
10368
}
104-
this.scrollTo(scrollToHeight, { alignment, animated: false });
105-
return this.props.onScrolled(scrollToHeight);
106-
}
69+
// Actually perform the scroll
70+
scrollTo(scrollToHeight, { alignment, animated });
71+
return onScrolled(scrollToHeight);
72+
}, [scrollTo, scrollToHeight]);
10773

108-
componentDidUpdate(prevProps) {
109-
const { scrollToHeight, animated, alignment } = this.props;
110-
if (scrollToHeight == null) {
111-
return;
112-
}
113-
if (prevProps.scrollToHeight === scrollToHeight) {
114-
return;
115-
}
116-
this.scrollTo(scrollToHeight, { alignment, animated });
117-
return this.props.onScrolled(scrollToHeight);
118-
}
74+
const { pixelHeight } = this.context;
75+
return h(Box, {
76+
height: pixelHeight,
77+
position: "absolute",
78+
ref,
79+
...rest,
80+
});
81+
}
82+
83+
function defaultOnScrolled(height: number) {
84+
console.log(`Scrolled to ${height} m`);
85+
}
86+
87+
function defaultGetScrollContainer() {
88+
// Todo: generalize this
89+
return document.querySelector(".panel-container");
11990
}

packages/data-components/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [0.3.0] - 2026-01-20
4+
5+
- Replace `node-fetch` with `cross-fetch` in `PrevalentTaxa` component
6+
37
## [0.2.2] - 2025-11-28
48

59
- Move location information (e.g., `LngLatCoords`, `Elevation`) React components

packages/data-components/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/data-components",
3-
"version": "0.2.2",
3+
"version": "0.3.0",
44
"description": "A library of React components tailored for Macrostrat data and endpoints",
55
"type": "module",
66
"source": "src/index.ts",
@@ -52,6 +52,7 @@
5252
"@visx/shape": "^3.12.0",
5353
"axios": "^1.7.9",
5454
"classnames": "^2.5.1",
55+
"cross-fetch": "^4.1.0",
5556
"d3-array": "^3.2.4",
5657
"mapbox-gl": "^2.7.0||^3.13.0"
5758
},

packages/data-components/src/components/prevalent-taxa/prevalent-taxa.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useState, useEffect } from "react";
22
import axios from "axios";
33
import { hyperStyled } from "@macrostrat/hyper";
4-
//@ts-ignore
54
import styles from "./taxa.module.scss";
65
import { Spinner } from "@blueprintjs/core";
6+
import fetch from "cross-fetch";
77

88
const h = hyperStyled(styles);
99

packages/data-sheet/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format
44
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
55
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.2.4] - 2026-01-20
8+
9+
- Modernize `react-color` dependency
10+
- Modernize data editor handling
11+
712
## [2.2.3] - 2026-01-17
813

914
- Fix issue with column resizing

packages/data-sheet/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/data-sheet",
3-
"version": "2.2.3",
3+
"version": "2.2.4",
44
"description": "Scalable data sheet with optional editing capabilities",
55
"type": "module",
66
"source": "src/index.ts",
@@ -35,12 +35,11 @@
3535
"@macrostrat/hyper": "^3.0.6",
3636
"@macrostrat/ui-components": "workspace:^",
3737
"@supabase/postgrest-js": "^1.17.7",
38+
"@uiw/react-color-sketch": "^2.9.2",
3839
"chroma-js": "^2.4.2",
3940
"classnames": "^2.3.1",
4041
"immutability-helper": "^3.1.1",
41-
"react": "^17.0.2||^18",
42-
"react-color": "^2.19.3",
43-
"react-colorful": "^5.6.1",
42+
"react": "^17.0.2||^18 ||^19",
4443
"underscore": "^1.13.7",
4544
"zustand": "^5.0.2",
4645
"zustand-computed": "^2.1.0"

0 commit comments

Comments
 (0)