@macrostrat/column-views 3.9.0 → 3.10.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 +25 -0
- package/dist/index.cjs +15 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -34
- package/dist/index.js.map +1 -1
- 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/index.ts +3 -1
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.10.0] - 2026-09-01 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/column-views-v3.9.0...@macrostrat/column-views-v3.10.0)
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Improve the internal structure of the correlation map store
|
|
8
|
+
[4738d3df](https://github.com/UW-Macrostrat/web-components/commit/4738d3df1bdec8f4b233af215cadc0422ed562e8)
|
|
9
|
+
- Created the @macrostrat/map-views module for specific map interactions and
|
|
10
|
+
[4738d3df](https://github.com/UW-Macrostrat/web-components/commit/4738d3df1bdec8f4b233af215cadc0422ed562e8)
|
|
11
|
+
high-level views around Macrostrat maps.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Improve the rendering of correlation chart units
|
|
16
|
+
[4738d3df](https://github.com/UW-Macrostrat/web-components/commit/4738d3df1bdec8f4b233af215cadc0422ed562e8)
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
[4738d3df](https://github.com/UW-Macrostrat/web-components/commit/4738d3df1bdec8f4b233af215cadc0422ed562e8)
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
[03860266](https://github.com/UW-Macrostrat/web-components/commit/038602669f6d71fed4b847cd55c9d7c32885c054)
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
[4738d3df](https://github.com/UW-Macrostrat/web-components/commit/4738d3df1bdec8f4b233af215cadc0422ed562e8)
|
|
23
|
+
- @macrostrat/map-views@1.0.0
|
|
24
|
+
- @macrostrat/scoped-store@1.1.0
|
|
25
|
+
- @macrostrat/stratigraphy-utils@1.4.0
|
|
26
|
+
- @macrostrat/api-types@1.3.0
|
|
27
|
+
|
|
3
28
|
## [3.9.0] - 2026-08-25 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/column-views-v3.8.0...@macrostrat/column-views-v3.9.0)
|
|
4
29
|
|
|
5
30
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -2,41 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const index = require("./units/index.cjs");
|
|
4
4
|
const ageAxis = require("./age-axis.cjs");
|
|
5
|
-
const index$
|
|
5
|
+
const index$3 = require("./prepare-units/index.cjs");
|
|
6
6
|
const animatedAgeWindow = require("./animated-age-window.cjs");
|
|
7
7
|
const column = require("./column.cjs");
|
|
8
8
|
const ageModelOverlay = require("./age-model-overlay.cjs");
|
|
9
9
|
const notes = require("./notes.cjs");
|
|
10
|
+
const mapViews = require("@macrostrat/map-views");
|
|
10
11
|
const ageRange = require("./unit-details/age-range.cjs");
|
|
11
12
|
const composite = require("./units/composite.cjs");
|
|
12
|
-
const columns = require("./maps/layers/columns.cjs");
|
|
13
13
|
const base = require("./facets/measurements/base.cjs");
|
|
14
14
|
const dataComponents = require("@macrostrat/data-components");
|
|
15
|
-
const layers = require("./maps/column-navigation/svg/layers.cjs");
|
|
16
|
-
const core = require("./maps/column-correlation/core.cjs");
|
|
17
|
-
const state = require("./maps/column-correlation/state.cjs");
|
|
18
|
-
const index$1 = require("./maps/column-navigation/mapbox/index.cjs");
|
|
19
15
|
const columnNav = require("./data-provider/column-nav.cjs");
|
|
20
|
-
const index$2 = require("./maps/column-navigation/svg/index.cjs");
|
|
21
16
|
const main = require("./correlation-chart/main.cjs");
|
|
22
|
-
const index$
|
|
17
|
+
const index$1 = require("./facets/detrital-zircon/index.cjs");
|
|
23
18
|
const provider = require("./facets/fossils/provider.cjs");
|
|
24
19
|
const types = require("./prepare-units/types.cjs");
|
|
25
|
-
const index$4 = require("./maps/inset-map/index.cjs");
|
|
26
20
|
const isotopesColumn = require("./facets/carbon-isotopes/isotopes-column.cjs");
|
|
27
21
|
const panel = require("./unit-details/panel.cjs");
|
|
28
22
|
const store = require("./data-provider/store.cjs");
|
|
29
|
-
const units = require("./maps/layers/units.cjs");
|
|
30
23
|
const dataProvider = require("./facets/carbon-isotopes/data-provider.cjs");
|
|
31
24
|
const utils = require("./prepare-units/utils.cjs");
|
|
32
|
-
const index$
|
|
25
|
+
const index$2 = require("./facets/fossils/index.cjs");
|
|
33
26
|
const taxonRanges = require("./facets/fossils/taxon-ranges.cjs");
|
|
34
27
|
const sgp = require("./facets/measurements/sgp.cjs");
|
|
35
28
|
const stratNames = require("./unit-details/strat-names.cjs");
|
|
36
29
|
const modalPanel = require("./unit-details/modal-panel.cjs");
|
|
37
30
|
const popover = require("./unit-details/popover.cjs");
|
|
38
31
|
const unitSelection = require("./data-provider/unit-selection.cjs");
|
|
39
|
-
const colors = require("./units/colors.cjs");
|
|
40
32
|
const hashString = require("./correlation-chart/hash-string.cjs");
|
|
41
33
|
const helpers = require("./prepare-units/helpers.cjs");
|
|
42
34
|
exports.BasicUnitComponent = index.BasicUnitComponent;
|
|
@@ -52,8 +44,8 @@ exports.ApproximateHeightAxis = ageAxis.ApproximateHeightAxis;
|
|
|
52
44
|
exports.CompositeAgeAxis = ageAxis.CompositeAgeAxis;
|
|
53
45
|
exports.CompositeAgeAxisCore = ageAxis.CompositeAgeAxisCore;
|
|
54
46
|
exports.VerticalAxisLabel = ageAxis.VerticalAxisLabel;
|
|
55
|
-
exports.prepareColumnUnits = index$
|
|
56
|
-
exports.usePreparedColumnUnits = index$
|
|
47
|
+
exports.prepareColumnUnits = index$3.prepareColumnUnits;
|
|
48
|
+
exports.usePreparedColumnUnits = index$3.usePreparedColumnUnits;
|
|
57
49
|
exports.useAnimatedAgeWindow = animatedAgeWindow.useAnimatedAgeWindow;
|
|
58
50
|
exports.Column = column.Column;
|
|
59
51
|
exports.ColumnBasicInfo = column.ColumnBasicInfo;
|
|
@@ -75,9 +67,6 @@ exports.CompositeUnitsColumn = composite.CompositeUnitsColumn;
|
|
|
75
67
|
exports.LabelTrackerProvider = composite.LabelTrackerProvider;
|
|
76
68
|
exports.SectionLabelsColumn = composite.SectionLabelsColumn;
|
|
77
69
|
exports.TrackedLabeledUnit = composite.TrackedLabeledUnit;
|
|
78
|
-
exports.BaseColumnsLayer = columns.BaseColumnsLayer;
|
|
79
|
-
exports.SelectedColumnOverlay = columns.SelectedColumnOverlay;
|
|
80
|
-
exports.buildColumnsStyle = columns.buildColumnsStyle;
|
|
81
70
|
exports.BaseMeasurementsColumn = base.BaseMeasurementsColumn;
|
|
82
71
|
exports.TruncatedList = base.TruncatedList;
|
|
83
72
|
exports.groupNotesByPixelDistance = base.groupNotesByPixelDistance;
|
|
@@ -95,32 +84,15 @@ Object.defineProperty(exports, "UnitIdentifier", {
|
|
|
95
84
|
enumerable: true,
|
|
96
85
|
get: () => dataComponents.UnitIdentifier
|
|
97
86
|
});
|
|
98
|
-
exports.ColumnCenters = layers.ColumnCenters;
|
|
99
|
-
exports.ColumnFeatures = layers.ColumnFeatures;
|
|
100
|
-
exports.ColumnKeyboardNavigation = layers.ColumnKeyboardNavigation;
|
|
101
|
-
exports.Columns = layers.Columns;
|
|
102
|
-
exports.CurrentColumn = layers.CurrentColumn;
|
|
103
|
-
exports.MeasurementsLayer = layers.MeasurementsLayer;
|
|
104
|
-
exports.ColumnCorrelationMap = core.ColumnCorrelationMap;
|
|
105
|
-
exports.ColumnCorrelationProvider = state.ColumnCorrelationProvider;
|
|
106
|
-
exports.useColumnMapLink = state.useColumnMapLink;
|
|
107
|
-
exports.useCorrelationMapStore = state.useCorrelationMapStore;
|
|
108
|
-
exports.ColumnHoverInteraction = index$1.ColumnHoverInteraction;
|
|
109
|
-
exports.ColumnNavigationMap = index$1.ColumnNavigationMap;
|
|
110
|
-
exports.ColumnSelectionManager = index$1.ColumnSelectionManager;
|
|
111
|
-
exports.ColumnsNavigationLayer = index$1.ColumnsNavigationLayer;
|
|
112
87
|
exports.ColumnNavProvider = columnNav.ColumnNavProvider;
|
|
113
88
|
exports.useColumnNav = columnNav.useColumnNav;
|
|
114
|
-
exports.ColumnNavigationSVGMap = index$2.ColumnNavigationSVGMap;
|
|
115
|
-
exports.ResizableMapFrame = index$2.ResizableMapFrame;
|
|
116
89
|
exports.CorrelationChart = main.CorrelationChart;
|
|
117
|
-
exports.DetritalColumn = index$
|
|
118
|
-
exports.DetritalGroup = index$
|
|
90
|
+
exports.DetritalColumn = index$1.DetritalColumn;
|
|
91
|
+
exports.DetritalGroup = index$1.DetritalGroup;
|
|
119
92
|
exports.FossilDataType = provider.FossilDataType;
|
|
120
93
|
exports.useFossilData = provider.useFossilData;
|
|
121
94
|
exports.HeightMethod = types.HeightMethod;
|
|
122
95
|
exports.HybridScaleType = types.HybridScaleType;
|
|
123
|
-
exports.InsetMap = index$4.InsetMap;
|
|
124
96
|
exports.IsotopesColumn = isotopesColumn.IsotopesColumn;
|
|
125
97
|
exports.IsotopesDataset = isotopesColumn.IsotopesDataset;
|
|
126
98
|
exports.LegendPanelHeader = panel.LegendPanelHeader;
|
|
@@ -140,8 +112,6 @@ exports.useColumnUnitsMap = store.useColumnUnitsMap;
|
|
|
140
112
|
exports.useCompositeScale = store.useCompositeScale;
|
|
141
113
|
exports.useMacrostratColumnData = store.useMacrostratColumnData;
|
|
142
114
|
exports.useMacrostratUnits = store.useMacrostratUnits;
|
|
143
|
-
exports.MacrostratUnitsOverlay = units.MacrostratUnitsOverlay;
|
|
144
|
-
exports.buildUnitsStyle = units.buildUnitsStyle;
|
|
145
115
|
exports.MeasurementDataContext = dataProvider.MeasurementDataContext;
|
|
146
116
|
exports.MeasurementDataProvider = dataProvider.MeasurementDataProvider;
|
|
147
117
|
exports.useMeasurementData = dataProvider.useMeasurementData;
|
|
@@ -153,7 +123,7 @@ exports.ensureRealFloat = utils.ensureRealFloat;
|
|
|
153
123
|
exports.getPositionWithinUnit = utils.getPositionWithinUnit;
|
|
154
124
|
exports.getUnitHeightRange = utils.getUnitHeightRange;
|
|
155
125
|
exports.unitsOverlap = utils.unitsOverlap;
|
|
156
|
-
exports.PBDBFossilsColumn = index$
|
|
126
|
+
exports.PBDBFossilsColumn = index$2.PBDBFossilsColumn;
|
|
157
127
|
exports.PBDBOccurrencesMatrix = taxonRanges.PBDBOccurrencesMatrix;
|
|
158
128
|
exports.SGPMeasurementsColumn = sgp.SGPMeasurementsColumn;
|
|
159
129
|
exports.StratNameField = stratNames.StratNameField;
|
|
@@ -171,10 +141,13 @@ exports.useSelectedUnit = unitSelection.useSelectedUnit;
|
|
|
171
141
|
exports.useUnitSelection = unitSelection.useUnitSelection;
|
|
172
142
|
exports.useUnitSelectionDispatch = unitSelection.useUnitSelectionDispatch;
|
|
173
143
|
exports.useUnitSelectionTarget = unitSelection.useUnitSelectionTarget;
|
|
174
|
-
exports.flattenLithologies = colors.flattenLithologies;
|
|
175
|
-
exports.getMixedColorForData = colors.getMixedColorForData;
|
|
176
|
-
exports.getMixedUnitColor = colors.getMixedUnitColor;
|
|
177
144
|
exports.parseLineFromString = hashString.parseLineFromString;
|
|
178
145
|
exports.stringifyLine = hashString.stringifyLine;
|
|
179
146
|
exports.preprocessUnits = helpers.preprocessUnits;
|
|
147
|
+
Object.keys(mapViews).forEach((k) => {
|
|
148
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
get: () => mapViews[k]
|
|
151
|
+
});
|
|
152
|
+
});
|
|
180
153
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ 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
|
+
/** Legacy views */
|
|
13
|
+
export * from '@macrostrat/map-views';
|
package/dist/index.js
CHANGED
|
@@ -5,26 +5,19 @@ import { useAnimatedAgeWindow } from "./animated-age-window.js";
|
|
|
5
5
|
import { Column, ColumnBasicInfo, ColumnContainer } from "./column.js";
|
|
6
6
|
import { BoundaryAgeModelOverlay, ComputedSurfacesOverlay } from "./age-model-overlay.js";
|
|
7
7
|
import { ColumnNotes } from "./notes.js";
|
|
8
|
+
export * from "@macrostrat/map-views";
|
|
8
9
|
import { AgeField, AgeLabel, AgeRange, Duration, IntervalProportions, getAge, getAgeRange } from "./unit-details/age-range.js";
|
|
9
10
|
import { AnnotatedUnitsColumn, ColumnNotesProvider, CompositeUnitComponent, CompositeUnitsColumn, LabelTrackerProvider, SectionLabelsColumn, TrackedLabeledUnit } from "./units/composite.js";
|
|
10
|
-
import { BaseColumnsLayer, SelectedColumnOverlay, buildColumnsStyle } from "./maps/layers/columns.js";
|
|
11
11
|
import { BaseMeasurementsColumn, TruncatedList, groupNotesByPixelDistance, mergeHeightRanges, standardizeMeasurementHeight } from "./facets/measurements/base.js";
|
|
12
12
|
import { ClickableText, Identifier, UnitIdentifier } from "@macrostrat/data-components";
|
|
13
|
-
import { ColumnCenters, ColumnFeatures, ColumnKeyboardNavigation, Columns, CurrentColumn, MeasurementsLayer } from "./maps/column-navigation/svg/layers.js";
|
|
14
|
-
import { ColumnCorrelationMap } from "./maps/column-correlation/core.js";
|
|
15
|
-
import { ColumnCorrelationProvider, useColumnMapLink, useCorrelationMapStore } from "./maps/column-correlation/state.js";
|
|
16
|
-
import { ColumnHoverInteraction, ColumnNavigationMap, ColumnSelectionManager, ColumnsNavigationLayer } from "./maps/column-navigation/mapbox/index.js";
|
|
17
13
|
import { ColumnNavProvider, useColumnNav } from "./data-provider/column-nav.js";
|
|
18
|
-
import { ColumnNavigationSVGMap, ResizableMapFrame } from "./maps/column-navigation/svg/index.js";
|
|
19
14
|
import { CorrelationChart } from "./correlation-chart/main.js";
|
|
20
15
|
import { DetritalColumn, DetritalGroup } from "./facets/detrital-zircon/index.js";
|
|
21
16
|
import { FossilDataType, useFossilData } from "./facets/fossils/provider.js";
|
|
22
17
|
import { HeightMethod, HybridScaleType } from "./prepare-units/types.js";
|
|
23
|
-
import { InsetMap } from "./maps/inset-map/index.js";
|
|
24
18
|
import { IsotopesColumn, IsotopesDataset } from "./facets/carbon-isotopes/isotopes-column.js";
|
|
25
19
|
import { LegendPanelHeader, ReferencesField, ThicknessField, UnitDetailsFeature, UnitDetailsPanel } from "./unit-details/panel.js";
|
|
26
20
|
import { LithologiesProvider, MacrostratColumnDataProvider, MacrostratColumnProvider, MacrostratColumnStateProvider, UnitSelectionProvider, columnUnitsAtom, columnUnitsMapAtom, scope, useColumnUnitsMap, useCompositeScale, useMacrostratColumnData, useMacrostratUnits } from "./data-provider/store.js";
|
|
27
|
-
import { MacrostratUnitsOverlay, buildUnitsStyle } from "./maps/layers/units.js";
|
|
28
21
|
import { MeasurementDataContext, MeasurementDataProvider, useMeasurementData } from "./facets/carbon-isotopes/data-provider.js";
|
|
29
22
|
import { MergeSectionsMode, agesOverlap, createUnitSorter, ensureArray, ensureRealFloat, getPositionWithinUnit, getUnitHeightRange, unitsOverlap } from "./prepare-units/utils.js";
|
|
30
23
|
import { PBDBFossilsColumn } from "./facets/fossils/index.js";
|
|
@@ -34,7 +27,6 @@ import { StratNameField } from "./unit-details/strat-names.js";
|
|
|
34
27
|
import { UnitDetailsPanelWithNavigation } from "./unit-details/modal-panel.js";
|
|
35
28
|
import { UnitDetailsPopover, UnitSelectionPopover } from "./unit-details/popover.js";
|
|
36
29
|
import { UnitKeyboardNavigation, UnitSelectionCallbackManager, allowUnitSelectionAtom, selectedUnitElementAtom, selectedUnitIDAtom, useAtomOverlayPosition, useColumnRef, useSelectedUnit, useUnitSelection, useUnitSelectionDispatch, useUnitSelectionTarget } from "./data-provider/unit-selection.js";
|
|
37
|
-
import { flattenLithologies, getMixedColorForData, getMixedUnitColor } from "./units/colors.js";
|
|
38
30
|
import { parseLineFromString, stringifyLine } from "./correlation-chart/hash-string.js";
|
|
39
31
|
import { preprocessUnits } from "./prepare-units/helpers.js";
|
|
40
32
|
export {
|
|
@@ -44,7 +36,6 @@ export {
|
|
|
44
36
|
AgeRange,
|
|
45
37
|
AnnotatedUnitsColumn,
|
|
46
38
|
ApproximateHeightAxis,
|
|
47
|
-
BaseColumnsLayer,
|
|
48
39
|
BaseMeasurementsColumn,
|
|
49
40
|
BasicUnitComponent,
|
|
50
41
|
BoundaryAgeModelOverlay,
|
|
@@ -52,28 +43,16 @@ export {
|
|
|
52
43
|
ColoredUnitComponent,
|
|
53
44
|
Column,
|
|
54
45
|
ColumnBasicInfo,
|
|
55
|
-
ColumnCenters,
|
|
56
46
|
ColumnContainer,
|
|
57
|
-
ColumnCorrelationMap,
|
|
58
|
-
ColumnCorrelationProvider,
|
|
59
|
-
ColumnFeatures,
|
|
60
|
-
ColumnHoverInteraction,
|
|
61
|
-
ColumnKeyboardNavigation,
|
|
62
47
|
ColumnNavProvider,
|
|
63
|
-
ColumnNavigationMap,
|
|
64
|
-
ColumnNavigationSVGMap,
|
|
65
48
|
ColumnNotes,
|
|
66
49
|
ColumnNotesProvider,
|
|
67
|
-
ColumnSelectionManager,
|
|
68
|
-
Columns,
|
|
69
|
-
ColumnsNavigationLayer,
|
|
70
50
|
CompositeAgeAxis,
|
|
71
51
|
CompositeAgeAxisCore,
|
|
72
52
|
CompositeUnitComponent,
|
|
73
53
|
CompositeUnitsColumn,
|
|
74
54
|
ComputedSurfacesOverlay,
|
|
75
55
|
CorrelationChart,
|
|
76
|
-
CurrentColumn,
|
|
77
56
|
DetritalColumn,
|
|
78
57
|
DetritalGroup,
|
|
79
58
|
Duration,
|
|
@@ -82,7 +61,6 @@ export {
|
|
|
82
61
|
HeightMethod,
|
|
83
62
|
HybridScaleType,
|
|
84
63
|
Identifier,
|
|
85
|
-
InsetMap,
|
|
86
64
|
IntervalProportions,
|
|
87
65
|
IsotopesColumn,
|
|
88
66
|
IsotopesDataset,
|
|
@@ -92,18 +70,14 @@ export {
|
|
|
92
70
|
MacrostratColumnDataProvider,
|
|
93
71
|
MacrostratColumnProvider,
|
|
94
72
|
MacrostratColumnStateProvider,
|
|
95
|
-
MacrostratUnitsOverlay,
|
|
96
73
|
MeasurementDataContext,
|
|
97
74
|
MeasurementDataProvider,
|
|
98
|
-
MeasurementsLayer,
|
|
99
75
|
MergeSectionsMode,
|
|
100
76
|
PBDBFossilsColumn,
|
|
101
77
|
PBDBOccurrencesMatrix,
|
|
102
78
|
ReferencesField,
|
|
103
|
-
ResizableMapFrame,
|
|
104
79
|
SGPMeasurementsColumn,
|
|
105
80
|
SectionLabelsColumn,
|
|
106
|
-
SelectedColumnOverlay,
|
|
107
81
|
SimpleUnitsColumn,
|
|
108
82
|
StratNameField,
|
|
109
83
|
ThicknessField,
|
|
@@ -123,18 +97,13 @@ export {
|
|
|
123
97
|
VerticalAxisLabel,
|
|
124
98
|
agesOverlap,
|
|
125
99
|
allowUnitSelectionAtom,
|
|
126
|
-
buildColumnsStyle,
|
|
127
|
-
buildUnitsStyle,
|
|
128
100
|
columnUnitsAtom,
|
|
129
101
|
columnUnitsMapAtom,
|
|
130
102
|
createUnitSorter,
|
|
131
103
|
ensureArray,
|
|
132
104
|
ensureRealFloat,
|
|
133
|
-
flattenLithologies,
|
|
134
105
|
getAge,
|
|
135
106
|
getAgeRange,
|
|
136
|
-
getMixedColorForData,
|
|
137
|
-
getMixedUnitColor,
|
|
138
107
|
getPositionWithinUnit,
|
|
139
108
|
getUnitHeightRange,
|
|
140
109
|
groupNotesByPixelDistance,
|
|
@@ -150,12 +119,10 @@ export {
|
|
|
150
119
|
unitsOverlap,
|
|
151
120
|
useAnimatedAgeWindow,
|
|
152
121
|
useAtomOverlayPosition,
|
|
153
|
-
useColumnMapLink,
|
|
154
122
|
useColumnNav,
|
|
155
123
|
useColumnRef,
|
|
156
124
|
useColumnUnitsMap,
|
|
157
125
|
useCompositeScale,
|
|
158
|
-
useCorrelationMapStore,
|
|
159
126
|
useFossilData,
|
|
160
127
|
useMacrostratColumnData,
|
|
161
128
|
useMacrostratUnits,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/units/boxes.cjs
CHANGED
|
@@ -4,11 +4,11 @@ const columnComponents = require("@macrostrat/column-components");
|
|
|
4
4
|
const uiComponents = require("@macrostrat/ui-components");
|
|
5
5
|
const h$1 = require("@macrostrat/hyper");
|
|
6
6
|
const React = require("react");
|
|
7
|
-
const resolvers = require("./resolvers.cjs");
|
|
8
7
|
require("@macrostrat/data-provider");
|
|
9
8
|
const boxes_module = require("./boxes.module.sass.cjs");
|
|
10
9
|
const classNames = require("classnames");
|
|
11
10
|
const utils = require("../prepare-units/utils.cjs");
|
|
11
|
+
const stratigraphyUtils = require("@macrostrat/stratigraphy-utils");
|
|
12
12
|
const unitSelection = require("../data-provider/unit-selection.cjs");
|
|
13
13
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
14
14
|
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
@@ -57,7 +57,7 @@ function Unit(props) {
|
|
|
57
57
|
overflowTop: hasOverflowTop,
|
|
58
58
|
overflowBottom: hasOverflowBottom
|
|
59
59
|
};
|
|
60
|
-
const _patternID = patternID ??
|
|
60
|
+
const _patternID = patternID ?? stratigraphyUtils.getBestFGDCPatternForUnit(d);
|
|
61
61
|
let _fill = fill ?? columnComponents.useGeologicPattern(_patternID, defaultFill);
|
|
62
62
|
const hasBackgroundColor = backgroundColor != null;
|
|
63
63
|
const _className = classNames__default.default(className, { colored: hasBackgroundColor });
|
|
@@ -165,7 +165,7 @@ function UnitBoxes(props) {
|
|
|
165
165
|
}, [divisions, unitComponent, unitComponentProps]);
|
|
166
166
|
return h(
|
|
167
167
|
columnComponents.PatternDefsProvider,
|
|
168
|
-
{ resolveID:
|
|
168
|
+
{ resolveID: stratigraphyUtils.getBestFGDCPatternForUnit, scalePattern: stratigraphyUtils.scalePattern },
|
|
169
169
|
h("g.divisions", children)
|
|
170
170
|
);
|
|
171
171
|
}
|
package/dist/units/boxes.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boxes.cjs","sources":["../../src/units/boxes.ts"],"sourcesContent":["import {\n ColumnAxisType,\n ColumnContext,\n ColumnLayoutContext,\n ClippableRect,\n ForeignObject,\n PatternDefsProvider,\n useColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { SizeAwareLabel, Clickable } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport { ReactNode, useContext, useMemo } from \"react\";\nimport { resolveID, scalePattern } from \"./resolvers\";\nimport { useUnitSelectionTarget } from \"../data-provider\";\nimport { useLithologies } from \"@macrostrat/data-provider\";\nimport { IUnit } from \"./types\";\nimport styles from \"./boxes.module.sass\";\nimport classNames from \"classnames\";\nimport { getUnitHeightRange } from \"../prepare-units/utils\";\nimport { getMixedUnitColor } from \"./colors\";\nimport type { RectBounds } from \"./types\";\n\nconst h = hyper.styled(styles);\n\n/** Resolve a class name through this file's CSS module exactly as the styled\n * `h` would (module-scoped classes are hashed; unknown/global classes pass\n * through). Needed because `ClippableRect` renders the element in\n * `@macrostrat/column-components`, so class resolution must happen here. */\nconst cls = (name: string): string => (styles as any)[name] ?? name;\n\ninterface UnitRectOptions {\n widthFraction?: number;\n axisType?: ColumnAxisType;\n // Padding to create overflow for zig-zags or other ornamented edges\n padding?: number;\n}\n\ninterface UnitProps extends Clickable, Partial<RectBounds>, UnitRectOptions {\n division: IUnit;\n resolveID?(IUnit): string;\n UUID?: string;\n defaultFill?: string;\n widthFraction?: number;\n children?: ReactNode;\n className?: string;\n fill?: string;\n backgroundColor?: string;\n patternColor?: string;\n patternID?: string | number;\n}\n\nexport interface LabeledUnitProps\n extends UnitRectOptions, Clickable, Partial<RectBounds> {\n division: IUnit;\n patternID?: string | number;\n label: string;\n onLabelUpdated?(label: string, shown: boolean);\n halfWidth?: boolean;\n showLabel?: boolean;\n backgroundColor?: string;\n}\n\nfunction useUnitRect(\n division: IUnit,\n options: UnitRectOptions = {},\n): RectBounds {\n const {\n widthFraction = 1,\n axisType = ColumnAxisType.AGE,\n padding = 0,\n } = options;\n const { scale } = useContext(ColumnContext);\n const { width } = useContext(ColumnLayoutContext);\n\n const [bottomHeight, topHeight] = getUnitHeightRange(division, axisType);\n\n const y = scale(topHeight);\n const height = Math.abs(scale(bottomHeight) - y);\n\n return {\n x: width * (1 - widthFraction) - padding,\n y: y - padding,\n height: height + padding * 2,\n width: widthFraction * width + padding * 2,\n };\n}\n\nexport function MinimalUnit(props) {\n const {\n division: d,\n children,\n className,\n widthFraction = 1,\n axisType: _, // not sure why this is brought in...\n nColumns: __,\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const lithMap = useLithologies();\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n };\n\n const backgroundColor = getMixedUnitColor(d, lithMap, null, false);\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n \"--column-stroke-color\": backgroundColor,\n },\n },\n [\n h(\"rect.unit.background\", {\n ref,\n ...bounds,\n fill: backgroundColor,\n fillOpacity: 0.8,\n stroke: backgroundColor,\n onClick,\n }),\n h.if(linked)(\"rect.linked-overlay\", bounds),\n h.if(selected)(\"rect.selection-overlay\", bounds),\n ],\n );\n}\n\nfunction Unit(props: UnitProps) {\n const {\n division: d,\n children,\n fill,\n defaultFill = \"transparent\",\n className,\n widthFraction = 1,\n backgroundColor,\n patternColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n\n const hasOverflowTop = d.t_clip_pos != null;\n const hasOverflowBottom = d.b_clip_pos != null;\n\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n overflowTop: hasOverflowTop,\n overflowBottom: hasOverflowBottom,\n };\n const _patternID = patternID ?? resolveID(d);\n let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);\n\n const hasBackgroundColor = backgroundColor != null;\n\n const _className = classNames(className, { colored: hasBackgroundColor });\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className: _className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n },\n },\n [\n h(ClippableRect, {\n ...bounds,\n fill: backgroundColor,\n onClick,\n className: cls(\"background\"),\n }),\n h(ClippableRect, {\n ref,\n ...bounds,\n fill: _fill,\n //mask,\n onClick,\n className: cls(\"unit\"),\n }),\n h.if(linked)(ClippableRect, {\n ...bounds,\n className: cls(\"linked-overlay\"),\n }),\n h.if(selected)(ClippableRect, {\n ...bounds,\n className: cls(\"selection-overlay\"),\n }),\n //defs,\n children,\n ],\n );\n}\n\nfunction LabeledUnit(props: LabeledUnitProps) {\n const {\n division,\n label,\n onLabelUpdated,\n widthFraction,\n showLabel = true,\n backgroundColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType, isTransitioning, hideLabelsWhileTransitioning } =\n useColumn();\n const bounds = {\n ...useUnitRect(division, { widthFraction, axisType }),\n ...baseBounds,\n };\n const { width, height } = bounds;\n // Labels stay visible through the animation by default. `hideLabelsWhileTransitioning`\n // is a perf escape hatch: when set, the `foreignObject` label (whose HTML\n // reflows on every size change) is skipped mid-transition and restored on settle.\n const skipLabel = isTransitioning && hideLabelsWhileTransitioning;\n return h(\n Unit,\n {\n className: \"labeled-unit\",\n division,\n backgroundColor,\n patternID,\n ...bounds,\n },\n [\n h.if(showLabel && !skipLabel)(\n ForeignObject,\n { ...bounds, className: \"unit-label-container\" },\n h(SizeAwareLabel, {\n className: \"unit-overlay\",\n labelClassName: \"unit-label\",\n style: { width, height },\n label,\n // Re-fit the label when a transition settles (isTransitioning flips),\n // not on every intermediate frame.\n remeasureKey: isTransitioning,\n onVisibilityChanged(viz) {\n onLabelUpdated(label, viz);\n },\n }),\n ),\n ],\n );\n}\n\nfunction UnitBoxes<T>(props: {\n unitComponent: React.FunctionComponent<{ division: T }>;\n unitComponentProps?: any;\n transformDivisions?(divisions: T[]): T[];\n transformDivision?: (\n division: any,\n index: number,\n divisions: any[],\n ) => T | null;\n}) {\n const { unitComponent = Unit, unitComponentProps = {} } = props;\n const { divisions } = useContext(ColumnContext);\n\n if (divisions.length == 0) {\n console.warn(\"No divisions found in column context\");\n return null;\n }\n\n const children = useMemo(() => {\n return divisions.map((division: any, i) => {\n // @ts-ignore\n return h(unitComponent, {\n division,\n key: division.unit_id,\n ...unitComponentProps,\n });\n });\n }, [divisions, unitComponent, unitComponentProps]);\n\n return h(\n PatternDefsProvider,\n { resolveID, scalePattern },\n h(\"g.divisions\", children),\n );\n}\n\nexport { LabeledUnit, Unit, UnitBoxes, UnitProps };\n"],"names":["hyper","styles","ColumnAxisType","useContext","ColumnContext","ColumnLayoutContext","getUnitHeightRange","useColumn","resolveID","useGeologicPattern","classNames","use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ent":["import {\n ColumnAxisType,\n ColumnContext,\n ColumnLayoutContext,\n ClippableRect,\n ForeignObject,\n PatternDefsProvider,\n useColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { SizeAwareLabel, Clickable } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport { ReactNode, useContext, useMemo } from \"react\";\nimport { useUnitSelectionTarget } from \"../data-provider\";\nimport { useLithologies } from \"@macrostrat/data-provider\";\nimport { IUnit } from \"./types\";\nimport styles from \"./boxes.module.sass\";\nimport classNames from \"classnames\";\nimport { getUnitHeightRange } from \"../prepare-units/utils\";\nimport type { RectBounds } from \"./types\";\nimport {\n getBestFGDCPatternForUnit,\n scalePattern,\n getMixedUnitColor,\n} from \"@macrostrat/stratigraphy-utils\";\n\nconst h = hyper.styled(styles);\n\n/** Resolve a class name through this file's CSS module exactly as the styled\n * `h` would (module-scoped classes are hashed; unknown/global classes pass\n * through). Needed because `ClippableRect` renders the element in\n * `@macrostrat/column-components`, so class resolution must happen here. */\nconst cls = (name: string): string => (styles as any)[name] ?? name;\n\ninterface UnitRectOptions {\n widthFraction?: number;\n axisType?: ColumnAxisType;\n // Padding to create overflow for zig-zags or other ornamented edges\n padding?: number;\n}\n\ninterface UnitProps extends Clickable, Partial<RectBounds>, UnitRectOptions {\n division: IUnit;\n resolveID?(IUnit): string;\n UUID?: string;\n defaultFill?: string;\n widthFraction?: number;\n children?: ReactNode;\n className?: string;\n fill?: string;\n backgroundColor?: string;\n patternColor?: string;\n patternID?: string | number;\n}\n\nexport interface LabeledUnitProps\n extends UnitRectOptions, Clickable, Partial<RectBounds> {\n division: IUnit;\n patternID?: string | number;\n label: string;\n onLabelUpdated?(label: string, shown: boolean);\n halfWidth?: boolean;\n showLabel?: boolean;\n backgroundColor?: string;\n}\n\nfunction useUnitRect(\n division: IUnit,\n options: UnitRectOptions = {},\n): RectBounds {\n const {\n widthFraction = 1,\n axisType = ColumnAxisType.AGE,\n padding = 0,\n } = options;\n const { scale } = useContext(ColumnContext);\n const { width } = useContext(ColumnLayoutContext);\n\n const [bottomHeight, topHeight] = getUnitHeightRange(division, axisType);\n\n const y = scale(topHeight);\n const height = Math.abs(scale(bottomHeight) - y);\n\n return {\n x: width * (1 - widthFraction) - padding,\n y: y - padding,\n height: height + padding * 2,\n width: widthFraction * width + padding * 2,\n };\n}\n\nexport function MinimalUnit(props) {\n const {\n division: d,\n children,\n className,\n widthFraction = 1,\n axisType: _, // not sure why this is brought in...\n nColumns: __,\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const lithMap = useLithologies();\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n };\n\n const backgroundColor = getMixedUnitColor(d, lithMap, null, false);\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n \"--column-stroke-color\": backgroundColor,\n },\n },\n [\n h(\"rect.unit.background\", {\n ref,\n ...bounds,\n fill: backgroundColor,\n fillOpacity: 0.8,\n stroke: backgroundColor,\n onClick,\n }),\n h.if(linked)(\"rect.linked-overlay\", bounds),\n h.if(selected)(\"rect.selection-overlay\", bounds),\n ],\n );\n}\n\nfunction Unit(props: UnitProps) {\n const {\n division: d,\n children,\n fill,\n defaultFill = \"transparent\",\n className,\n widthFraction = 1,\n backgroundColor,\n patternColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n\n const hasOverflowTop = d.t_clip_pos != null;\n const hasOverflowBottom = d.b_clip_pos != null;\n\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n overflowTop: hasOverflowTop,\n overflowBottom: hasOverflowBottom,\n };\n const _patternID = patternID ?? getBestFGDCPatternForUnit(d);\n let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);\n\n const hasBackgroundColor = backgroundColor != null;\n\n const _className = classNames(className, { colored: hasBackgroundColor });\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className: _className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n },\n },\n [\n h(ClippableRect, {\n ...bounds,\n fill: backgroundColor,\n onClick,\n className: cls(\"background\"),\n }),\n h(ClippableRect, {\n ref,\n ...bounds,\n fill: _fill,\n //mask,\n onClick,\n className: cls(\"unit\"),\n }),\n h.if(linked)(ClippableRect, {\n ...bounds,\n className: cls(\"linked-overlay\"),\n }),\n h.if(selected)(ClippableRect, {\n ...bounds,\n className: cls(\"selection-overlay\"),\n }),\n //defs,\n children,\n ],\n );\n}\n\nfunction LabeledUnit(props: LabeledUnitProps) {\n const {\n division,\n label,\n onLabelUpdated,\n widthFraction,\n showLabel = true,\n backgroundColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType, isTransitioning, hideLabelsWhileTransitioning } =\n useColumn();\n const bounds = {\n ...useUnitRect(division, { widthFraction, axisType }),\n ...baseBounds,\n };\n const { width, height } = bounds;\n // Labels stay visible through the animation by default. `hideLabelsWhileTransitioning`\n // is a perf escape hatch: when set, the `foreignObject` label (whose HTML\n // reflows on every size change) is skipped mid-transition and restored on settle.\n const skipLabel = isTransitioning && hideLabelsWhileTransitioning;\n return h(\n Unit,\n {\n className: \"labeled-unit\",\n division,\n backgroundColor,\n patternID,\n ...bounds,\n },\n [\n h.if(showLabel && !skipLabel)(\n ForeignObject,\n { ...bounds, className: \"unit-label-container\" },\n h(SizeAwareLabel, {\n className: \"unit-overlay\",\n labelClassName: \"unit-label\",\n style: { width, height },\n label,\n // Re-fit the label when a transition settles (isTransitioning flips),\n // not on every intermediate frame.\n remeasureKey: isTransitioning,\n onVisibilityChanged(viz) {\n onLabelUpdated(label, viz);\n },\n }),\n ),\n ],\n );\n}\n\nfunction UnitBoxes<T>(props: {\n unitComponent: React.FunctionComponent<{ division: T }>;\n unitComponentProps?: any;\n transformDivisions?(divisions: T[]): T[];\n transformDivision?: (\n division: any,\n index: number,\n divisions: any[],\n ) => T | null;\n}) {\n const { unitComponent = Unit, unitComponentProps = {} } = props;\n const { divisions } = useContext(ColumnContext);\n\n if (divisions.length == 0) {\n console.warn(\"No divisions found in column context\");\n return null;\n }\n\n const children = useMemo(() => {\n return divisions.map((division: any, i) => {\n // @ts-ignore\n return h(unitComponent, {\n division,\n key: division.unit_id,\n ...unitComponentProps,\n });\n });\n }, [divisions, unitComponent, unitComponentProps]);\n\n return h(\n PatternDefsProvider,\n { resolveID: getBestFGDCPatternForUnit, scalePattern },\n h(\"g.divisions\", children),\n );\n}\n\nexport { LabeledUnit, Unit, UnitBoxes, UnitProps };\n"],"names":["hyper","styles","ColumnAxisType","useContext","ColumnContext","ColumnLayoutContext","getUnitHeightRange","useColumn","getBestFGDCPatternForUnit","useGeologicPattern","classNames","useUnitSelectionTarget","ClippableRect","ForeignObject","SizeAwareLabel","useMemo","PatternDefsProvider","scalePattern"],"mappings":";;;;;;;;;;;;;;;AA0BA,MAAM,IAAIA,WAAAA,QAAM,OAAOC,oBAAM;AAM7B,MAAM,MAAM,CAAC,SAA0BA,qBAAe,IAAI,KAAK;AAkC/D,SAAS,YACP,UACA,UAA2B,IACf;AACZ,QAAM;AAAA,IACJ,gBAAgB;AAAA,IAChB,WAAWC,iBAAAA,eAAe;AAAA,IAC1B,UAAU;AAAA,EAAA,IACR;AACJ,QAAM,EAAE,MAAA,IAAUC,MAAAA,WAAWC,8BAAa;AAC1C,QAAM,EAAE,MAAA,IAAUD,MAAAA,WAAWE,oCAAmB;AAEhD,QAAM,CAAC,cAAc,SAAS,IAAIC,MAAAA,mBAAmB,UAAU,QAAQ;AAEvE,QAAM,IAAI,MAAM,SAAS;AACzB,QAAM,SAAS,KAAK,IAAI,MAAM,YAAY,IAAI,CAAC;AAE/C,SAAO;AAAA,IACL,GAAG,SAAS,IAAI,iBAAiB;AAAA,IACjC,GAAG,IAAI;AAAA,IACP,QAAQ,S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A,WAAWC,8BAAa;AAE9C,MAAI,UAAU,UAAU,GAAG;AACzB,YAAQ,KAAK,sCAAsC;AACnD,WAAO;AAAA,EACT;AAEA,QAAM,WAAWW,MAAAA,QAAQ,MAAM;AAC7B,WAAO,UAAU,IAAI,CAAC,UAAe,MAAM;AAEzC,aAAO,EAAE,eAAe;AAAA,QACtB;AAAA,QACA,KAAK,SAAS;AAAA,QACd,GAAG;AAAA,MAAA,CACJ;AAAA,IACH,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,eAAe,kBAAkB,CAAC;AAEjD,SAAO;AAAA,IACLC,iBAAAA;AAAAA,IACA,EAAE,WAAWR,kBAAAA,2BAAA,cAA2BS,+BAAA;AAAA,IACxC,EAAE,eAAe,QAAQ;AAAA,EAAA;AAE7B;;;;"}
|
package/dist/units/boxes.js
CHANGED
|
@@ -2,11 +2,11 @@ import { useColumn, ForeignObject, ColumnContext, PatternDefsProvider, ColumnAxi
|
|
|
2
2
|
import { SizeAwareLabel } from "@macrostrat/ui-components";
|
|
3
3
|
import h$1 from "@macrostrat/hyper";
|
|
4
4
|
import { useContext, useMemo } from "react";
|
|
5
|
-
import { scalePattern, resolveID } from "./resolvers.js";
|
|
6
5
|
import "@macrostrat/data-provider";
|
|
7
6
|
import h$2 from "./boxes.module.sass.js";
|
|
8
7
|
import classNames from "classnames";
|
|
9
8
|
import { getUnitHeightRange } from "../prepare-units/utils.js";
|
|
9
|
+
import { scalePattern, getBestFGDCPatternForUnit } from "@macrostrat/stratigraphy-utils";
|
|
10
10
|
import { useUnitSelectionTarget } from "../data-provider/unit-selection.js";
|
|
11
11
|
const h = h$1.styled(h$2);
|
|
12
12
|
const cls = (name) => h$2[name] ?? name;
|
|
@@ -52,7 +52,7 @@ function Unit(props) {
|
|
|
52
52
|
overflowTop: hasOverflowTop,
|
|
53
53
|
overflowBottom: hasOverflowBottom
|
|
54
54
|
};
|
|
55
|
-
const _patternID = patternID ??
|
|
55
|
+
const _patternID = patternID ?? getBestFGDCPatternForUnit(d);
|
|
56
56
|
let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);
|
|
57
57
|
const hasBackgroundColor = backgroundColor != null;
|
|
58
58
|
const _className = classNames(className, { colored: hasBackgroundColor });
|
|
@@ -160,7 +160,7 @@ function UnitBoxes(props) {
|
|
|
160
160
|
}, [divisions, unitComponent, unitComponentProps]);
|
|
161
161
|
return h(
|
|
162
162
|
PatternDefsProvider,
|
|
163
|
-
{ resolveID, scalePattern },
|
|
163
|
+
{ resolveID: getBestFGDCPatternForUnit, scalePattern },
|
|
164
164
|
h("g.divisions", children)
|
|
165
165
|
);
|
|
166
166
|
}
|
package/dist/units/boxes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boxes.js","sources":["../../src/units/boxes.ts"],"sourcesContent":["import {\n ColumnAxisType,\n ColumnContext,\n ColumnLayoutContext,\n ClippableRect,\n ForeignObject,\n PatternDefsProvider,\n useColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { SizeAwareLabel, Clickable } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport { ReactNode, useContext, useMemo } from \"react\";\nimport { resolveID, scalePattern } from \"./resolvers\";\nimport { useUnitSelectionTarget } from \"../data-provider\";\nimport { useLithologies } from \"@macrostrat/data-provider\";\nimport { IUnit } from \"./types\";\nimport styles from \"./boxes.module.sass\";\nimport classNames from \"classnames\";\nimport { getUnitHeightRange } from \"../prepare-units/utils\";\nimport { getMixedUnitColor } from \"./colors\";\nimport type { RectBounds } from \"./types\";\n\nconst h = hyper.styled(styles);\n\n/** Resolve a class name through this file's CSS module exactly as the styled\n * `h` would (module-scoped classes are hashed; unknown/global classes pass\n * through). Needed because `ClippableRect` renders the element in\n * `@macrostrat/column-components`, so class resolution must happen here. */\nconst cls = (name: string): string => (styles as any)[name] ?? name;\n\ninterface UnitRectOptions {\n widthFraction?: number;\n axisType?: ColumnAxisType;\n // Padding to create overflow for zig-zags or other ornamented edges\n padding?: number;\n}\n\ninterface UnitProps extends Clickable, Partial<RectBounds>, UnitRectOptions {\n division: IUnit;\n resolveID?(IUnit): string;\n UUID?: string;\n defaultFill?: string;\n widthFraction?: number;\n children?: ReactNode;\n className?: string;\n fill?: string;\n backgroundColor?: string;\n patternColor?: string;\n patternID?: string | number;\n}\n\nexport interface LabeledUnitProps\n extends UnitRectOptions, Clickable, Partial<RectBounds> {\n division: IUnit;\n patternID?: string | number;\n label: string;\n onLabelUpdated?(label: string, shown: boolean);\n halfWidth?: boolean;\n showLabel?: boolean;\n backgroundColor?: string;\n}\n\nfunction useUnitRect(\n division: IUnit,\n options: UnitRectOptions = {},\n): RectBounds {\n const {\n widthFraction = 1,\n axisType = ColumnAxisType.AGE,\n padding = 0,\n } = options;\n const { scale } = useContext(ColumnContext);\n const { width } = useContext(ColumnLayoutContext);\n\n const [bottomHeight, topHeight] = getUnitHeightRange(division, axisType);\n\n const y = scale(topHeight);\n const height = Math.abs(scale(bottomHeight) - y);\n\n return {\n x: width * (1 - widthFraction) - padding,\n y: y - padding,\n height: height + padding * 2,\n width: widthFraction * width + padding * 2,\n };\n}\n\nexport function MinimalUnit(props) {\n const {\n division: d,\n children,\n className,\n widthFraction = 1,\n axisType: _, // not sure why this is brought in...\n nColumns: __,\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const lithMap = useLithologies();\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n };\n\n const backgroundColor = getMixedUnitColor(d, lithMap, null, false);\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n \"--column-stroke-color\": backgroundColor,\n },\n },\n [\n h(\"rect.unit.background\", {\n ref,\n ...bounds,\n fill: backgroundColor,\n fillOpacity: 0.8,\n stroke: backgroundColor,\n onClick,\n }),\n h.if(linked)(\"rect.linked-overlay\", bounds),\n h.if(selected)(\"rect.selection-overlay\", bounds),\n ],\n );\n}\n\nfunction Unit(props: UnitProps) {\n const {\n division: d,\n children,\n fill,\n defaultFill = \"transparent\",\n className,\n widthFraction = 1,\n backgroundColor,\n patternColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n\n const hasOverflowTop = d.t_clip_pos != null;\n const hasOverflowBottom = d.b_clip_pos != null;\n\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n overflowTop: hasOverflowTop,\n overflowBottom: hasOverflowBottom,\n };\n const _patternID = patternID ?? resolveID(d);\n let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);\n\n const hasBackgroundColor = backgroundColor != null;\n\n const _className = classNames(className, { colored: hasBackgroundColor });\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className: _className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n },\n },\n [\n h(ClippableRect, {\n ...bounds,\n fill: backgroundColor,\n onClick,\n className: cls(\"background\"),\n }),\n h(ClippableRect, {\n ref,\n ...bounds,\n fill: _fill,\n //mask,\n onClick,\n className: cls(\"unit\"),\n }),\n h.if(linked)(ClippableRect, {\n ...bounds,\n className: cls(\"linked-overlay\"),\n }),\n h.if(selected)(ClippableRect, {\n ...bounds,\n className: cls(\"selection-overlay\"),\n }),\n //defs,\n children,\n ],\n );\n}\n\nfunction LabeledUnit(props: LabeledUnitProps) {\n const {\n division,\n label,\n onLabelUpdated,\n widthFraction,\n showLabel = true,\n backgroundColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType, isTransitioning, hideLabelsWhileTransitioning } =\n useColumn();\n const bounds = {\n ...useUnitRect(division, { widthFraction, axisType }),\n ...baseBounds,\n };\n const { width, height } = bounds;\n // Labels stay visible through the animation by default. `hideLabelsWhileTransitioning`\n // is a perf escape hatch: when set, the `foreignObject` label (whose HTML\n // reflows on every size change) is skipped mid-transition and restored on settle.\n const skipLabel = isTransitioning && hideLabelsWhileTransitioning;\n return h(\n Unit,\n {\n className: \"labeled-unit\",\n division,\n backgroundColor,\n patternID,\n ...bounds,\n },\n [\n h.if(showLabel && !skipLabel)(\n ForeignObject,\n { ...bounds, className: \"unit-label-container\" },\n h(SizeAwareLabel, {\n className: \"unit-overlay\",\n labelClassName: \"unit-label\",\n style: { width, height },\n label,\n // Re-fit the label when a transition settles (isTransitioning flips),\n // not on every intermediate frame.\n remeasureKey: isTransitioning,\n onVisibilityChanged(viz) {\n onLabelUpdated(label, viz);\n },\n }),\n ),\n ],\n );\n}\n\nfunction UnitBoxes<T>(props: {\n unitComponent: React.FunctionComponent<{ division: T }>;\n unitComponentProps?: any;\n transformDivisions?(divisions: T[]): T[];\n transformDivision?: (\n division: any,\n index: number,\n divisions: any[],\n ) => T | null;\n}) {\n const { unitComponent = Unit, unitComponentProps = {} } = props;\n const { divisions } = useContext(ColumnContext);\n\n if (divisions.length == 0) {\n console.warn(\"No divisions found in column context\");\n return null;\n }\n\n const children = useMemo(() => {\n return divisions.map((division: any, i) => {\n // @ts-ignore\n return h(unitComponent, {\n division,\n key: division.unit_id,\n ...unitComponentProps,\n });\n });\n }, [divisions, unitComponent, unitComponentProps]);\n\n return h(\n PatternDefsProvider,\n { resolveID, scalePattern },\n h(\"g.divisions\", children),\n );\n}\n\nexport { LabeledUnit, Unit, UnitBoxes, UnitProps };\n"],"names":["hyper","styles"],"mappings":";;;;;;;;;;AAuBA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAM7B,MAAM,MAAM,CAAC,SAA0BA,IAAe,IAAI,KAAK;AAkC/D,SAAS,YACP,UACA,UAA2B,IACf;AACZ,QAAM;AAAA,IACJ,gBAAgB;AAAA,IAChB,WAAW,eAAe;AAAA,IAC1B,UAAU;AAAA,EAAA,IACR;AACJ,QAAM,EAAE,MAAA,IAAU,WAAW,aAAa;AAC1C,QAAM,EAAE,MAAA,IAAU,WAAW,mBAAmB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AAAA,MAAA;AAAA,IACH;AAAA,EACF;AAEJ;AAEA,SAAS,UAAa,OASnB;AACD,QAAM,EAAE,gBAAgB,MAAM,qBAAqB,CAAA,MAAO;AAC1D,QAAM,EAAE,UAAA,IAAc,WAAW,aAAa;AAE9C,MAAI,UAAU,UAAU,GAAG;AACzB,YAAQ,KAAK,sCAAsC;AACnD,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,QAAQ,MAAM;AAC7B,WAAO,UAAU,IAAI,CAAC,UAAe,MAAM;AAEzC,aAAO,EAAE,eAAe;AAAA,QACtB;AAAA,QACA,KAAK,SAAS;AAAA,QACd,GAAG;AAAA,MAAA,CACJ;AAAA,IACH,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,eAAe,kBAAkB,CAAC;AAEjD,SAAO;AAAA,IACL;AAAA,IACA,EAAE,WAAW,aAAA;AAAA,IACb,EAAE,eAAe,QAAQ;AAAA,EAAA;AAE7B;"}
|
|
1
|
+
{"version":3,"file":"boxes.js","sources":["../../src/units/boxes.ts"],"sourcesContent":["import {\n ColumnAxisType,\n ColumnContext,\n ColumnLayoutContext,\n ClippableRect,\n ForeignObject,\n PatternDefsProvider,\n useColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { SizeAwareLabel, Clickable } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport { ReactNode, useContext, useMemo } from \"react\";\nimport { useUnitSelectionTarget } from \"../data-provider\";\nimport { useLithologies } from \"@macrostrat/data-provider\";\nimport { IUnit } from \"./types\";\nimport styles from \"./boxes.module.sass\";\nimport classNames from \"classnames\";\nimport { getUnitHeightRange } from \"../prepare-units/utils\";\nimport type { RectBounds } from \"./types\";\nimport {\n getBestFGDCPatternForUnit,\n scalePattern,\n getMixedUnitColor,\n} from \"@macrostrat/stratigraphy-utils\";\n\nconst h = hyper.styled(styles);\n\n/** Resolve a class name through this file's CSS module exactly as the styled\n * `h` would (module-scoped classes are hashed; unknown/global classes pass\n * through). Needed because `ClippableRect` renders the element in\n * `@macrostrat/column-components`, so class resolution must happen here. */\nconst cls = (name: string): string => (styles as any)[name] ?? name;\n\ninterface UnitRectOptions {\n widthFraction?: number;\n axisType?: ColumnAxisType;\n // Padding to create overflow for zig-zags or other ornamented edges\n padding?: number;\n}\n\ninterface UnitProps extends Clickable, Partial<RectBounds>, UnitRectOptions {\n division: IUnit;\n resolveID?(IUnit): string;\n UUID?: string;\n defaultFill?: string;\n widthFraction?: number;\n children?: ReactNode;\n className?: string;\n fill?: string;\n backgroundColor?: string;\n patternColor?: string;\n patternID?: string | number;\n}\n\nexport interface LabeledUnitProps\n extends UnitRectOptions, Clickable, Partial<RectBounds> {\n division: IUnit;\n patternID?: string | number;\n label: string;\n onLabelUpdated?(label: string, shown: boolean);\n halfWidth?: boolean;\n showLabel?: boolean;\n backgroundColor?: string;\n}\n\nfunction useUnitRect(\n division: IUnit,\n options: UnitRectOptions = {},\n): RectBounds {\n const {\n widthFraction = 1,\n axisType = ColumnAxisType.AGE,\n padding = 0,\n } = options;\n const { scale } = useContext(ColumnContext);\n const { width } = useContext(ColumnLayoutContext);\n\n const [bottomHeight, topHeight] = getUnitHeightRange(division, axisType);\n\n const y = scale(topHeight);\n const height = Math.abs(scale(bottomHeight) - y);\n\n return {\n x: width * (1 - widthFraction) - padding,\n y: y - padding,\n height: height + padding * 2,\n width: widthFraction * width + padding * 2,\n };\n}\n\nexport function MinimalUnit(props) {\n const {\n division: d,\n children,\n className,\n widthFraction = 1,\n axisType: _, // not sure why this is brought in...\n nColumns: __,\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const lithMap = useLithologies();\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n };\n\n const backgroundColor = getMixedUnitColor(d, lithMap, null, false);\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n \"--column-stroke-color\": backgroundColor,\n },\n },\n [\n h(\"rect.unit.background\", {\n ref,\n ...bounds,\n fill: backgroundColor,\n fillOpacity: 0.8,\n stroke: backgroundColor,\n onClick,\n }),\n h.if(linked)(\"rect.linked-overlay\", bounds),\n h.if(selected)(\"rect.selection-overlay\", bounds),\n ],\n );\n}\n\nfunction Unit(props: UnitProps) {\n const {\n division: d,\n children,\n fill,\n defaultFill = \"transparent\",\n className,\n widthFraction = 1,\n backgroundColor,\n patternColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n\n const hasOverflowTop = d.t_clip_pos != null;\n const hasOverflowBottom = d.b_clip_pos != null;\n\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n overflowTop: hasOverflowTop,\n overflowBottom: hasOverflowBottom,\n };\n const _patternID = patternID ?? getBestFGDCPatternForUnit(d);\n let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);\n\n const hasBackgroundColor = backgroundColor != null;\n\n const _className = classNames(className, { colored: hasBackgroundColor });\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className: _className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n },\n },\n [\n h(ClippableRect, {\n ...bounds,\n fill: backgroundColor,\n onClick,\n className: cls(\"background\"),\n }),\n h(ClippableRect, {\n ref,\n ...bounds,\n fill: _fill,\n //mask,\n onClick,\n className: cls(\"unit\"),\n }),\n h.if(linked)(ClippableRect, {\n ...bounds,\n className: cls(\"linked-overlay\"),\n }),\n h.if(selected)(ClippableRect, {\n ...bounds,\n className: cls(\"selection-overlay\"),\n }),\n //defs,\n children,\n ],\n );\n}\n\nfunction LabeledUnit(props: LabeledUnitProps) {\n const {\n division,\n label,\n onLabelUpdated,\n widthFraction,\n showLabel = true,\n backgroundColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType, isTransitioning, hideLabelsWhileTransitioning } =\n useColumn();\n const bounds = {\n ...useUnitRect(division, { widthFraction, axisType }),\n ...baseBounds,\n };\n const { width, height } = bounds;\n // Labels stay visible through the animation by default. `hideLabelsWhileTransitioning`\n // is a perf escape hatch: when set, the `foreignObject` label (whose HTML\n // reflows on every size change) is skipped mid-transition and restored on settle.\n const skipLabel = isTransitioning && hideLabelsWhileTransitioning;\n return h(\n Unit,\n {\n className: \"labeled-unit\",\n division,\n backgroundColor,\n patternID,\n ...bounds,\n },\n [\n h.if(showLabel && !skipLabel)(\n ForeignObject,\n { ...bounds, className: \"unit-label-container\" },\n h(SizeAwareLabel, {\n className: \"unit-overlay\",\n labelClassName: \"unit-label\",\n style: { width, height },\n label,\n // Re-fit the label when a transition settles (isTransitioning flips),\n // not on every intermediate frame.\n remeasureKey: isTransitioning,\n onVisibilityChanged(viz) {\n onLabelUpdated(label, viz);\n },\n }),\n ),\n ],\n );\n}\n\nfunction UnitBoxes<T>(props: {\n unitComponent: React.FunctionComponent<{ division: T }>;\n unitComponentProps?: any;\n transformDivisions?(divisions: T[]): T[];\n transformDivision?: (\n division: any,\n index: number,\n divisions: any[],\n ) => T | null;\n}) {\n const { unitComponent = Unit, unitComponentProps = {} } = props;\n const { divisions } = useContext(ColumnContext);\n\n if (divisions.length == 0) {\n console.warn(\"No divisions found in column context\");\n return null;\n }\n\n const children = useMemo(() => {\n return divisions.map((division: any, i) => {\n // @ts-ignore\n return h(unitComponent, {\n division,\n key: division.unit_id,\n ...unitComponentProps,\n });\n });\n }, [divisions, unitComponent, unitComponentProps]);\n\n return h(\n PatternDefsProvider,\n { resolveID: getBestFGDCPatternForUnit, scalePattern },\n h(\"g.divisions\", children),\n );\n}\n\nexport { LabeledUnit, Unit, UnitBoxes, UnitProps };\n"],"names":["hyper","styles"],"mappings":";;;;;;;;;;AA0BA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAM7B,MAAM,MAAM,CAAC,SAA0BA,IAAe,IAAI,KAAK;AAkC/D,SAAS,YACP,UACA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AAA,UAChB,WAAW;AAAA,UACX,gBAAgB;AAAA,UAChB,OAAO,EAAE,OAAO,OAAA;AAAA,UAChB;AAAA;AAAA;AAAA,UAGA,cAAc;AAAA,UACd,oBAAoB,KAAK;AACvB,2BAAe,OAAO,GAAG;AAAA,UAC3B;AAAA,QAAA,CACD;AAAA,MAAA;AAAA,IACH;AAAA,EACF;AAEJ;AAEA,SAAS,UAAa,OASnB;AACD,QAAM,EAAE,gBAAgB,MAAM,qBAAqB,CAAA,MAAO;AAC1D,QAAM,EAAE,UAAA,IAAc,WAAW,aAAa;AAE9C,MAAI,UAAU,UAAU,GAAG;AACzB,YAAQ,KAAK,sCAAsC;AACnD,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,QAAQ,MAAM;AAC7B,WAAO,UAAU,IAAI,CAAC,UAAe,MAAM;AAEzC,aAAO,EAAE,eAAe;AAAA,QACtB;AAAA,QACA,KAAK,SAAS;AAAA,QACd,GAAG;AAAA,MAAA,CACJ;AAAA,IACH,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,eAAe,kBAAkB,CAAC;AAEjD,SAAO;AAAA,IACL;AAAA,IACA,EAAE,WAAW,2BAA2B,aAAA;AAAA,IACxC,EAAE,eAAe,QAAQ;AAAA,EAAA;AAE7B;"}
|
package/dist/units/index.cjs
CHANGED
|
@@ -5,11 +5,10 @@ const columnComponents = require("@macrostrat/column-components");
|
|
|
5
5
|
const names = require("./names.cjs");
|
|
6
6
|
const boxes = require("./boxes.cjs");
|
|
7
7
|
const uiComponents = require("@macrostrat/ui-components");
|
|
8
|
-
const
|
|
8
|
+
const stratigraphyUtils = require("@macrostrat/stratigraphy-utils");
|
|
9
9
|
const composite = require("./composite.cjs");
|
|
10
10
|
const dataProvider = require("@macrostrat/data-provider");
|
|
11
11
|
const React = require("react");
|
|
12
|
-
const resolvers = require("./resolvers.cjs");
|
|
13
12
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
14
13
|
const h__default = /* @__PURE__ */ _interopDefault(h);
|
|
15
14
|
function UnitsColumn({ width = 100 }) {
|
|
@@ -51,7 +50,7 @@ function UnitComponent({
|
|
|
51
50
|
let reducedWidth = _nColumns;
|
|
52
51
|
if ("layout" in division) {
|
|
53
52
|
const layout = division.layout;
|
|
54
|
-
_nColumns =
|
|
53
|
+
_nColumns = layout.totalColumns;
|
|
55
54
|
columnIx = layout.column;
|
|
56
55
|
reducedWidth = width / layout.totalColumns / layout.nColumns;
|
|
57
56
|
x = columnIx * width / _nColumns;
|
|
@@ -69,13 +68,13 @@ function useUnitColor(unit, opts = {}) {
|
|
|
69
68
|
const { asBackground = true } = opts;
|
|
70
69
|
return React.useMemo(() => {
|
|
71
70
|
if (unit == null || lithMap == null) return null;
|
|
72
|
-
return
|
|
71
|
+
return stratigraphyUtils.getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);
|
|
73
72
|
}, [unit?.unit_id, lithMap, inDarkMode, asBackground]);
|
|
74
73
|
}
|
|
75
74
|
function ColoredUnitComponent(props) {
|
|
76
75
|
const backgroundColor = useUnitColor(props.division);
|
|
77
76
|
const patternID = React.useMemo(() => {
|
|
78
|
-
return
|
|
77
|
+
return stratigraphyUtils.getBestFGDCPatternForUnit(props.division);
|
|
79
78
|
}, [props.division?.unit_id]);
|
|
80
79
|
const fill = columnComponents.useGeologicPattern(patternID);
|
|
81
80
|
return h__default.default(UnitComponent, {
|
|
@@ -91,20 +90,20 @@ function useUnitColorByEnvironment(unit, opts = {}) {
|
|
|
91
90
|
const { asBackground = true } = opts;
|
|
92
91
|
return React.useMemo(() => {
|
|
93
92
|
if (unit == null || environmentMap == null) return null;
|
|
94
|
-
let c =
|
|
93
|
+
let c = stratigraphyUtils.getMixedUnitColor(unit, environmentMap, inDarkMode, asBackground, {
|
|
95
94
|
key: "environ",
|
|
96
95
|
id_key: "environ_id"
|
|
97
96
|
});
|
|
98
97
|
if (c != null) {
|
|
99
98
|
return c;
|
|
100
99
|
}
|
|
101
|
-
return
|
|
100
|
+
return stratigraphyUtils.getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);
|
|
102
101
|
}, [unit?.unit_id, environmentMap, lithMap, inDarkMode, asBackground]);
|
|
103
102
|
}
|
|
104
103
|
function EnvironmentColoredUnitComponent(props) {
|
|
105
104
|
const backgroundColor = useUnitColorByEnvironment(props.division);
|
|
106
105
|
const patternID = React.useMemo(() => {
|
|
107
|
-
return
|
|
106
|
+
return stratigraphyUtils.getBestFGDCPatternForUnit(props.division);
|
|
108
107
|
}, [props.division?.unit_id]);
|
|
109
108
|
const fill = columnComponents.useGeologicPattern(patternID);
|
|
110
109
|
return h__default.default(UnitComponent, {
|
|
@@ -113,9 +112,6 @@ function EnvironmentColoredUnitComponent(props) {
|
|
|
113
112
|
...props
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
|
-
exports.flattenLithologies = colors.flattenLithologies;
|
|
117
|
-
exports.getMixedColorForData = colors.getMixedColorForData;
|
|
118
|
-
exports.getMixedUnitColor = colors.getMixedUnitColor;
|
|
119
115
|
exports.AnnotatedUnitsColumn = composite.AnnotatedUnitsColumn;
|
|
120
116
|
exports.ColumnNotesProvider = composite.ColumnNotesProvider;
|
|
121
117
|
exports.CompositeUnitComponent = composite.CompositeUnitComponent;
|
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":";;;;;;;;;;;;;AAuBO,SAAS,YAAY,EAAE,QAAQ,OAAO;AAI3C,SAAOA,WAAAA,QAAEC,iBAAAA,iBAAiB,EAAE,SAASD,WAAAA,QAAEE,MAAAA,SAAS,CAAC;AACnD;AAEO,SAAS,kBAAkB,OAA4B;AAK5D,QAAM,EAAE,aAAa,OAAO,cAAc,GAAG,cAAc,OAAO;AAElE,SAAOF,mBAAE;AAAA,IACPA,WAAAA,QAAE,aAAa;AAAA,MACb,OAAO;AAAA,IAAA,CACR;AAAA,IACDA,WAAAA,QAAEG,MAAAA,iBAAiB;AAAA,MACjB,WAAW,aAAa,cAAc,WAAW;AAAA,MACjD,aAAa;AAAA,MACb,OAAO,QAAQ,cAAc;AAAA,IAAA,CAC9B;AAAA,EAAA,CACF;AACH;AAEO,SAAS,mBAAmB,EAAE,UAAU,GAAG,QAAQ;AAGxD,SAAOH,WAAAA,QAAE,eAAe;AAAA,IACtB;AAAA,IACA,GAAG;AAAA,IACH,iBAAiB,SAAS;AAAA,IAC1B,WAAW,SAAS;AAAA,EAAA,CACrB;AACH;AAQO,SAAS,cAAkC;AAAA,EAChD;AAAA,EACA,WAAW;AAAA,EACX,GAAG;AACL,GAA0B;AACxB,QAAM,QAAQ,KAAK,SAASI,iBAAAA,gBAAA,GAAmB;AAE/C,MAAI,YAAY;AAChB,MAAI,MAAM,SAAS,GAAG;AACpB,gBAAY;AAAA,EACd;AACA,MAAI,WAAW;AACf,MAAI,IAAI;AAER,MAAI,eAAe;AACnB,MAAI,YAAY,UAAU;AACxB,UAAM,SAAS,SAAS;AACxB,gBAAY,OAAO;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K;AAAA,MACL,QAAQ;AAAA,IAAA,CACT;AACD,QAAI,KAAK,MAAM;AACb,aAAO;AAAA,IACT;AAEA,WAAOA,kBAAAA,kBAAkB,MAAM,SAAS,YAAY,YAAY;AAAA,EAClE,GAAG,CAAC,MAAM,SAAS,gBAAgB,SAAS,YAAY,YAAY,CAAC;AACvE;AAEO,SAAS,gCAAgC,OAAO;AAGrD,QAAM,kBAAkB,0BAA0B,MAAM,QAAQ;AAEhE,QAAM,YAAYD,MAAAA,QAAQ,MAAM;AAC9B,WAAOE,kBAAAA,0BAA0B,MAAM,QAAQ;AAAA,EACjD,GAAG,CAAC,MAAM,UAAU,OAAO,CAAC;AAE5B,QAAM,OAAOC,iBAAAA,mBAAmB,SAAS;AAEzC,SAAOX,WAAAA,QAAE,eAAe;AAAA,IACtB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,CACJ;AACH;;;;;;;;;;;;;;;;"}
|
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>;
|