@macrostrat/column-views 3.0.3 → 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.
Files changed (84) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/data-provider/column-nav.js +1 -1
  3. package/dist/data-provider/index.d.ts +0 -2
  4. package/dist/data-provider/store.cjs +49 -6
  5. package/dist/data-provider/store.cjs.map +1 -1
  6. package/dist/data-provider/store.js +46 -3
  7. package/dist/data-provider/store.js.map +1 -1
  8. package/dist/data-provider/unit-selection.cjs +9 -9
  9. package/dist/data-provider/unit-selection.cjs.map +1 -1
  10. package/dist/data-provider/unit-selection.d.ts +1 -1
  11. package/dist/data-provider/unit-selection.js +2 -2
  12. package/dist/data-provider/unit-selection.js.map +1 -1
  13. package/dist/index.cjs +5 -24
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.js +4 -23
  16. package/dist/index.js.map +1 -1
  17. package/dist/maps/column-correlation/state.cjs +2 -2
  18. package/dist/maps/column-correlation/state.cjs.map +1 -1
  19. package/dist/maps/column-correlation/state.d.ts +1 -0
  20. package/dist/maps/column-correlation/state.js +1 -1
  21. package/dist/maps/column-correlation/state.js.map +1 -1
  22. package/dist/maps/column-navigation/mapbox/state.cjs +3 -3
  23. package/dist/maps/column-navigation/mapbox/state.cjs.map +1 -1
  24. package/dist/maps/column-navigation/mapbox/state.js +1 -1
  25. package/dist/maps/column-navigation/mapbox/state.js.map +1 -1
  26. package/dist/maps/column-navigation/svg/data-fetcher.cjs +25 -0
  27. package/dist/maps/column-navigation/svg/data-fetcher.cjs.map +1 -0
  28. package/dist/maps/column-navigation/svg/data-fetcher.d.ts +6 -0
  29. package/dist/maps/column-navigation/svg/data-fetcher.js +25 -0
  30. package/dist/maps/column-navigation/svg/data-fetcher.js.map +1 -0
  31. package/dist/maps/column-navigation/svg/layers.cjs +2 -3
  32. package/dist/maps/column-navigation/svg/layers.cjs.map +1 -1
  33. package/dist/maps/column-navigation/svg/layers.js +1 -2
  34. package/dist/maps/column-navigation/svg/layers.js.map +1 -1
  35. package/dist/section.cjs +3 -3
  36. package/dist/section.cjs.map +1 -1
  37. package/dist/section.js +2 -2
  38. package/dist/section.js.map +1 -1
  39. package/dist/unit-details/panel.cjs +76 -57
  40. package/dist/unit-details/panel.cjs.map +1 -1
  41. package/dist/unit-details/panel.js +72 -53
  42. package/dist/unit-details/panel.js.map +1 -1
  43. package/dist/units/boxes.cjs +1 -0
  44. package/dist/units/boxes.cjs.map +1 -1
  45. package/dist/units/boxes.js +1 -0
  46. package/dist/units/boxes.js.map +1 -1
  47. package/dist/units/index.cjs +4 -4
  48. package/dist/units/index.cjs.map +1 -1
  49. package/dist/units/index.js +1 -1
  50. package/dist/units/index.js.map +1 -1
  51. package/package.json +3 -2
  52. package/src/correlation-chart/stories/correlation-chart.stories.ts +29 -22
  53. package/src/data-provider/index.ts +0 -2
  54. package/src/data-provider/store.ts +51 -10
  55. package/src/data-provider/unit-selection.ts +4 -4
  56. package/src/maps/column-correlation/state.ts +2 -1
  57. package/src/maps/column-navigation/mapbox/state.ts +1 -1
  58. package/src/maps/column-navigation/svg/column-navigation-svg-map.stories.ts +1 -1
  59. package/src/maps/column-navigation/svg/data-fetcher.ts +34 -0
  60. package/src/maps/column-navigation/svg/layers.ts +1 -1
  61. package/src/section.ts +1 -1
  62. package/src/unit-details/panel.ts +97 -60
  63. package/src/units/boxes.ts +2 -1
  64. package/src/units/index.ts +1 -1
  65. package/dist/data-provider/base.cjs +0 -352
  66. package/dist/data-provider/base.cjs.map +0 -1
  67. package/dist/data-provider/base.d.ts +0 -65
  68. package/dist/data-provider/base.js +0 -349
  69. package/dist/data-provider/base.js.map +0 -1
  70. package/dist/data-provider/core.cjs +0 -58
  71. package/dist/data-provider/core.cjs.map +0 -1
  72. package/dist/data-provider/core.d.ts +0 -31
  73. package/dist/data-provider/core.js +0 -56
  74. package/dist/data-provider/core.js.map +0 -1
  75. package/dist/data-provider/fetch.cjs +0 -212
  76. package/dist/data-provider/fetch.cjs.map +0 -1
  77. package/dist/data-provider/fetch.d.ts +0 -27
  78. package/dist/data-provider/fetch.js +0 -210
  79. package/dist/data-provider/fetch.js.map +0 -1
  80. package/dist/data-provider/store.d.ts +0 -34
  81. package/dist/unit-details/panel.d.ts +0 -87
  82. package/src/data-provider/base.ts +0 -475
  83. package/src/data-provider/core.ts +0 -89
  84. package/src/data-provider/fetch.ts +0 -278
@@ -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 \"../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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"}
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",
3
+ "version": "3.1.0",
4
4
  "description": "Data views for Macrostrat stratigraphic columns",
5
5
  "repository": {
6
6
  "type": "git",
@@ -49,7 +49,8 @@
49
49
  "@macrostrat/api-types": "^1.1.5",
50
50
  "@macrostrat/color-utils": "^1.2.1",
51
51
  "@macrostrat/column-components": "^2.0.4",
52
- "@macrostrat/data-components": "^1.0.1",
52
+ "@macrostrat/data-components": "^1.1.0",
53
+ "@macrostrat/data-provider": "^1.0.0",
53
54
  "@macrostrat/hyper": "^3.0.6",
54
55
  "@macrostrat/map-interface": "^2.0.1",
55
56
  "@macrostrat/map-styles": "^2.0.1",
@@ -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: "https://dev.macrostrat.org/api/v2" },
43
+ { baseURL: domain + "/api/v2" },
41
44
  h(
42
- ColumnCorrelationProvider,
43
- {
44
- focusedLine,
45
- columns: null,
46
- projectID,
47
- onSelectColumns(cols, line) {
48
- setFocusedLine(line);
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
- h("div.correlation-ui", [
52
- h("div.correlation-container", h(CorrelationDiagramWrapper, rest)),
53
- h("div.right-column", [
54
- h(ColumnCorrelationMap, {
55
- accessToken: mapboxToken,
56
- className: "correlation-map",
57
- //showLogo: false,
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
  }
@@ -1,5 +1,3 @@
1
- export * from "./fetch";
2
- export * from "./base";
3
1
  export * from "./column-nav";
4
2
  export * from "./store";
5
3
  export * from "./unit-selection";
@@ -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
- AtomMap,
18
- columnUnitsAtom,
19
- columnUnitsMapAtom,
20
- scope,
21
- ScopedProvider,
22
- } from "./core";
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
- ScopedProvider,
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 { columnUnitsMapAtom, scope } from "./core";
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
- throw new Error("Unit selection is disabled.");
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 "../../data-provider/base";
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 {
@@ -12,7 +12,7 @@ import h from "@macrostrat/hyper";
12
12
  import {
13
13
  useMacrostratColumns,
14
14
  useMacrostratStore,
15
- } from "../../../data-provider";
15
+ } from "@macrostrat/data-provider";
16
16
 
17
17
  export interface NavigationStore {
18
18
  columns: ColumnGeoJSONRecordWithID[];
@@ -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 "../../../data-provider";
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 "../../../data-provider";
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";
@@ -2,7 +2,7 @@ import hyper from "@macrostrat/hyper";
2
2
  import styles from "./panel.module.sass";
3
3
  import { JSONView } from "@macrostrat/ui-components";
4
4
  import { Button, ButtonGroup } from "@blueprintjs/core";
5
- import { ReactNode, useMemo, useState } from "react";
5
+ import { ReactNode, useCallback, useMemo, useState } from "react";
6
6
  import {
7
7
  DataField,
8
8
  EnvironmentsList,
@@ -13,13 +13,21 @@ import {
13
13
  LithologyTagFeature,
14
14
  Parenthetical,
15
15
  Value,
16
+ MacrostratInteractionManager,
17
+ useInteractionProps,
18
+ ItemInteractionProps,
19
+ useInteractionManager,
20
+ MacrostratItemIdentifier,
21
+ MacrostratInteractionProvider,
22
+ isClickable,
16
23
  } from "@macrostrat/data-components";
24
+ import { useColumnUnitsMap } from "../data-provider";
17
25
  import {
18
- useColumnUnitsMap,
19
26
  useMacrostratColumnInfo,
20
27
  useMacrostratData,
21
28
  useMacrostratDefs,
22
- } from "../data-provider";
29
+ useStratNames,
30
+ } from "@macrostrat/data-provider";
23
31
  import type {
24
32
  Environment,
25
33
  UnitLong,
@@ -42,6 +50,7 @@ export interface UnitDetailsPanelProps {
42
50
  lithologyFeatures?: Set<LithologyTagFeature>;
43
51
  onSelectUnit?: (unitID: number) => void;
44
52
  onClickItem?: MacrostratItemClickHandler;
53
+ interactionManager?: MacrostratInteractionManager;
45
54
  }
46
55
 
47
56
  export function UnitDetailsPanel({
@@ -71,7 +80,6 @@ export function UnitDetailsPanel({
71
80
  features,
72
81
  lithologyFeatures,
73
82
  onClickItem,
74
- onSelectUnit,
75
83
  });
76
84
  }
77
85
 
@@ -94,7 +102,7 @@ export function UnitDetailsPanel({
94
102
  ]);
95
103
  }
96
104
 
97
- return h("div.unit-details-panel", { className }, [
105
+ const main = h("div.unit-details-panel", { className }, [
98
106
  h(LegendPanelHeader, {
99
107
  onClose,
100
108
  title,
@@ -104,6 +112,36 @@ export function UnitDetailsPanel({
104
112
  }),
105
113
  h("div.unit-details-content-holder", content),
106
114
  ]);
115
+
116
+ /** Handle unit selection clicks */
117
+ const clickHandlerForItem = useMemo(() => {
118
+ if (onSelectUnit == null && onClickItem == null) return null;
119
+ return (item: MacrostratItemIdentifier) => {
120
+ if ("unit_id" in item && !("col_id" in item)) {
121
+ // We are selecting a unit within the column
122
+ return (event: MouseEvent) => {
123
+ onSelectUnit(item.unit_id);
124
+ // Don't allow event to propagate further (e.g., to open a link)
125
+ event.preventDefault();
126
+ };
127
+ }
128
+ return undefined;
129
+ };
130
+ }, [onSelectUnit, onClickItem]);
131
+
132
+ if (clickHandlerForItem != null) {
133
+ // We wrap this in a MacrostratInteractionManager to handle unit selection
134
+ return h(
135
+ MacrostratInteractionProvider,
136
+ {
137
+ clickHandlerForItem,
138
+ inherit: true,
139
+ },
140
+ main,
141
+ );
142
+ }
143
+
144
+ return main;
107
145
  }
108
146
 
109
147
  export function LegendPanelHeader({
@@ -162,7 +200,6 @@ export type MacrostratItemClickHandler = (
162
200
 
163
201
  function UnitDetailsContent({
164
202
  unit,
165
- onSelectUnit,
166
203
  lithologyFeatures = new Set([
167
204
  LithologyTagFeature.Proportion,
168
205
  LithologyTagFeature.Attributes,
@@ -175,7 +212,6 @@ function UnitDetailsContent({
175
212
  getItemHref,
176
213
  }: {
177
214
  unit: UnitLong;
178
- onSelectUnit?: (unitID: number) => void;
179
215
  lithologyFeatures?: Set<LithologyTagFeature>;
180
216
  features?: Set<UnitDetailsFeature>;
181
217
  onClickItem?: MacrostratItemClickHandler;
@@ -243,12 +279,10 @@ function UnitDetailsContent({
243
279
  col_id: unit.col_id,
244
280
  }),
245
281
  thicknessOrHeightRange,
246
- h.if(lithologies)(LithologyList, {
282
+ h.if(lithologies != null)(LithologyList, {
247
283
  label: "Lithology",
248
284
  lithologies,
249
285
  features: lithologyFeatures,
250
- getItemHref,
251
- onClickItem,
252
286
  }),
253
287
  h(AgeField, { unit }, [
254
288
  h(Parenthetical, h(Duration, { value: unit.b_age - unit.t_age })),
@@ -257,10 +291,8 @@ function UnitDetailsContent({
257
291
  onClickItem,
258
292
  }),
259
293
  ]),
260
- h.if(environments)(EnvironmentsList, {
294
+ h.if(environments != null)(EnvironmentsList, {
261
295
  environments,
262
- onClickItem,
263
- getItemHref,
264
296
  }),
265
297
  h.if(unit.strat_name_id != null)(StratNameField, {
266
298
  strat_name_id: unit.strat_name_id,
@@ -272,7 +304,6 @@ function UnitDetailsContent({
272
304
  { label: "Above" },
273
305
  h(UnitIDList, {
274
306
  units: unit.units_above,
275
- onSelectUnit,
276
307
  showNames: true,
277
308
  }),
278
309
  ),
@@ -281,7 +312,6 @@ function UnitDetailsContent({
281
312
  { label: "Below" },
282
313
  h(UnitIDList, {
283
314
  units: unit.units_below,
284
- onSelectUnit,
285
315
  showNames: true,
286
316
  }),
287
317
  ),
@@ -333,27 +363,35 @@ export function ReferencesField({ refs, className = null, ...rest }) {
333
363
  );
334
364
  }
335
365
 
336
- function StratNameField({
337
- strat_name_id,
338
- onClickItem,
339
- }: {
340
- strat_name_id: number;
341
- onClickItem?: (event: MouseEvent, item: { strat_name_id: number }) => void;
342
- }) {
343
- const stratNames = useMemo(() => [strat_name_id], [strat_name_id]);
344
- const data = useMacrostratData("strat_names", stratNames);
345
- const stratNameData = data?.[0];
366
+ function useStratNameData(strat_name_id: number) {
367
+ const stratNames = useStratNames([strat_name_id]);
368
+ return stratNames?.[0];
369
+ }
370
+
371
+ function StratNameField(
372
+ props: {
373
+ strat_name_id: number;
374
+ className?: string;
375
+ } & ItemInteractionProps,
376
+ ) {
377
+ /** Handling for stratigraphic name field */
378
+ const { strat_name_id, className, ...rest } = props;
379
+ const data = useStratNameData(strat_name_id);
380
+
381
+ const baseInteractionProps = useInteractionProps({ strat_name_id });
382
+
383
+ const coreProps = {
384
+ ...baseInteractionProps,
385
+ ...rest,
386
+ };
387
+
346
388
  let inner: any = h(Identifier, { id: strat_name_id });
347
- const name = stratNameData?.strat_name_long;
389
+ const name = data?.strat_name_long;
348
390
  if (name != null) {
349
391
  inner = h("span.strat-name", name);
350
392
  }
351
393
 
352
- const clickable = onClickItem != null;
353
-
354
- const className = classNames({
355
- clickable,
356
- });
394
+ const clickable = isClickable(coreProps);
357
395
 
358
396
  return h(
359
397
  DataField,
@@ -363,8 +401,8 @@ function StratNameField({
363
401
  h(
364
402
  clickable ? "a" : "span",
365
403
  {
366
- className,
367
- onClick: (e) => onClickItem(e, { strat_name_id }),
404
+ className: classNames({ clickable }, className),
405
+ ...coreProps,
368
406
  },
369
407
  inner,
370
408
  ),
@@ -566,36 +604,32 @@ function enhanceLithologies(
566
604
  }
567
605
 
568
606
  export function ClickableText({
569
- onClick,
570
607
  className,
571
- children,
608
+ ...rest
572
609
  }: {
573
- onClick: () => void;
574
610
  className?: string;
575
611
  children: ReactNode;
576
- }) {
612
+ } & ItemInteractionProps) {
577
613
  /** An optionally clickable text element */
578
- const tag = onClick != null ? "a" : "span";
579
- return h(tag, { onClick, className }, children);
614
+ const clickable = isClickable(rest);
615
+ const tag = clickable ? "a" : "span";
616
+ return h(tag, { className: classNames(className, { clickable }), ...rest });
580
617
  }
581
618
 
582
619
  export function Identifier({
583
620
  id,
584
- onClick,
585
621
  className,
622
+ ...rest
586
623
  }: {
587
624
  id: number | string;
588
- onClick?: (id: number | string) => void;
589
625
  className?: string;
590
- }) {
626
+ } & ItemInteractionProps) {
591
627
  /** An item that displays a numeric identifier, optionally clickable */
592
- const _onClick = onClick != null ? () => onClick(id) : null;
593
-
594
628
  return h(
595
629
  ClickableText,
596
630
  {
597
- onClick: _onClick,
598
631
  className: classNames("identifier", className),
632
+ ...rest,
599
633
  },
600
634
  id,
601
635
  );
@@ -607,9 +641,11 @@ type UnitInfo = {
607
641
  name?: string;
608
642
  };
609
643
 
610
- function UnitIDList({ units, onSelectUnit, showNames = false }) {
644
+ function UnitIDList({ units, showNames = false }) {
611
645
  const unitsMap = useColumnUnitsMap();
612
646
 
647
+ const interactionManager = useInteractionManager();
648
+
613
649
  const extUnits: UnitInfo[] = useMemo(() => {
614
650
  const u1 = units.filter((d) => d != 0);
615
651
  if (showNames) {
@@ -637,9 +673,17 @@ function UnitIDList({ units, onSelectUnit, showNames = false }) {
637
673
  return h(
638
674
  ItemList,
639
675
  { className: "units-list" },
640
- extUnits.map((info) =>
641
- h("span.item", h(UnitIdentifier, { ...info, onSelectUnit })),
642
- ),
676
+ extUnits.map((info) => {
677
+ return h(
678
+ "span.item",
679
+ h(UnitIdentifier, {
680
+ ...info,
681
+ ...interactionManager?.interactionPropsForItem({
682
+ unit_id: info.unitID,
683
+ }),
684
+ }),
685
+ );
686
+ }),
643
687
  );
644
688
  }
645
689
 
@@ -647,21 +691,14 @@ function UnitIdentifier({
647
691
  unitID,
648
692
  colID,
649
693
  name,
650
- onSelectUnit,
651
- }: UnitInfo & { onSelectUnit?: (unitID: number) => void }) {
652
- const onClick = useMemo(() => {
653
- if (onSelectUnit == null) return null;
654
- return () => {
655
- onSelectUnit(unitID);
656
- };
657
- }, [onSelectUnit]);
658
-
694
+ ...interactionProps
695
+ }: UnitInfo & ItemInteractionProps) {
659
696
  if (name != null) {
660
697
  return h(
661
698
  ClickableText,
662
699
  {
663
700
  className: "unit-name",
664
- onClick,
701
+ ...interactionProps,
665
702
  },
666
703
  name,
667
704
  );
@@ -669,9 +706,9 @@ function UnitIdentifier({
669
706
 
670
707
  return h(Identifier, {
671
708
  className: "unit-id",
672
- onClick,
673
709
  key: unitID,
674
710
  id: unitID,
711
+ ...interactionProps,
675
712
  });
676
713
  }
677
714