@macrostrat/column-views 3.0.2 → 3.1.0
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.
- package/CHANGELOG.md +12 -0
- package/dist/data-provider/column-nav.js +1 -1
- package/dist/data-provider/index.d.ts +0 -2
- package/dist/data-provider/store.cjs +49 -6
- package/dist/data-provider/store.cjs.map +1 -1
- package/dist/data-provider/store.js +46 -3
- package/dist/data-provider/store.js.map +1 -1
- package/dist/data-provider/unit-selection.cjs +9 -9
- package/dist/data-provider/unit-selection.cjs.map +1 -1
- package/dist/data-provider/unit-selection.d.ts +1 -1
- package/dist/data-provider/unit-selection.js +2 -2
- package/dist/data-provider/unit-selection.js.map +1 -1
- package/dist/index.cjs +5 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -23
- package/dist/index.js.map +1 -1
- package/dist/maps/column-correlation/state.cjs +2 -2
- package/dist/maps/column-correlation/state.cjs.map +1 -1
- package/dist/maps/column-correlation/state.d.ts +1 -0
- package/dist/maps/column-correlation/state.js +1 -1
- package/dist/maps/column-correlation/state.js.map +1 -1
- package/dist/maps/column-navigation/mapbox/state.cjs +3 -3
- package/dist/maps/column-navigation/mapbox/state.cjs.map +1 -1
- package/dist/maps/column-navigation/mapbox/state.js +1 -1
- package/dist/maps/column-navigation/mapbox/state.js.map +1 -1
- package/dist/maps/column-navigation/svg/data-fetcher.cjs +25 -0
- package/dist/maps/column-navigation/svg/data-fetcher.cjs.map +1 -0
- package/dist/maps/column-navigation/svg/data-fetcher.d.ts +6 -0
- package/dist/maps/column-navigation/svg/data-fetcher.js +25 -0
- package/dist/maps/column-navigation/svg/data-fetcher.js.map +1 -0
- package/dist/maps/column-navigation/svg/layers.cjs +2 -3
- package/dist/maps/column-navigation/svg/layers.cjs.map +1 -1
- package/dist/maps/column-navigation/svg/layers.js +1 -2
- package/dist/maps/column-navigation/svg/layers.js.map +1 -1
- package/dist/section.cjs +3 -3
- package/dist/section.cjs.map +1 -1
- package/dist/section.js +2 -2
- package/dist/section.js.map +1 -1
- package/dist/unit-details/panel.cjs +76 -57
- package/dist/unit-details/panel.cjs.map +1 -1
- package/dist/unit-details/panel.js +72 -53
- package/dist/unit-details/panel.js.map +1 -1
- package/dist/units/boxes.cjs +1 -0
- package/dist/units/boxes.cjs.map +1 -1
- package/dist/units/boxes.js +1 -0
- package/dist/units/boxes.js.map +1 -1
- package/dist/units/index.cjs +4 -4
- package/dist/units/index.cjs.map +1 -1
- package/dist/units/index.js +1 -1
- package/dist/units/index.js.map +1 -1
- package/package.json +23 -17
- package/src/correlation-chart/stories/correlation-chart.stories.ts +29 -22
- package/src/data-provider/index.ts +0 -2
- package/src/data-provider/store.ts +51 -10
- package/src/data-provider/unit-selection.ts +4 -4
- package/src/maps/column-correlation/state.ts +2 -1
- package/src/maps/column-navigation/mapbox/state.ts +1 -1
- package/src/maps/column-navigation/svg/column-navigation-svg-map.stories.ts +1 -1
- package/src/maps/column-navigation/svg/data-fetcher.ts +34 -0
- package/src/maps/column-navigation/svg/layers.ts +1 -1
- package/src/section.ts +1 -1
- package/src/unit-details/panel.ts +97 -60
- package/src/units/boxes.ts +2 -1
- package/src/units/index.ts +1 -1
- package/dist/data-provider/base.cjs +0 -352
- package/dist/data-provider/base.cjs.map +0 -1
- package/dist/data-provider/base.d.ts +0 -65
- package/dist/data-provider/base.js +0 -349
- package/dist/data-provider/base.js.map +0 -1
- package/dist/data-provider/core.cjs +0 -58
- package/dist/data-provider/core.cjs.map +0 -1
- package/dist/data-provider/core.d.ts +0 -31
- package/dist/data-provider/core.js +0 -56
- package/dist/data-provider/core.js.map +0 -1
- package/dist/data-provider/fetch.cjs +0 -212
- package/dist/data-provider/fetch.cjs.map +0 -1
- package/dist/data-provider/fetch.d.ts +0 -27
- package/dist/data-provider/fetch.js +0 -210
- package/dist/data-provider/fetch.js.map +0 -1
- package/dist/data-provider/store.d.ts +0 -34
- package/dist/unit-details/panel.d.ts +0 -87
- package/src/data-provider/base.ts +0 -475
- package/src/data-provider/core.ts +0 -89
- package/src/data-provider/fetch.ts +0 -278
package/dist/units/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/units/index.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n LithologyColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { UnitNamesColumn } from \"./names\";\nimport { ICompositeUnitProps } from \"./composite\";\nimport { UnitBoxes, UnitProps } from \"./boxes\";\nimport { useColumnLayout } from \"@macrostrat/column-components\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { getMixedUnitColor } from \"./colors\";\nimport { TrackedLabeledUnit } from \"./composite\";\nimport { useEnvironments, useLithologies } from \"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/units/index.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n LithologyColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { UnitNamesColumn } from \"./names\";\nimport { ICompositeUnitProps } from \"./composite\";\nimport { UnitBoxes, UnitProps } from \"./boxes\";\nimport { useColumnLayout } from \"@macrostrat/column-components\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { getMixedUnitColor } from \"./colors\";\nimport { TrackedLabeledUnit } from \"./composite\";\nimport { useEnvironments, useLithologies } from \"@macrostrat/data-provider\";\nimport { useMemo } from \"react\";\nimport { resolveID } from \"./resolvers\";\nimport { Lithology } from \"@macrostrat/api-types\";\n\nexport * from \"./composite\";\nexport * from \"./types\";\nexport * from \"./colors\";\n\nexport function UnitsColumn({ width = 100 }) {\n /*\n A column showing units with USGS color fill\n */\n return h(LithologyColumn, { width }, h(UnitBoxes));\n}\n\nexport function SimpleUnitsColumn(props: ICompositeUnitProps) {\n /*\n A column with units and names either\n overlapping or offset to the right\n */\n const { columnWidth, width, gutterWidth = 0, labelOffset = 30 } = props;\n\n return h([\n h(UnitsColumn, {\n width: columnWidth,\n }),\n h(UnitNamesColumn, {\n transform: `translate(${columnWidth + gutterWidth})`,\n paddingLeft: labelOffset,\n width: width - columnWidth - gutterWidth,\n }),\n ]);\n}\n\nexport function BasicUnitComponent({ division, ...rest }) {\n /** A unit that allows directly setting colors and patterns. */\n\n return h(UnitComponent, {\n division,\n ...rest,\n backgroundColor: division.color,\n patternID: division.patternID,\n });\n}\n\nexport function UnitComponent({ division, nColumns = 2, ...rest }) {\n const width = rest.width ?? useColumnLayout()?.width;\n\n const nOverlappingUnits = division.overlappingUnits?.length ?? 0;\n const _nColumns = nOverlappingUnits == 0 ? 1 : nColumns;\n const columnIx = (division.column ?? 0) % _nColumns;\n const reducedWidth = width / _nColumns;\n const x = (columnIx * width) / _nColumns;\n\n return h(TrackedLabeledUnit, {\n division,\n ...rest,\n width: reducedWidth,\n x,\n });\n}\n\ninterface UnitColorOptions {\n asBackground?: boolean;\n}\n\nexport function useUnitColor(unit, opts: UnitColorOptions = {}): string | null {\n /** Get the color for a unit based on its lithology */\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || lithMap == null) return null;\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, lithMap, inDarkMode, asBackground]);\n}\n\nexport function ColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColor(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nexport function useUnitColorByEnvironment(\n unit,\n opts: UnitColorOptions = {},\n): string | null {\n /** Get the color for a unit based on its lithology */\n const environmentMap = useEnvironments();\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || environmentMap == null) return null;\n let c = getMixedUnitColor(unit, environmentMap, inDarkMode, asBackground, {\n key: \"environ\",\n id_key: \"environ_id\",\n });\n if (c != null) {\n return c;\n }\n // Fallback to lithology color if no environment color is found\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, environmentMap, lithMap, inDarkMode, asBackground]);\n}\n\nexport function EnvironmentColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColorByEnvironment(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nfunction getPatternID(\n liths: Array<Lithology>,\n lithMap: Map<number, Lithology>,\n): string | null {\n if (lithMap == null || liths == null || liths.length == 0) {\n return null;\n }\n const patternIDs = new Set<string>();\n for (const lith of liths) {\n const lithData = lithMap.get(lith.lith_id);\n if (lithData) {\n patternIDs.add(`${lithData.fill}`);\n }\n }\n let id = patternIDs.values()[0];\n if (id == \"0\") return null;\n return id;\n}\n"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@macrostrat/column-views",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Data views for Macrostrat stratigraphic columns",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"directory": "packages/column-views"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"type": "module",
|
|
12
11
|
"source": "src/index.ts",
|
|
13
|
-
"main": "dist/index.
|
|
12
|
+
"main": "dist/index.cjs",
|
|
13
|
+
"module": "dist/index.js",
|
|
14
14
|
"node": "dist/index.cjs",
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
16
|
"style": "dist/column-views.css",
|
|
@@ -24,9 +24,14 @@
|
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
26
|
"source": "./src/index.ts",
|
|
27
|
-
"import":
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
"import": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.cjs"
|
|
34
|
+
},
|
|
30
35
|
"style": "./dist/column-views.css"
|
|
31
36
|
},
|
|
32
37
|
"./package.json": "./package.json",
|
|
@@ -42,18 +47,19 @@
|
|
|
42
47
|
"dependencies": {
|
|
43
48
|
"@blueprintjs/core": "^6.6.1",
|
|
44
49
|
"@macrostrat/api-types": "^1.1.5",
|
|
45
|
-
"@macrostrat/color-utils": "^1.2.
|
|
46
|
-
"@macrostrat/column-components": "^2.0.
|
|
47
|
-
"@macrostrat/data-components": "^1.
|
|
50
|
+
"@macrostrat/color-utils": "^1.2.1",
|
|
51
|
+
"@macrostrat/column-components": "^2.0.4",
|
|
52
|
+
"@macrostrat/data-components": "^1.1.0",
|
|
53
|
+
"@macrostrat/data-provider": "^1.0.0",
|
|
48
54
|
"@macrostrat/hyper": "^3.0.6",
|
|
49
|
-
"@macrostrat/map-interface": "^2.0.
|
|
50
|
-
"@macrostrat/map-styles": "^2.0.
|
|
51
|
-
"@macrostrat/mapbox-react": "^3.0.
|
|
52
|
-
"@macrostrat/mapbox-utils": "^1.7.
|
|
53
|
-
"@macrostrat/stratigraphy-utils": "^1.2.
|
|
54
|
-
"@macrostrat/svg-map-components": "^2.0.
|
|
55
|
-
"@macrostrat/timescale": "^3.0.
|
|
56
|
-
"@macrostrat/ui-components": "^5.0.
|
|
55
|
+
"@macrostrat/map-interface": "^2.0.1",
|
|
56
|
+
"@macrostrat/map-styles": "^2.0.1",
|
|
57
|
+
"@macrostrat/mapbox-react": "^3.0.1",
|
|
58
|
+
"@macrostrat/mapbox-utils": "^1.7.1",
|
|
59
|
+
"@macrostrat/stratigraphy-utils": "^1.2.1",
|
|
60
|
+
"@macrostrat/svg-map-components": "^2.0.1",
|
|
61
|
+
"@macrostrat/timescale": "^3.0.1",
|
|
62
|
+
"@macrostrat/ui-components": "^5.0.4",
|
|
57
63
|
"@turf/boolean-point-in-polygon": "^7.3.2",
|
|
58
64
|
"@turf/buffer": "^7.3.2",
|
|
59
65
|
"@turf/centroid": "^7.3.2",
|
|
@@ -4,14 +4,15 @@ import { useCorrelationLine } from "./utils";
|
|
|
4
4
|
import {
|
|
5
5
|
ColumnCorrelationMap,
|
|
6
6
|
ColumnCorrelationProvider,
|
|
7
|
-
fetchUnits,
|
|
8
|
-
MacrostratDataProvider,
|
|
9
7
|
MergeSectionsMode,
|
|
10
8
|
useCorrelationMapStore,
|
|
11
|
-
useMacrostratBaseURL,
|
|
12
|
-
useMacrostratFetch,
|
|
13
9
|
} from "../..";
|
|
14
10
|
import { hyperStyled } from "@macrostrat/hyper";
|
|
11
|
+
import {
|
|
12
|
+
MacrostratDataProvider,
|
|
13
|
+
fetchUnits,
|
|
14
|
+
useMacrostratFetch,
|
|
15
|
+
} from "@macrostrat/data-provider";
|
|
15
16
|
|
|
16
17
|
import styles from "./stories.module.sass";
|
|
17
18
|
import { CorrelationChart, CorrelationChartProps } from "../main";
|
|
@@ -19,6 +20,7 @@ import { ErrorBoundary, useAsyncMemo } from "@macrostrat/ui-components";
|
|
|
19
20
|
import { OverlaysProvider } from "@blueprintjs/core";
|
|
20
21
|
import { EnvironmentColoredUnitComponent } from "../../units";
|
|
21
22
|
import { scaleLinear, scalePow } from "d3-scale";
|
|
23
|
+
import { MacrostratInteractionProvider } from "@macrostrat/data-components";
|
|
22
24
|
|
|
23
25
|
const mapboxToken = import.meta.env.VITE_MAPBOX_API_TOKEN;
|
|
24
26
|
|
|
@@ -35,29 +37,34 @@ function CorrelationStoryUI({
|
|
|
35
37
|
projectID,
|
|
36
38
|
...rest
|
|
37
39
|
}: any) {
|
|
40
|
+
const domain = "https://dev.macrostrat.org";
|
|
38
41
|
return h(
|
|
39
42
|
MacrostratDataProvider,
|
|
40
|
-
{ baseURL: "
|
|
43
|
+
{ baseURL: domain + "/api/v2" },
|
|
41
44
|
h(
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
MacrostratInteractionProvider,
|
|
46
|
+
{ linkDomain: domain },
|
|
47
|
+
h(
|
|
48
|
+
ColumnCorrelationProvider,
|
|
49
|
+
{
|
|
50
|
+
focusedLine,
|
|
51
|
+
columns: null,
|
|
52
|
+
projectID,
|
|
53
|
+
onSelectColumns(cols, line) {
|
|
54
|
+
setFocusedLine(line);
|
|
55
|
+
},
|
|
49
56
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
h("div.correlation-ui", [
|
|
58
|
+
h("div.correlation-container", h(CorrelationDiagramWrapper, rest)),
|
|
59
|
+
h("div.right-column", [
|
|
60
|
+
h(ColumnCorrelationMap, {
|
|
61
|
+
accessToken: mapboxToken,
|
|
62
|
+
className: "correlation-map",
|
|
63
|
+
//showLogo: false,
|
|
64
|
+
}),
|
|
65
|
+
]),
|
|
59
66
|
]),
|
|
60
|
-
|
|
67
|
+
),
|
|
61
68
|
),
|
|
62
69
|
);
|
|
63
70
|
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
CompositeColumnScale,
|
|
5
5
|
createCompositeScale,
|
|
6
6
|
} from "../prepare-units/composite-scale";
|
|
7
|
-
import { ColumnAxisType } from "@macrostrat/column-components";
|
|
7
|
+
import { ColumnAxisType, ColumnProvider } from "@macrostrat/column-components";
|
|
8
8
|
import type { ExtUnit, PackageLayoutData } from "../prepare-units";
|
|
9
9
|
import {
|
|
10
10
|
allowUnitSelectionAtom,
|
|
@@ -12,14 +12,23 @@ import {
|
|
|
12
12
|
UnitSelectionCallbacks,
|
|
13
13
|
UnitSelectionCallbackManager,
|
|
14
14
|
} from "./unit-selection";
|
|
15
|
-
import { BaseUnit } from "@macrostrat/api-types";
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
import type { BaseUnit } from "@macrostrat/api-types";
|
|
16
|
+
import { type AtomMap, createScopedStore } from "@macrostrat/data-components";
|
|
17
|
+
import { atom } from "jotai";
|
|
18
|
+
|
|
19
|
+
export const scope = createScopedStore();
|
|
20
|
+
|
|
21
|
+
export const columnUnitsAtom = atom<BaseUnit[]>();
|
|
22
|
+
|
|
23
|
+
export const columnUnitsMapAtom = atom<Map<number, BaseUnit> | null>((get) => {
|
|
24
|
+
const units = get(columnUnitsAtom);
|
|
25
|
+
if (!units) return null;
|
|
26
|
+
const unitMap = new Map<number, BaseUnit>();
|
|
27
|
+
units.forEach((unit) => {
|
|
28
|
+
unitMap.set(unit.unit_id, unit);
|
|
29
|
+
});
|
|
30
|
+
return unitMap;
|
|
31
|
+
});
|
|
23
32
|
|
|
24
33
|
export interface ColumnStateProviderProps<
|
|
25
34
|
T extends BaseUnit,
|
|
@@ -64,9 +73,11 @@ export function MacrostratColumnStateProvider<T extends BaseUnit>({
|
|
|
64
73
|
}
|
|
65
74
|
|
|
66
75
|
return h(
|
|
67
|
-
|
|
76
|
+
scope.Provider,
|
|
68
77
|
{
|
|
69
78
|
atoms: atomMap,
|
|
79
|
+
keepUpdated: true,
|
|
80
|
+
inherit: true,
|
|
70
81
|
},
|
|
71
82
|
[selectionHandlers, children],
|
|
72
83
|
);
|
|
@@ -170,3 +181,33 @@ export function useCompositeScale(): CompositeColumnScale {
|
|
|
170
181
|
[ctx.sections],
|
|
171
182
|
);
|
|
172
183
|
}
|
|
184
|
+
|
|
185
|
+
export function MacrostratColumnProvider(props) {
|
|
186
|
+
/** A column provider specialized the Macrostrat API. Maps more
|
|
187
|
+
* generic concepts to Macrostrat-specific ones.
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
const { axisType } = useMacrostratColumnData();
|
|
191
|
+
const { units, domain, pixelScale, scale, children } = props;
|
|
192
|
+
return h(
|
|
193
|
+
ColumnProvider,
|
|
194
|
+
{
|
|
195
|
+
axisType,
|
|
196
|
+
divisions: units,
|
|
197
|
+
range: domain,
|
|
198
|
+
pixelsPerMeter: pixelScale,
|
|
199
|
+
scale,
|
|
200
|
+
},
|
|
201
|
+
children,
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** This is now a legacy provider */
|
|
206
|
+
export function LithologiesProvider({ children }) {
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
console.warn(
|
|
209
|
+
"LithologiesProvider is deprecated. Replace with MacrostratDataProvider",
|
|
210
|
+
);
|
|
211
|
+
}, []);
|
|
212
|
+
return children;
|
|
213
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { BaseUnit, UnitLong } from "@macrostrat/api-types";
|
|
1
|
+
import type { BaseUnit, UnitLong } from "@macrostrat/api-types";
|
|
2
2
|
import { useKeyHandler } from "@macrostrat/ui-components";
|
|
3
3
|
import { useEffect, useRef, useCallback, useMemo } from "react";
|
|
4
4
|
import type { RectBounds, IUnit } from "../units/types";
|
|
5
5
|
import { atom } from "jotai";
|
|
6
|
-
import {
|
|
7
|
-
import { ColumnData } from "@macrostrat/column-views";
|
|
6
|
+
import { scope, columnUnitsMapAtom } from "./store";
|
|
8
7
|
import {
|
|
9
8
|
AgeRangeQuantifiedDifference,
|
|
10
9
|
ageRangeQuantifiedDifference,
|
|
11
10
|
AgeRangeRelationship,
|
|
12
11
|
} from "@macrostrat/stratigraphy-utils";
|
|
12
|
+
import type { ColumnData } from "@macrostrat/data-provider";
|
|
13
13
|
|
|
14
14
|
type UnitSelectDispatch = (
|
|
15
15
|
unit: number | BaseUnit | null,
|
|
@@ -69,7 +69,7 @@ const selectedUnitAtom = atom(
|
|
|
69
69
|
target: HTMLElement | null = null,
|
|
70
70
|
): BaseUnit | null => {
|
|
71
71
|
if (!get(allowUnitSelectionAtom)) {
|
|
72
|
-
|
|
72
|
+
console.error("Unit selection is disabled.");
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
let unitID: number | null;
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "react";
|
|
16
16
|
import h from "@macrostrat/hyper";
|
|
17
17
|
import { createComputed } from "zustand-computed";
|
|
18
|
-
import { useMacrostratColumns } from "
|
|
18
|
+
import { useMacrostratColumns } from "@macrostrat/data-provider";
|
|
19
19
|
import { buffer } from "@turf/buffer";
|
|
20
20
|
import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon";
|
|
21
21
|
|
|
@@ -26,6 +26,7 @@ export interface CorrelationMapInput {
|
|
|
26
26
|
|
|
27
27
|
export interface CorrelationMapStore extends CorrelationMapInput {
|
|
28
28
|
onClickMap: (event: mapboxgl.MapMouseEvent, point: Point) => void;
|
|
29
|
+
projectID?: number;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export interface CorrelationProviderProps extends CorrelationMapInput {
|
|
@@ -2,7 +2,7 @@ import h from "@macrostrat/hyper";
|
|
|
2
2
|
|
|
3
3
|
import { Meta } from "@storybook/react-vite";
|
|
4
4
|
import { ColumnNavigationSVGMap, ColumnNavigationSVGMapProps } from ".";
|
|
5
|
-
import { MacrostratDataProvider } from "
|
|
5
|
+
import { MacrostratDataProvider } from "@macrostrat/data-provider";
|
|
6
6
|
import { useState } from "react";
|
|
7
7
|
|
|
8
8
|
interface ColumnIndexMapProps extends ColumnNavigationSVGMapProps {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ColumnStatusCode,
|
|
3
|
+
fetchAllColumns,
|
|
4
|
+
useMacrostratFetch,
|
|
5
|
+
} from "@macrostrat/data-provider";
|
|
6
|
+
import { useAsyncMemo } from "@macrostrat/ui-components";
|
|
7
|
+
|
|
8
|
+
export function useColumnFeatures({
|
|
9
|
+
status_code,
|
|
10
|
+
project_id,
|
|
11
|
+
format = "geojson",
|
|
12
|
+
}: {
|
|
13
|
+
apiRoute?: string;
|
|
14
|
+
status_code?: string;
|
|
15
|
+
project_id?: number;
|
|
16
|
+
format?: "geojson" | "topojson" | "geojson_bare";
|
|
17
|
+
}) {
|
|
18
|
+
/** Legacy fetcher for column features */
|
|
19
|
+
const fetch = useMacrostratFetch();
|
|
20
|
+
|
|
21
|
+
let statusCode: ColumnStatusCode[] = ["active"];
|
|
22
|
+
if (status_code == "in process") {
|
|
23
|
+
statusCode.push("in process");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return useAsyncMemo(async () => {
|
|
27
|
+
return await fetchAllColumns({
|
|
28
|
+
projectID: project_id,
|
|
29
|
+
statusCode: statusCode,
|
|
30
|
+
format,
|
|
31
|
+
fetch,
|
|
32
|
+
});
|
|
33
|
+
}, [project_id, status_code, format]);
|
|
34
|
+
}
|
|
@@ -9,7 +9,7 @@ import chroma from "chroma-js";
|
|
|
9
9
|
import { ExtendedFeature } from "d3-geo";
|
|
10
10
|
import { Polygon } from "geojson";
|
|
11
11
|
import { useContext, useMemo } from "react";
|
|
12
|
-
import { useColumnFeatures } from "
|
|
12
|
+
import { useColumnFeatures } from "./data-fetcher";
|
|
13
13
|
import {
|
|
14
14
|
buildKeyMapping,
|
|
15
15
|
buildTriangulation,
|
package/src/section.ts
CHANGED
|
@@ -16,8 +16,8 @@ import {
|
|
|
16
16
|
useMacrostratColumnData,
|
|
17
17
|
useMacrostratUnits,
|
|
18
18
|
MacrostratColumnProvider,
|
|
19
|
-
useMacrostratBaseURL,
|
|
20
19
|
} from "./data-provider";
|
|
20
|
+
import { useMacrostratBaseURL } from "@macrostrat/data-provider";
|
|
21
21
|
import { Duration } from "./unit-details";
|
|
22
22
|
import { Value } from "@macrostrat/data-components";
|
|
23
23
|
import type { ExtUnit, PackageScaleLayoutData } from "./prepare-units/types";
|