@macrostrat/column-views 3.9.0 → 3.11.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 +44 -0
- package/dist/column-views.css +10 -0
- package/dist/correlation-chart/main.cjs +11 -3
- package/dist/correlation-chart/main.cjs.map +1 -1
- package/dist/correlation-chart/main.d.ts +1 -1
- package/dist/correlation-chart/main.js +11 -3
- package/dist/correlation-chart/main.js.map +1 -1
- package/dist/index.cjs +18 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -34
- package/dist/index.js.map +1 -1
- package/dist/unit-details/age-window-tag.cjs +68 -0
- package/dist/unit-details/age-window-tag.cjs.map +1 -0
- package/dist/unit-details/age-window-tag.d.ts +26 -0
- package/dist/unit-details/age-window-tag.js +66 -0
- package/dist/unit-details/age-window-tag.js.map +1 -0
- package/dist/unit-details/age-window-tag.module.sass.cjs +12 -0
- package/dist/unit-details/age-window-tag.module.sass.cjs.map +1 -0
- package/dist/unit-details/age-window-tag.module.sass.js +11 -0
- package/dist/unit-details/age-window-tag.module.sass.js.map +1 -0
- package/dist/unit-details/index.d.ts +1 -0
- package/dist/units/boxes.cjs +3 -3
- package/dist/units/boxes.cjs.map +1 -1
- package/dist/units/boxes.js +3 -3
- package/dist/units/boxes.js.map +1 -1
- package/dist/units/index.cjs +7 -11
- package/dist/units/index.cjs.map +1 -1
- package/dist/units/index.d.ts +0 -1
- package/dist/units/index.js +4 -9
- package/dist/units/index.js.map +1 -1
- package/package.json +6 -27
- package/src/correlation-chart/main.ts +14 -2
- package/src/index.ts +3 -1
- package/src/unit-details/age-window-tag.module.sass +10 -0
- package/src/unit-details/age-window-tag.ts +102 -0
- package/src/unit-details/index.ts +1 -0
- package/src/units/boxes.ts +7 -4
- package/src/units/index.ts +9 -26
- package/dist/maps/column-correlation/core.cjs +0 -288
- package/dist/maps/column-correlation/core.cjs.map +0 -1
- package/dist/maps/column-correlation/core.d.ts +0 -9
- package/dist/maps/column-correlation/core.js +0 -286
- package/dist/maps/column-correlation/core.js.map +0 -1
- package/dist/maps/column-correlation/index.d.ts +0 -2
- package/dist/maps/column-correlation/state.cjs +0 -193
- package/dist/maps/column-correlation/state.cjs.map +0 -1
- package/dist/maps/column-correlation/state.d.ts +0 -62
- package/dist/maps/column-correlation/state.js +0 -190
- package/dist/maps/column-correlation/state.js.map +0 -1
- package/dist/maps/column-navigation/index.d.ts +0 -2
- package/dist/maps/column-navigation/mapbox/index.cjs +0 -215
- package/dist/maps/column-navigation/mapbox/index.cjs.map +0 -1
- package/dist/maps/column-navigation/mapbox/index.d.ts +0 -38
- package/dist/maps/column-navigation/mapbox/index.js +0 -213
- package/dist/maps/column-navigation/mapbox/index.js.map +0 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs +0 -105
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs.map +0 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +0 -8
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.js +0 -105
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.js.map +0 -1
- package/dist/maps/column-navigation/mapbox/state.cjs +0 -73
- package/dist/maps/column-navigation/mapbox/state.cjs.map +0 -1
- package/dist/maps/column-navigation/mapbox/state.d.ts +0 -23
- package/dist/maps/column-navigation/mapbox/state.js +0 -71
- package/dist/maps/column-navigation/mapbox/state.js.map +0 -1
- package/dist/maps/column-navigation/svg/animated.d.ts +0 -1
- package/dist/maps/column-navigation/svg/data-fetcher.cjs +0 -25
- package/dist/maps/column-navigation/svg/data-fetcher.cjs.map +0 -1
- package/dist/maps/column-navigation/svg/data-fetcher.d.ts +0 -6
- package/dist/maps/column-navigation/svg/data-fetcher.js +0 -25
- package/dist/maps/column-navigation/svg/data-fetcher.js.map +0 -1
- package/dist/maps/column-navigation/svg/index.cjs +0 -94
- package/dist/maps/column-navigation/svg/index.cjs.map +0 -1
- package/dist/maps/column-navigation/svg/index.d.ts +0 -9
- package/dist/maps/column-navigation/svg/index.js +0 -93
- package/dist/maps/column-navigation/svg/index.js.map +0 -1
- package/dist/maps/column-navigation/svg/layers.cjs +0 -177
- package/dist/maps/column-navigation/svg/layers.cjs.map +0 -1
- package/dist/maps/column-navigation/svg/layers.d.ts +0 -54
- package/dist/maps/column-navigation/svg/layers.js +0 -174
- package/dist/maps/column-navigation/svg/layers.js.map +0 -1
- package/dist/maps/column-navigation/utils/keyboard-navigation.cjs +0 -50
- package/dist/maps/column-navigation/utils/keyboard-navigation.cjs.map +0 -1
- package/dist/maps/column-navigation/utils/keyboard-navigation.d.ts +0 -10
- package/dist/maps/column-navigation/utils/keyboard-navigation.js +0 -50
- package/dist/maps/column-navigation/utils/keyboard-navigation.js.map +0 -1
- package/dist/maps/index.d.ts +0 -4
- package/dist/maps/inset-map/index.cjs +0 -71
- package/dist/maps/inset-map/index.cjs.map +0 -1
- package/dist/maps/inset-map/index.d.ts +0 -16
- package/dist/maps/inset-map/index.js +0 -69
- package/dist/maps/inset-map/index.js.map +0 -1
- package/dist/maps/layers/columns.cjs +0 -165
- package/dist/maps/layers/columns.cjs.map +0 -1
- package/dist/maps/layers/columns.d.ts +0 -28
- package/dist/maps/layers/columns.js +0 -165
- package/dist/maps/layers/columns.js.map +0 -1
- package/dist/maps/layers/index.d.ts +0 -2
- package/dist/maps/layers/units.cjs +0 -207
- package/dist/maps/layers/units.cjs.map +0 -1
- package/dist/maps/layers/units.d.ts +0 -14
- package/dist/maps/layers/units.js +0 -204
- package/dist/maps/layers/units.js.map +0 -1
- package/dist/units/colors.cjs +0 -115
- package/dist/units/colors.cjs.map +0 -1
- package/dist/units/colors.d.ts +0 -20
- package/dist/units/colors.js +0 -113
- package/dist/units/colors.js.map +0 -1
- package/dist/units/resolvers.cjs +0 -125
- package/dist/units/resolvers.cjs.map +0 -1
- package/dist/units/resolvers.d.ts +0 -8
- package/dist/units/resolvers.js +0 -125
- package/dist/units/resolvers.js.map +0 -1
- package/src/maps/column-correlation/column-correlation-map.stories.ts +0 -108
- package/src/maps/column-correlation/core.ts +0 -342
- package/src/maps/column-correlation/index.ts +0 -2
- package/src/maps/column-correlation/state.ts +0 -315
- package/src/maps/column-navigation/index.ts +0 -2
- package/src/maps/column-navigation/mapbox/column-navigation-map.stories.ts +0 -278
- package/src/maps/column-navigation/mapbox/index.ts +0 -276
- package/src/maps/column-navigation/mapbox/keyboard-navigation.ts +0 -133
- package/src/maps/column-navigation/mapbox/state.ts +0 -119
- package/src/maps/column-navigation/svg/animated.ts +0 -78
- package/src/maps/column-navigation/svg/column-navigation-svg-map.stories.ts +0 -46
- package/src/maps/column-navigation/svg/data-fetcher.ts +0 -34
- package/src/maps/column-navigation/svg/index.ts +0 -96
- package/src/maps/column-navigation/svg/layers.ts +0 -233
- package/src/maps/column-navigation/utils/keyboard-navigation.ts +0 -58
- package/src/maps/index.ts +0 -4
- package/src/maps/inset-map/index.ts +0 -87
- package/src/maps/inset-map/inset-map.stories.ts +0 -20
- package/src/maps/layers/columns.ts +0 -216
- package/src/maps/layers/index.ts +0 -2
- package/src/maps/layers/units.ts +0 -286
- package/src/maps/unit-map.stories.ts +0 -79
- package/src/units/colors.ts +0 -183
- package/src/units/resolvers.ts +0 -141
package/dist/units/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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
|
|
1
|
+
{"version":3,"file":"index.cjs","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 } from \"./boxes\";\nimport { useColumnLayout } from \"@macrostrat/column-components\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport {\n getBestFGDCPatternForUnit,\n getMixedUnitColor,\n} from \"@macrostrat/stratigraphy-utils\";\nimport { TrackedLabeledUnit } from \"./composite\";\nimport { useEnvironments, useLithologies } from \"@macrostrat/data-provider\";\nimport { useMemo } from \"react\";\nimport { BaseUnit, Lithology } from \"@macrostrat/api-types\";\nimport { UnitWithLayoutParameters } from \"../prepare-units/helpers.ts\";\n\nexport * from \"./composite\";\nexport * from \"./types\";\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\ninterface UnitComponentProps<T extends BaseUnit> {\n division: UnitWithLayoutParameters<T> | T;\n nColumns: number;\n width?: number;\n}\n\nexport function UnitComponent<T extends BaseUnit>({\n division,\n nColumns = 2,\n ...rest\n}: UnitComponentProps<T>) {\n const width = rest.width ?? useColumnLayout()?.width;\n\n let _nColumns = nColumns;\n if (isNaN(_nColumns)) {\n _nColumns = 2;\n }\n let columnIx = 0;\n let x = 0;\n\n let reducedWidth = _nColumns;\n if (\"layout\" in division) {\n const layout = division.layout;\n _nColumns = layout.totalColumns;\n columnIx = layout.column;\n reducedWidth = width / layout.totalColumns / layout.nColumns;\n x = (columnIx * width) / _nColumns;\n }\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 getBestFGDCPatternForUnit(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 getBestFGDCPatternForUnit(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"],"names":["h","LithologyColumn","UnitBoxes","UnitNamesColumn","useColumnLayout","TrackedLabeledUnit","useLithologies","useInDarkMode","useMemo","getMixedUnitColor","getBestFGDCPatternForUnit","useGeologicPattern","useEnvironments"],"mappings":"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"}
|
package/dist/units/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { BaseUnit } from '@macrostrat/api-types';
|
|
|
3
3
|
import { UnitWithLayoutParameters } from '../prepare-units/helpers.ts';
|
|
4
4
|
export * from './composite';
|
|
5
5
|
export * from './types';
|
|
6
|
-
export * from './colors';
|
|
7
6
|
export declare function UnitsColumn({ width }: {
|
|
8
7
|
width?: number | undefined;
|
|
9
8
|
}): import('react').FunctionComponentElement<import('@macrostrat/column-components').LithologyColumnProps>;
|
package/dist/units/index.js
CHANGED
|
@@ -3,13 +3,11 @@ import { useGeologicPattern, useColumnLayout, LithologyColumn } from "@macrostra
|
|
|
3
3
|
import { UnitNamesColumn } from "./names.js";
|
|
4
4
|
import { UnitBoxes } from "./boxes.js";
|
|
5
5
|
import { useInDarkMode } from "@macrostrat/ui-components";
|
|
6
|
-
import { getMixedUnitColor } from "
|
|
7
|
-
import { flattenLithologies, getMixedColorForData } from "./colors.js";
|
|
6
|
+
import { getBestFGDCPatternForUnit, getMixedUnitColor } from "@macrostrat/stratigraphy-utils";
|
|
8
7
|
import { TrackedLabeledUnit } from "./composite.js";
|
|
9
8
|
import { AnnotatedUnitsColumn, ColumnNotesProvider, CompositeUnitComponent, CompositeUnitsColumn, LabelTrackerProvider, SectionLabelsColumn } from "./composite.js";
|
|
10
9
|
import { useLithologies, useEnvironments } from "@macrostrat/data-provider";
|
|
11
10
|
import { useMemo } from "react";
|
|
12
|
-
import { resolveID } from "./resolvers.js";
|
|
13
11
|
function UnitsColumn({ width = 100 }) {
|
|
14
12
|
return h(LithologyColumn, { width }, h(UnitBoxes));
|
|
15
13
|
}
|
|
@@ -49,7 +47,7 @@ function UnitComponent({
|
|
|
49
47
|
let reducedWidth = _nColumns;
|
|
50
48
|
if ("layout" in division) {
|
|
51
49
|
const layout = division.layout;
|
|
52
|
-
_nColumns =
|
|
50
|
+
_nColumns = layout.totalColumns;
|
|
53
51
|
columnIx = layout.column;
|
|
54
52
|
reducedWidth = width / layout.totalColumns / layout.nColumns;
|
|
55
53
|
x = columnIx * width / _nColumns;
|
|
@@ -73,7 +71,7 @@ function useUnitColor(unit, opts = {}) {
|
|
|
73
71
|
function ColoredUnitComponent(props) {
|
|
74
72
|
const backgroundColor = useUnitColor(props.division);
|
|
75
73
|
const patternID = useMemo(() => {
|
|
76
|
-
return
|
|
74
|
+
return getBestFGDCPatternForUnit(props.division);
|
|
77
75
|
}, [props.division?.unit_id]);
|
|
78
76
|
const fill = useGeologicPattern(patternID);
|
|
79
77
|
return h(UnitComponent, {
|
|
@@ -102,7 +100,7 @@ function useUnitColorByEnvironment(unit, opts = {}) {
|
|
|
102
100
|
function EnvironmentColoredUnitComponent(props) {
|
|
103
101
|
const backgroundColor = useUnitColorByEnvironment(props.division);
|
|
104
102
|
const patternID = useMemo(() => {
|
|
105
|
-
return
|
|
103
|
+
return getBestFGDCPatternForUnit(props.division);
|
|
106
104
|
}, [props.division?.unit_id]);
|
|
107
105
|
const fill = useGeologicPattern(patternID);
|
|
108
106
|
return h(UnitComponent, {
|
|
@@ -125,9 +123,6 @@ export {
|
|
|
125
123
|
TrackedLabeledUnit,
|
|
126
124
|
UnitComponent,
|
|
127
125
|
UnitsColumn,
|
|
128
|
-
flattenLithologies,
|
|
129
|
-
getMixedColorForData,
|
|
130
|
-
getMixedUnitColor,
|
|
131
126
|
useUnitColor,
|
|
132
127
|
useUnitColorByEnvironment
|
|
133
128
|
};
|
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
|
|
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 } from \"./boxes\";\nimport { useColumnLayout } from \"@macrostrat/column-components\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport {\n getBestFGDCPatternForUnit,\n getMixedUnitColor,\n} from \"@macrostrat/stratigraphy-utils\";\nimport { TrackedLabeledUnit } from \"./composite\";\nimport { useEnvironments, useLithologies } from \"@macrostrat/data-provider\";\nimport { useMemo } from \"react\";\nimport { BaseUnit, Lithology } from \"@macrostrat/api-types\";\nimport { UnitWithLayoutParameters } from \"../prepare-units/helpers.ts\";\n\nexport * from \"./composite\";\nexport * from \"./types\";\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\ninterface UnitComponentProps<T extends BaseUnit> {\n division: UnitWithLayoutParameters<T> | T;\n nColumns: number;\n width?: number;\n}\n\nexport function UnitComponent<T extends BaseUnit>({\n division,\n nColumns = 2,\n ...rest\n}: UnitComponentProps<T>) {\n const width = rest.width ?? useColumnLayout()?.width;\n\n let _nColumns = nColumns;\n if (isNaN(_nColumns)) {\n _nColumns = 2;\n }\n let columnIx = 0;\n let x = 0;\n\n let reducedWidth = _nColumns;\n if (\"layout\" in division) {\n const layout = division.layout;\n _nColumns = layout.totalColumns;\n columnIx = layout.column;\n reducedWidth = width / layout.totalColumns / layout.nColumns;\n x = (columnIx * width) / _nColumns;\n }\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 getBestFGDCPatternForUnit(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 getBestFGDCPatternForUnit(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"],"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.
|
|
3
|
+
"version": "3.11.0",
|
|
4
4
|
"description": "Data views for Macrostrat stratigraphic columns",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,50 +46,29 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@blueprintjs/core": "^6.14.0",
|
|
49
|
-
"@macrostrat/api-types": "^1.
|
|
49
|
+
"@macrostrat/api-types": "^1.3.0",
|
|
50
50
|
"@macrostrat/color-utils": "^1.2.2",
|
|
51
51
|
"@macrostrat/column-components": "^2.1.0",
|
|
52
52
|
"@macrostrat/data-components": "^1.5.1",
|
|
53
53
|
"@macrostrat/data-provider": "^1.2.0",
|
|
54
54
|
"@macrostrat/hyper": "^3.1.1",
|
|
55
|
-
"@macrostrat/map-
|
|
56
|
-
"@macrostrat/
|
|
57
|
-
"@macrostrat/
|
|
58
|
-
"@macrostrat/mapbox-utils": "^1.8.0",
|
|
59
|
-
"@macrostrat/scoped-store": "^1.0.1",
|
|
60
|
-
"@macrostrat/stratigraphy-utils": "^1.3.0",
|
|
61
|
-
"@macrostrat/svg-map-components": "^2.0.3",
|
|
55
|
+
"@macrostrat/map-views": "^1.0.0",
|
|
56
|
+
"@macrostrat/scoped-store": "^1.1.0",
|
|
57
|
+
"@macrostrat/stratigraphy-utils": "^1.4.0",
|
|
62
58
|
"@macrostrat/timescale": "^3.2.0",
|
|
63
59
|
"@macrostrat/ui-components": "^5.2.0",
|
|
64
|
-
"@turf/boolean-point-in-polygon": "^7.3.2",
|
|
65
|
-
"@turf/buffer": "^7.3.2",
|
|
66
|
-
"@turf/centroid": "^7.3.2",
|
|
67
|
-
"@turf/distance": "^7.3.2",
|
|
68
|
-
"@turf/line-intersect": "^7.3.2",
|
|
69
|
-
"@turf/nearest-point-on-line": "^7.3.2",
|
|
70
60
|
"@types/chroma-js": "^3.1.1",
|
|
71
61
|
"@types/d3-format": "^3.0.4",
|
|
72
|
-
"@types/d3-geo": "^3.1.0",
|
|
73
62
|
"@types/d3-shape": "^3.1.7",
|
|
74
|
-
"@types/topojson-client": "^3.1.5",
|
|
75
63
|
"@visx/axis": "^3.12.0",
|
|
76
64
|
"chroma-js": "^3.2.0",
|
|
77
65
|
"classnames": "^2.5.1",
|
|
78
|
-
"cross-fetch": "^4.1.0",
|
|
79
66
|
"d3-array": "^3.2.4",
|
|
80
67
|
"d3-format": "^3.1.2",
|
|
81
|
-
"d3-geo": "^3.1.1",
|
|
82
|
-
"d3-geo-voronoi": "^2.1.0",
|
|
83
68
|
"d3-path": "^3.1.0",
|
|
84
69
|
"d3-scale": "^4.0.2",
|
|
85
70
|
"d3-shape": "^3.2.0",
|
|
86
|
-
"jotai": "^2.20.0"
|
|
87
|
-
"mapbox-gl": "^3.0.0",
|
|
88
|
-
"p-map": "^7.0.4",
|
|
89
|
-
"react-spring": "^9.7.5",
|
|
90
|
-
"topojson-client": "^3.1.0",
|
|
91
|
-
"zustand": "^5.0.3",
|
|
92
|
-
"zustand-computed": "^2.0.2"
|
|
71
|
+
"jotai": "^2.20.0"
|
|
93
72
|
},
|
|
94
73
|
"devDependencies": {
|
|
95
74
|
"@macrostrat/web-components-bundler": "1.0.1",
|
|
@@ -34,7 +34,10 @@ import type { ColumnData } from "@macrostrat/data-provider";
|
|
|
34
34
|
import { BaseUnit } from "@macrostrat/api-types";
|
|
35
35
|
import { ScaleContinuousNumeric } from "d3-scale";
|
|
36
36
|
import { ExtUnit } from "../prepare-units/types";
|
|
37
|
-
import type {
|
|
37
|
+
import type {
|
|
38
|
+
IntervalStyleBuilder,
|
|
39
|
+
TimescaleClickHandler,
|
|
40
|
+
} from "@macrostrat/timescale";
|
|
38
41
|
import { useMacrostratColumnInfo } from "@macrostrat/data-provider";
|
|
39
42
|
|
|
40
43
|
/** Standard props passed to a `columnHeaderComponent`. Everything a header
|
|
@@ -122,6 +125,7 @@ export function CorrelationChart({
|
|
|
122
125
|
columnHeaderComponent,
|
|
123
126
|
axisTopContent,
|
|
124
127
|
onClickTimescaleInterval,
|
|
128
|
+
timescaleIntervalStyle,
|
|
125
129
|
onColumnMouseOver,
|
|
126
130
|
onColumnClick,
|
|
127
131
|
isTransitioning = false,
|
|
@@ -166,6 +170,7 @@ export function CorrelationChart({
|
|
|
166
170
|
scaleInfo,
|
|
167
171
|
unconformityLabels,
|
|
168
172
|
onClickInterval: onClickTimescaleInterval,
|
|
173
|
+
intervalStyle: timescaleIntervalStyle,
|
|
169
174
|
}),
|
|
170
175
|
h(MainChartArea, [
|
|
171
176
|
h(
|
|
@@ -515,16 +520,23 @@ interface TimescaleColumnProps {
|
|
|
515
520
|
showLabels?: boolean;
|
|
516
521
|
unconformityLabels?: boolean;
|
|
517
522
|
onClickInterval?: TimescaleClickHandler;
|
|
523
|
+
intervalStyle?: IntervalStyleBuilder;
|
|
518
524
|
}
|
|
519
525
|
|
|
520
526
|
function TimescaleColumn(props: TimescaleColumnProps) {
|
|
521
|
-
const {
|
|
527
|
+
const {
|
|
528
|
+
scaleInfo,
|
|
529
|
+
unconformityLabels = true,
|
|
530
|
+
onClickInterval,
|
|
531
|
+
intervalStyle,
|
|
532
|
+
} = props;
|
|
522
533
|
return h("div.column-container.age-axis-container", [
|
|
523
534
|
h(CompositeAgeAxisCore, { ...scaleInfo }),
|
|
524
535
|
h(CompositeTimescaleCore, {
|
|
525
536
|
...scaleInfo,
|
|
526
537
|
unconformityLabels,
|
|
527
538
|
onClickInterval,
|
|
539
|
+
intervalStyle,
|
|
528
540
|
}),
|
|
529
541
|
]);
|
|
530
542
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,8 +5,10 @@ export * from "./prepare-units";
|
|
|
5
5
|
export * from "./animated-age-window";
|
|
6
6
|
export * from "./column";
|
|
7
7
|
export * from "./unit-details";
|
|
8
|
-
export * from "./maps";
|
|
9
8
|
export * from "./age-model-overlay";
|
|
10
9
|
export * from "./correlation-chart";
|
|
11
10
|
export * from "./notes";
|
|
12
11
|
export * from "./facets";
|
|
12
|
+
|
|
13
|
+
/** Legacy views */
|
|
14
|
+
export * from "@macrostrat/map-views";
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Button } from "@blueprintjs/core";
|
|
2
|
+
import {
|
|
3
|
+
IntervalShort,
|
|
4
|
+
IntervalTag,
|
|
5
|
+
Tag,
|
|
6
|
+
TagSize,
|
|
7
|
+
useInteractionProps,
|
|
8
|
+
} from "@macrostrat/data-components";
|
|
9
|
+
import type { Interval } from "@macrostrat/timescale";
|
|
10
|
+
import classNames from "classnames";
|
|
11
|
+
import h from "./age-window-tag.module.sass";
|
|
12
|
+
import { AgeRange } from "./age-range";
|
|
13
|
+
import type { AgeWindow } from "../animated-age-window";
|
|
14
|
+
|
|
15
|
+
/** Adapt a timescale `Interval` (as delivered by a `Timescale` click, with
|
|
16
|
+
* `eag`/`lag`/`nam`/`col`) to the `IntervalShort` shape the tag components
|
|
17
|
+
* take. The id prefers the Macrostrat `int_id` when the interval tree was built
|
|
18
|
+
* from the API, falling back to the interval's own `oid`. */
|
|
19
|
+
export function intervalShortFromTimescale(interval: Interval): IntervalShort {
|
|
20
|
+
return {
|
|
21
|
+
id: interval.int_id ?? interval.oid,
|
|
22
|
+
name: interval.nam,
|
|
23
|
+
color: interval.col,
|
|
24
|
+
b_age: interval.eag,
|
|
25
|
+
t_age: interval.lag,
|
|
26
|
+
rank: interval.lvl,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface AgeWindowTagProps {
|
|
31
|
+
/** The interval the window was set from, if any. */
|
|
32
|
+
interval?: IntervalShort | null;
|
|
33
|
+
/** The rendered window. When it differs from the interval's own span (a
|
|
34
|
+
* refined window) it is shown in place of the interval's range. */
|
|
35
|
+
window?: AgeWindow | null;
|
|
36
|
+
/** Renders a clear button when given. */
|
|
37
|
+
onClear?: () => void;
|
|
38
|
+
size?: TagSize;
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A compact, clearable indicator of the age window a column or correlation
|
|
43
|
+
* chart is focused on — an interval tag (linking to the interval, with its
|
|
44
|
+
* range) or a bare age range. Renders nothing without an interval or window,
|
|
45
|
+
* so it can live permanently in a chart's `axisTopContent`. */
|
|
46
|
+
export function AgeWindowTag(props: AgeWindowTagProps) {
|
|
47
|
+
const {
|
|
48
|
+
interval = null,
|
|
49
|
+
window = null,
|
|
50
|
+
onClear,
|
|
51
|
+
size = TagSize.Small,
|
|
52
|
+
className,
|
|
53
|
+
} = props;
|
|
54
|
+
if (interval == null && window == null) return null;
|
|
55
|
+
|
|
56
|
+
let tag = null;
|
|
57
|
+
if (interval == null) {
|
|
58
|
+
tag = h(Tag, { size, name: h(AgeRange, { data: window }) });
|
|
59
|
+
} else if (window == null || windowMatchesInterval(window, interval)) {
|
|
60
|
+
tag = h(IntervalTag, { interval, showAgeRange: true, size });
|
|
61
|
+
} else {
|
|
62
|
+
tag = h(RefinedIntervalTag, { interval, window, size });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return h("span.age-window-tag", { className: classNames(className) }, [
|
|
66
|
+
tag,
|
|
67
|
+
h.if(onClear != null)(Button, {
|
|
68
|
+
className: "clear-button",
|
|
69
|
+
icon: "cross",
|
|
70
|
+
minimal: true,
|
|
71
|
+
small: true,
|
|
72
|
+
title: "Clear",
|
|
73
|
+
onClick: onClear,
|
|
74
|
+
}),
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function RefinedIntervalTag({
|
|
79
|
+
interval,
|
|
80
|
+
window,
|
|
81
|
+
size,
|
|
82
|
+
}: {
|
|
83
|
+
interval: IntervalShort;
|
|
84
|
+
window: AgeWindow;
|
|
85
|
+
size: TagSize;
|
|
86
|
+
}) {
|
|
87
|
+
const interaction = useInteractionProps({ int_id: interval.id });
|
|
88
|
+
return h(Tag, {
|
|
89
|
+
...interaction,
|
|
90
|
+
size,
|
|
91
|
+
name: interval.name,
|
|
92
|
+
color: interval.color,
|
|
93
|
+
details: h(AgeRange, { data: window }),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function windowMatchesInterval(
|
|
98
|
+
window: AgeWindow,
|
|
99
|
+
interval: IntervalShort,
|
|
100
|
+
): boolean {
|
|
101
|
+
return window.t_age === interval.t_age && window.b_age === interval.b_age;
|
|
102
|
+
}
|
package/src/units/boxes.ts
CHANGED
|
@@ -11,15 +11,18 @@ import {
|
|
|
11
11
|
import { SizeAwareLabel, Clickable } from "@macrostrat/ui-components";
|
|
12
12
|
import hyper from "@macrostrat/hyper";
|
|
13
13
|
import { ReactNode, useContext, useMemo } from "react";
|
|
14
|
-
import { resolveID, scalePattern } from "./resolvers";
|
|
15
14
|
import { useUnitSelectionTarget } from "../data-provider";
|
|
16
15
|
import { useLithologies } from "@macrostrat/data-provider";
|
|
17
16
|
import { IUnit } from "./types";
|
|
18
17
|
import styles from "./boxes.module.sass";
|
|
19
18
|
import classNames from "classnames";
|
|
20
19
|
import { getUnitHeightRange } from "../prepare-units/utils";
|
|
21
|
-
import { getMixedUnitColor } from "./colors";
|
|
22
20
|
import type { RectBounds } from "./types";
|
|
21
|
+
import {
|
|
22
|
+
getBestFGDCPatternForUnit,
|
|
23
|
+
scalePattern,
|
|
24
|
+
getMixedUnitColor,
|
|
25
|
+
} from "@macrostrat/stratigraphy-utils";
|
|
23
26
|
|
|
24
27
|
const h = hyper.styled(styles);
|
|
25
28
|
|
|
@@ -158,7 +161,7 @@ function Unit(props: UnitProps) {
|
|
|
158
161
|
overflowTop: hasOverflowTop,
|
|
159
162
|
overflowBottom: hasOverflowBottom,
|
|
160
163
|
};
|
|
161
|
-
const _patternID = patternID ??
|
|
164
|
+
const _patternID = patternID ?? getBestFGDCPatternForUnit(d);
|
|
162
165
|
let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);
|
|
163
166
|
|
|
164
167
|
const hasBackgroundColor = backgroundColor != null;
|
|
@@ -289,7 +292,7 @@ function UnitBoxes<T>(props: {
|
|
|
289
292
|
|
|
290
293
|
return h(
|
|
291
294
|
PatternDefsProvider,
|
|
292
|
-
{ resolveID, scalePattern },
|
|
295
|
+
{ resolveID: getBestFGDCPatternForUnit, scalePattern },
|
|
293
296
|
h("g.divisions", children),
|
|
294
297
|
);
|
|
295
298
|
}
|
package/src/units/index.ts
CHANGED
|
@@ -5,20 +5,21 @@ import {
|
|
|
5
5
|
} from "@macrostrat/column-components";
|
|
6
6
|
import { UnitNamesColumn } from "./names";
|
|
7
7
|
import { ICompositeUnitProps } from "./composite";
|
|
8
|
-
import { UnitBoxes
|
|
8
|
+
import { UnitBoxes } from "./boxes";
|
|
9
9
|
import { useColumnLayout } from "@macrostrat/column-components";
|
|
10
10
|
import { useInDarkMode } from "@macrostrat/ui-components";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
getBestFGDCPatternForUnit,
|
|
13
|
+
getMixedUnitColor,
|
|
14
|
+
} from "@macrostrat/stratigraphy-utils";
|
|
12
15
|
import { TrackedLabeledUnit } from "./composite";
|
|
13
16
|
import { useEnvironments, useLithologies } from "@macrostrat/data-provider";
|
|
14
17
|
import { useMemo } from "react";
|
|
15
|
-
import { resolveID } from "./resolvers";
|
|
16
18
|
import { BaseUnit, Lithology } from "@macrostrat/api-types";
|
|
17
19
|
import { UnitWithLayoutParameters } from "../prepare-units/helpers.ts";
|
|
18
20
|
|
|
19
21
|
export * from "./composite";
|
|
20
22
|
export * from "./types";
|
|
21
|
-
export * from "./colors";
|
|
22
23
|
|
|
23
24
|
export function UnitsColumn({ width = 100 }) {
|
|
24
25
|
/*
|
|
@@ -80,11 +81,12 @@ export function UnitComponent<T extends BaseUnit>({
|
|
|
80
81
|
let reducedWidth = _nColumns;
|
|
81
82
|
if ("layout" in division) {
|
|
82
83
|
const layout = division.layout;
|
|
83
|
-
_nColumns =
|
|
84
|
+
_nColumns = layout.totalColumns;
|
|
84
85
|
columnIx = layout.column;
|
|
85
86
|
reducedWidth = width / layout.totalColumns / layout.nColumns;
|
|
86
87
|
x = (columnIx * width) / _nColumns;
|
|
87
88
|
}
|
|
89
|
+
|
|
88
90
|
return h(TrackedLabeledUnit, {
|
|
89
91
|
division,
|
|
90
92
|
...rest,
|
|
@@ -115,7 +117,7 @@ export function ColoredUnitComponent(props) {
|
|
|
115
117
|
const backgroundColor = useUnitColor(props.division);
|
|
116
118
|
|
|
117
119
|
const patternID = useMemo(() => {
|
|
118
|
-
return
|
|
120
|
+
return getBestFGDCPatternForUnit(props.division); // ?? getPatternID(props.division.lith, lithMap);
|
|
119
121
|
}, [props.division?.unit_id]);
|
|
120
122
|
|
|
121
123
|
const fill = useGeologicPattern(patternID);
|
|
@@ -157,7 +159,7 @@ export function EnvironmentColoredUnitComponent(props) {
|
|
|
157
159
|
const backgroundColor = useUnitColorByEnvironment(props.division);
|
|
158
160
|
|
|
159
161
|
const patternID = useMemo(() => {
|
|
160
|
-
return
|
|
162
|
+
return getBestFGDCPatternForUnit(props.division); // ?? getPatternID(props.division.lith, lithMap);
|
|
161
163
|
}, [props.division?.unit_id]);
|
|
162
164
|
|
|
163
165
|
const fill = useGeologicPattern(patternID);
|
|
@@ -168,22 +170,3 @@ export function EnvironmentColoredUnitComponent(props) {
|
|
|
168
170
|
...props,
|
|
169
171
|
});
|
|
170
172
|
}
|
|
171
|
-
|
|
172
|
-
function getPatternID(
|
|
173
|
-
liths: Array<Lithology>,
|
|
174
|
-
lithMap: Map<number, Lithology>,
|
|
175
|
-
): string | null {
|
|
176
|
-
if (lithMap == null || liths == null || liths.length == 0) {
|
|
177
|
-
return null;
|
|
178
|
-
}
|
|
179
|
-
const patternIDs = new Set<string>();
|
|
180
|
-
for (const lith of liths) {
|
|
181
|
-
const lithData = lithMap.get(lith.lith_id);
|
|
182
|
-
if (lithData) {
|
|
183
|
-
patternIDs.add(`${lithData.fill}`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
let id = patternIDs.values()[0];
|
|
187
|
-
if (id == "0") return null;
|
|
188
|
-
return id;
|
|
189
|
-
}
|