@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/index.js
CHANGED
|
@@ -5,26 +5,20 @@ 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";
|
|
10
|
+
import { AgeWindowTag, intervalShortFromTimescale } from "./unit-details/age-window-tag.js";
|
|
9
11
|
import { AnnotatedUnitsColumn, ColumnNotesProvider, CompositeUnitComponent, CompositeUnitsColumn, LabelTrackerProvider, SectionLabelsColumn, TrackedLabeledUnit } from "./units/composite.js";
|
|
10
|
-
import { BaseColumnsLayer, SelectedColumnOverlay, buildColumnsStyle } from "./maps/layers/columns.js";
|
|
11
12
|
import { BaseMeasurementsColumn, TruncatedList, groupNotesByPixelDistance, mergeHeightRanges, standardizeMeasurementHeight } from "./facets/measurements/base.js";
|
|
12
13
|
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
14
|
import { ColumnNavProvider, useColumnNav } from "./data-provider/column-nav.js";
|
|
18
|
-
import { ColumnNavigationSVGMap, ResizableMapFrame } from "./maps/column-navigation/svg/index.js";
|
|
19
15
|
import { CorrelationChart } from "./correlation-chart/main.js";
|
|
20
16
|
import { DetritalColumn, DetritalGroup } from "./facets/detrital-zircon/index.js";
|
|
21
17
|
import { FossilDataType, useFossilData } from "./facets/fossils/provider.js";
|
|
22
18
|
import { HeightMethod, HybridScaleType } from "./prepare-units/types.js";
|
|
23
|
-
import { InsetMap } from "./maps/inset-map/index.js";
|
|
24
19
|
import { IsotopesColumn, IsotopesDataset } from "./facets/carbon-isotopes/isotopes-column.js";
|
|
25
20
|
import { LegendPanelHeader, ReferencesField, ThicknessField, UnitDetailsFeature, UnitDetailsPanel } from "./unit-details/panel.js";
|
|
26
21
|
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
22
|
import { MeasurementDataContext, MeasurementDataProvider, useMeasurementData } from "./facets/carbon-isotopes/data-provider.js";
|
|
29
23
|
import { MergeSectionsMode, agesOverlap, createUnitSorter, ensureArray, ensureRealFloat, getPositionWithinUnit, getUnitHeightRange, unitsOverlap } from "./prepare-units/utils.js";
|
|
30
24
|
import { PBDBFossilsColumn } from "./facets/fossils/index.js";
|
|
@@ -34,7 +28,6 @@ import { StratNameField } from "./unit-details/strat-names.js";
|
|
|
34
28
|
import { UnitDetailsPanelWithNavigation } from "./unit-details/modal-panel.js";
|
|
35
29
|
import { UnitDetailsPopover, UnitSelectionPopover } from "./unit-details/popover.js";
|
|
36
30
|
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
31
|
import { parseLineFromString, stringifyLine } from "./correlation-chart/hash-string.js";
|
|
39
32
|
import { preprocessUnits } from "./prepare-units/helpers.js";
|
|
40
33
|
export {
|
|
@@ -42,9 +35,9 @@ export {
|
|
|
42
35
|
AgeField,
|
|
43
36
|
AgeLabel,
|
|
44
37
|
AgeRange,
|
|
38
|
+
AgeWindowTag,
|
|
45
39
|
AnnotatedUnitsColumn,
|
|
46
40
|
ApproximateHeightAxis,
|
|
47
|
-
BaseColumnsLayer,
|
|
48
41
|
BaseMeasurementsColumn,
|
|
49
42
|
BasicUnitComponent,
|
|
50
43
|
BoundaryAgeModelOverlay,
|
|
@@ -52,28 +45,16 @@ export {
|
|
|
52
45
|
ColoredUnitComponent,
|
|
53
46
|
Column,
|
|
54
47
|
ColumnBasicInfo,
|
|
55
|
-
ColumnCenters,
|
|
56
48
|
ColumnContainer,
|
|
57
|
-
ColumnCorrelationMap,
|
|
58
|
-
ColumnCorrelationProvider,
|
|
59
|
-
ColumnFeatures,
|
|
60
|
-
ColumnHoverInteraction,
|
|
61
|
-
ColumnKeyboardNavigation,
|
|
62
49
|
ColumnNavProvider,
|
|
63
|
-
ColumnNavigationMap,
|
|
64
|
-
ColumnNavigationSVGMap,
|
|
65
50
|
ColumnNotes,
|
|
66
51
|
ColumnNotesProvider,
|
|
67
|
-
ColumnSelectionManager,
|
|
68
|
-
Columns,
|
|
69
|
-
ColumnsNavigationLayer,
|
|
70
52
|
CompositeAgeAxis,
|
|
71
53
|
CompositeAgeAxisCore,
|
|
72
54
|
CompositeUnitComponent,
|
|
73
55
|
CompositeUnitsColumn,
|
|
74
56
|
ComputedSurfacesOverlay,
|
|
75
57
|
CorrelationChart,
|
|
76
|
-
CurrentColumn,
|
|
77
58
|
DetritalColumn,
|
|
78
59
|
DetritalGroup,
|
|
79
60
|
Duration,
|
|
@@ -82,7 +63,6 @@ export {
|
|
|
82
63
|
HeightMethod,
|
|
83
64
|
HybridScaleType,
|
|
84
65
|
Identifier,
|
|
85
|
-
InsetMap,
|
|
86
66
|
IntervalProportions,
|
|
87
67
|
IsotopesColumn,
|
|
88
68
|
IsotopesDataset,
|
|
@@ -92,18 +72,14 @@ export {
|
|
|
92
72
|
MacrostratColumnDataProvider,
|
|
93
73
|
MacrostratColumnProvider,
|
|
94
74
|
MacrostratColumnStateProvider,
|
|
95
|
-
MacrostratUnitsOverlay,
|
|
96
75
|
MeasurementDataContext,
|
|
97
76
|
MeasurementDataProvider,
|
|
98
|
-
MeasurementsLayer,
|
|
99
77
|
MergeSectionsMode,
|
|
100
78
|
PBDBFossilsColumn,
|
|
101
79
|
PBDBOccurrencesMatrix,
|
|
102
80
|
ReferencesField,
|
|
103
|
-
ResizableMapFrame,
|
|
104
81
|
SGPMeasurementsColumn,
|
|
105
82
|
SectionLabelsColumn,
|
|
106
|
-
SelectedColumnOverlay,
|
|
107
83
|
SimpleUnitsColumn,
|
|
108
84
|
StratNameField,
|
|
109
85
|
ThicknessField,
|
|
@@ -123,21 +99,17 @@ export {
|
|
|
123
99
|
VerticalAxisLabel,
|
|
124
100
|
agesOverlap,
|
|
125
101
|
allowUnitSelectionAtom,
|
|
126
|
-
buildColumnsStyle,
|
|
127
|
-
buildUnitsStyle,
|
|
128
102
|
columnUnitsAtom,
|
|
129
103
|
columnUnitsMapAtom,
|
|
130
104
|
createUnitSorter,
|
|
131
105
|
ensureArray,
|
|
132
106
|
ensureRealFloat,
|
|
133
|
-
flattenLithologies,
|
|
134
107
|
getAge,
|
|
135
108
|
getAgeRange,
|
|
136
|
-
getMixedColorForData,
|
|
137
|
-
getMixedUnitColor,
|
|
138
109
|
getPositionWithinUnit,
|
|
139
110
|
getUnitHeightRange,
|
|
140
111
|
groupNotesByPixelDistance,
|
|
112
|
+
intervalShortFromTimescale,
|
|
141
113
|
mergeHeightRanges,
|
|
142
114
|
parseLineFromString,
|
|
143
115
|
prepareColumnUnits,
|
|
@@ -150,12 +122,10 @@ export {
|
|
|
150
122
|
unitsOverlap,
|
|
151
123
|
useAnimatedAgeWindow,
|
|
152
124
|
useAtomOverlayPosition,
|
|
153
|
-
useColumnMapLink,
|
|
154
125
|
useColumnNav,
|
|
155
126
|
useColumnRef,
|
|
156
127
|
useColumnUnitsMap,
|
|
157
128
|
useCompositeScale,
|
|
158
|
-
useCorrelationMapStore,
|
|
159
129
|
useFossilData,
|
|
160
130
|
useMacrostratColumnData,
|
|
161
131
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const core = require("@blueprintjs/core");
|
|
4
|
+
const dataComponents = require("@macrostrat/data-components");
|
|
5
|
+
const classNames = require("classnames");
|
|
6
|
+
const ageWindowTag_module = require("./age-window-tag.module.sass.cjs");
|
|
7
|
+
const ageRange = require("./age-range.cjs");
|
|
8
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
|
+
const classNames__default = /* @__PURE__ */ _interopDefault(classNames);
|
|
10
|
+
function intervalShortFromTimescale(interval) {
|
|
11
|
+
return {
|
|
12
|
+
id: interval.int_id ?? interval.oid,
|
|
13
|
+
name: interval.nam,
|
|
14
|
+
color: interval.col,
|
|
15
|
+
b_age: interval.eag,
|
|
16
|
+
t_age: interval.lag,
|
|
17
|
+
rank: interval.lvl
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function AgeWindowTag(props) {
|
|
21
|
+
const {
|
|
22
|
+
interval = null,
|
|
23
|
+
window = null,
|
|
24
|
+
onClear,
|
|
25
|
+
size = dataComponents.TagSize.Small,
|
|
26
|
+
className
|
|
27
|
+
} = props;
|
|
28
|
+
if (interval == null && window == null) return null;
|
|
29
|
+
let tag = null;
|
|
30
|
+
if (interval == null) {
|
|
31
|
+
tag = ageWindowTag_module(dataComponents.Tag, { size, name: ageWindowTag_module(ageRange.AgeRange, { data: window }) });
|
|
32
|
+
} else if (window == null || windowMatchesInterval(window, interval)) {
|
|
33
|
+
tag = ageWindowTag_module(dataComponents.IntervalTag, { interval, showAgeRange: true, size });
|
|
34
|
+
} else {
|
|
35
|
+
tag = ageWindowTag_module(RefinedIntervalTag, { interval, window, size });
|
|
36
|
+
}
|
|
37
|
+
return ageWindowTag_module("span.age-window-tag", { className: classNames__default.default(className) }, [
|
|
38
|
+
tag,
|
|
39
|
+
ageWindowTag_module.if(onClear != null)(core.Button, {
|
|
40
|
+
className: "clear-button",
|
|
41
|
+
icon: "cross",
|
|
42
|
+
minimal: true,
|
|
43
|
+
small: true,
|
|
44
|
+
title: "Clear",
|
|
45
|
+
onClick: onClear
|
|
46
|
+
})
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
function RefinedIntervalTag({
|
|
50
|
+
interval,
|
|
51
|
+
window,
|
|
52
|
+
size
|
|
53
|
+
}) {
|
|
54
|
+
const interaction = dataComponents.useInteractionProps({ int_id: interval.id });
|
|
55
|
+
return ageWindowTag_module(dataComponents.Tag, {
|
|
56
|
+
...interaction,
|
|
57
|
+
size,
|
|
58
|
+
name: interval.name,
|
|
59
|
+
color: interval.color,
|
|
60
|
+
details: ageWindowTag_module(ageRange.AgeRange, { data: window })
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function windowMatchesInterval(window, interval) {
|
|
64
|
+
return window.t_age === interval.t_age && window.b_age === interval.b_age;
|
|
65
|
+
}
|
|
66
|
+
exports.AgeWindowTag = AgeWindowTag;
|
|
67
|
+
exports.intervalShortFromTimescale = intervalShortFromTimescale;
|
|
68
|
+
//# sourceMappingURL=age-window-tag.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"age-window-tag.cjs","sources":["../../src/unit-details/age-window-tag.ts"],"sourcesContent":["import { Button } from \"@blueprintjs/core\";\nimport {\n IntervalShort,\n IntervalTag,\n Tag,\n TagSize,\n useInteractionProps,\n} from \"@macrostrat/data-components\";\nimport type { Interval } from \"@macrostrat/timescale\";\nimport classNames from \"classnames\";\nimport h from \"./age-window-tag.module.sass\";\nimport { AgeRange } from \"./age-range\";\nimport type { AgeWindow } from \"../animated-age-window\";\n\n/** Adapt a timescale `Interval` (as delivered by a `Timescale` click, with\n * `eag`/`lag`/`nam`/`col`) to the `IntervalShort` shape the tag components\n * take. The id prefers the Macrostrat `int_id` when the interval tree was built\n * from the API, falling back to the interval's own `oid`. */\nexport function intervalShortFromTimescale(interval: Interval): IntervalShort {\n return {\n id: interval.int_id ?? interval.oid,\n name: interval.nam,\n color: interval.col,\n b_age: interval.eag,\n t_age: interval.lag,\n rank: interval.lvl,\n };\n}\n\nexport interface AgeWindowTagProps {\n /** The interval the window was set from, if any. */\n interval?: IntervalShort | null;\n /** The rendered window. When it differs from the interval's own span (a\n * refined window) it is shown in place of the interval's range. */\n window?: AgeWindow | null;\n /** Renders a clear button when given. */\n onClear?: () => void;\n size?: TagSize;\n className?: string;\n}\n\n/** A compact, clearable indicator of the age window a column or correlation\n * chart is focused on — an interval tag (linking to the interval, with its\n * range) or a bare age range. Renders nothing without an interval or window,\n * so it can live permanently in a chart's `axisTopContent`. */\nexport function AgeWindowTag(props: AgeWindowTagProps) {\n const {\n interval = null,\n window = null,\n onClear,\n size = TagSize.Small,\n className,\n } = props;\n if (interval == null && window == null) return null;\n\n let tag = null;\n if (interval == null) {\n tag = h(Tag, { size, name: h(AgeRange, { data: window }) });\n } else if (window == null || windowMatchesInterval(window, interval)) {\n tag = h(IntervalTag, { interval, showAgeRange: true, size });\n } else {\n tag = h(RefinedIntervalTag, { interval, window, size });\n }\n\n return h(\"span.age-window-tag\", { className: classNames(className) }, [\n tag,\n h.if(onClear != null)(Button, {\n className: \"clear-button\",\n icon: \"cross\",\n minimal: true,\n small: true,\n title: \"Clear\",\n onClick: onClear,\n }),\n ]);\n}\n\nfunction RefinedIntervalTag({\n interval,\n window,\n size,\n}: {\n interval: IntervalShort;\n window: AgeWindow;\n size: TagSize;\n}) {\n const interaction = useInteractionProps({ int_id: interval.id });\n return h(Tag, {\n ...interaction,\n size,\n name: interval.name,\n color: interval.color,\n details: h(AgeRange, { data: window }),\n });\n}\n\nfunction windowMatchesInterval(\n window: AgeWindow,\n interval: IntervalShort,\n): boolean {\n return window.t_age === interval.t_age && window.b_age === interval.b_age;\n}\n"],"names":["TagSize","h","Tag","AgeRange","IntervalTag","classNames","Button","useInteractionProps"],"mappings":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A,IACH;AAAA,IACA,MAAM,SAAS;AAAA,IACf,OAAO,SAAS;AAAA,IAChB,SAASD,oBAAEE,SAAAA,UAAU,EAAE,MAAM,QAAQ;AAAA,EAAA,CACtC;AACH;AAEA,SAAS,sBACP,QACA,UACS;AACT,SAAO,OAAO,UAAU,SAAS,SAAS,OAAO,UAAU,SAAS;AACtE;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IntervalShort, TagSize } from '@macrostrat/data-components';
|
|
2
|
+
import { Interval } from '@macrostrat/timescale';
|
|
3
|
+
import { AgeWindow } from '../animated-age-window';
|
|
4
|
+
/** Adapt a timescale `Interval` (as delivered by a `Timescale` click, with
|
|
5
|
+
* `eag`/`lag`/`nam`/`col`) to the `IntervalShort` shape the tag components
|
|
6
|
+
* take. The id prefers the Macrostrat `int_id` when the interval tree was built
|
|
7
|
+
* from the API, falling back to the interval's own `oid`. */
|
|
8
|
+
export declare function intervalShortFromTimescale(interval: Interval): IntervalShort;
|
|
9
|
+
export interface AgeWindowTagProps {
|
|
10
|
+
/** The interval the window was set from, if any. */
|
|
11
|
+
interval?: IntervalShort | null;
|
|
12
|
+
/** The rendered window. When it differs from the interval's own span (a
|
|
13
|
+
* refined window) it is shown in place of the interval's range. */
|
|
14
|
+
window?: AgeWindow | null;
|
|
15
|
+
/** Renders a clear button when given. */
|
|
16
|
+
onClear?: () => void;
|
|
17
|
+
size?: TagSize;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
/** A compact, clearable indicator of the age window a column or correlation
|
|
21
|
+
* chart is focused on — an interval tag (linking to the interval, with its
|
|
22
|
+
* range) or a bare age range. Renders nothing without an interval or window,
|
|
23
|
+
* so it can live permanently in a chart's `axisTopContent`. */
|
|
24
|
+
export declare function AgeWindowTag(props: AgeWindowTagProps): import('react').ReactElement<{
|
|
25
|
+
className: string;
|
|
26
|
+
}, string | import('react').JSXElementConstructor<any>> | null;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Button } from "@blueprintjs/core";
|
|
2
|
+
import { TagSize, Tag, IntervalTag, useInteractionProps } from "@macrostrat/data-components";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import h from "./age-window-tag.module.sass.js";
|
|
5
|
+
import { AgeRange } from "./age-range.js";
|
|
6
|
+
function intervalShortFromTimescale(interval) {
|
|
7
|
+
return {
|
|
8
|
+
id: interval.int_id ?? interval.oid,
|
|
9
|
+
name: interval.nam,
|
|
10
|
+
color: interval.col,
|
|
11
|
+
b_age: interval.eag,
|
|
12
|
+
t_age: interval.lag,
|
|
13
|
+
rank: interval.lvl
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function AgeWindowTag(props) {
|
|
17
|
+
const {
|
|
18
|
+
interval = null,
|
|
19
|
+
window = null,
|
|
20
|
+
onClear,
|
|
21
|
+
size = TagSize.Small,
|
|
22
|
+
className
|
|
23
|
+
} = props;
|
|
24
|
+
if (interval == null && window == null) return null;
|
|
25
|
+
let tag = null;
|
|
26
|
+
if (interval == null) {
|
|
27
|
+
tag = h(Tag, { size, name: h(AgeRange, { data: window }) });
|
|
28
|
+
} else if (window == null || windowMatchesInterval(window, interval)) {
|
|
29
|
+
tag = h(IntervalTag, { interval, showAgeRange: true, size });
|
|
30
|
+
} else {
|
|
31
|
+
tag = h(RefinedIntervalTag, { interval, window, size });
|
|
32
|
+
}
|
|
33
|
+
return h("span.age-window-tag", { className: classNames(className) }, [
|
|
34
|
+
tag,
|
|
35
|
+
h.if(onClear != null)(Button, {
|
|
36
|
+
className: "clear-button",
|
|
37
|
+
icon: "cross",
|
|
38
|
+
minimal: true,
|
|
39
|
+
small: true,
|
|
40
|
+
title: "Clear",
|
|
41
|
+
onClick: onClear
|
|
42
|
+
})
|
|
43
|
+
]);
|
|
44
|
+
}
|
|
45
|
+
function RefinedIntervalTag({
|
|
46
|
+
interval,
|
|
47
|
+
window,
|
|
48
|
+
size
|
|
49
|
+
}) {
|
|
50
|
+
const interaction = useInteractionProps({ int_id: interval.id });
|
|
51
|
+
return h(Tag, {
|
|
52
|
+
...interaction,
|
|
53
|
+
size,
|
|
54
|
+
name: interval.name,
|
|
55
|
+
color: interval.color,
|
|
56
|
+
details: h(AgeRange, { data: window })
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function windowMatchesInterval(window, interval) {
|
|
60
|
+
return window.t_age === interval.t_age && window.b_age === interval.b_age;
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
AgeWindowTag,
|
|
64
|
+
intervalShortFromTimescale
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=age-window-tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"age-window-tag.js","sources":["../../src/unit-details/age-window-tag.ts"],"sourcesContent":["import { Button } from \"@blueprintjs/core\";\nimport {\n IntervalShort,\n IntervalTag,\n Tag,\n TagSize,\n useInteractionProps,\n} from \"@macrostrat/data-components\";\nimport type { Interval } from \"@macrostrat/timescale\";\nimport classNames from \"classnames\";\nimport h from \"./age-window-tag.module.sass\";\nimport { AgeRange } from \"./age-range\";\nimport type { AgeWindow } from \"../animated-age-window\";\n\n/** Adapt a timescale `Interval` (as delivered by a `Timescale` click, with\n * `eag`/`lag`/`nam`/`col`) to the `IntervalShort` shape the tag components\n * take. The id prefers the Macrostrat `int_id` when the interval tree was built\n * from the API, falling back to the interval's own `oid`. */\nexport function intervalShortFromTimescale(interval: Interval): IntervalShort {\n return {\n id: interval.int_id ?? interval.oid,\n name: interval.nam,\n color: interval.col,\n b_age: interval.eag,\n t_age: interval.lag,\n rank: interval.lvl,\n };\n}\n\nexport interface AgeWindowTagProps {\n /** The interval the window was set from, if any. */\n interval?: IntervalShort | null;\n /** The rendered window. When it differs from the interval's own span (a\n * refined window) it is shown in place of the interval's range. */\n window?: AgeWindow | null;\n /** Renders a clear button when given. */\n onClear?: () => void;\n size?: TagSize;\n className?: string;\n}\n\n/** A compact, clearable indicator of the age window a column or correlation\n * chart is focused on — an interval tag (linking to the interval, with its\n * range) or a bare age range. Renders nothing without an interval or window,\n * so it can live permanently in a chart's `axisTopContent`. */\nexport function AgeWindowTag(props: AgeWindowTagProps) {\n const {\n interval = null,\n window = null,\n onClear,\n size = TagSize.Small,\n className,\n } = props;\n if (interval == null && window == null) return null;\n\n let tag = null;\n if (interval == null) {\n tag = h(Tag, { size, name: h(AgeRange, { data: window }) });\n } else if (window == null || windowMatchesInterval(window, interval)) {\n tag = h(IntervalTag, { interval, showAgeRange: true, size });\n } else {\n tag = h(RefinedIntervalTag, { interval, window, size });\n }\n\n return h(\"span.age-window-tag\", { className: classNames(className) }, [\n tag,\n h.if(onClear != null)(Button, {\n className: \"clear-button\",\n icon: \"cross\",\n minimal: true,\n small: true,\n title: \"Clear\",\n onClick: onClear,\n }),\n ]);\n}\n\nfunction RefinedIntervalTag({\n interval,\n window,\n size,\n}: {\n interval: IntervalShort;\n window: AgeWindow;\n size: TagSize;\n}) {\n const interaction = useInteractionProps({ int_id: interval.id });\n return h(Tag, {\n ...interaction,\n size,\n name: interval.name,\n color: interval.color,\n details: h(AgeRange, { data: window }),\n });\n}\n\nfunction windowMatchesInterval(\n window: AgeWindow,\n interval: IntervalShort,\n): boolean {\n return window.t_age === interval.t_age && window.b_age === interval.b_age;\n}\n"],"names":[],"mappings":";;;;;AAkBO,SAAS,2BAA2B,UAAmC;AAC5E,SAAO;AAAA,IACL,IAAI,SAAS,UAAU,SAAS;AAAA,IAChC,MAAM,SAAS;AAAA,IACf,OAAO,SAAS;AAAA,IAChB,OAAO,SAAS;AAAA,IAChB,OAAO,SAAS;AAAA,IAChB,MAAM,SAAS;AAAA,EAAA;AAEnB;AAkBO,SAAS,aAAa,OAA0B;AACrD,QAAM;AAAA,IACJ,WAAW;AAAA,IACX,SAAS;AAAA,IACT;AAAA,IACA,OAAO,QAAQ;AAAA,IACf;AAAA,EAAA,IACE;AACJ,MAAI,YAAY,QAAQ,UAAU,KAAM,QAAO;AAE/C,MAAI,MAAM;AACV,MAAI,YAAY,MAAM;AACpB,UAAM,EAAE,KAAK,EAAE,MAAM,MAAM,EAAE,UAAU,EAAE,MAAM,OAAA,CAAQ,EAAA,CAAG;AAAA,EAC5D,WAAW,UAAU,QAAQ,sBAAsB,QAAQ,QAAQ,GAAG;AACpE,UAAM,EAAE,aAAa,EAAE,UAAU,cAAc,MAAM,MAAM;AAAA,EAC7D,OAAO;AACL,UAAM,EAAE,oBAAoB,EAAE,UAAU,QAAQ,MAAM;AAAA,EACxD;AAEA,SAAO,EAAE,uBAAuB,EAAE,WAAW,WAAW,SAAS,KAAK;AAAA,IACpE;AAAA,IACA,EAAE,GAAG,WAAW,IAAI,EAAE,QAAQ;AAAA,MAC5B,WAAW;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,OAAO;AAAA,MACP,OAAO;AAAA,MACP,SAAS;AAAA,IAAA,CACV;AAAA,EAAA,CACF;AACH;AAEA,SAAS,mBAAmB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,cAAc,oBAAoB,EAAE,QAAQ,SAAS,IAAI;AAC/D,SAAO,EAAE,KAAK;AAAA,IACZ,GAAG;AAAA,IACH;AAAA,IACA,MAAM,SAAS;AAAA,IACf,OAAO,SAAS;AAAA,IAChB,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ;AAAA,EAAA,CACtC;AACH;AAEA,SAAS,sBACP,QACA,UACS;AACT,SAAO,OAAO,UAAU,SAAS,SAAS,OAAO,UAAU,SAAS;AACtE;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const h$1 = require("@macrostrat/hyper");
|
|
3
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
4
|
+
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
5
|
+
const styles = {
|
|
6
|
+
"age-window-tag": "_age-window-tag_1tskh_1",
|
|
7
|
+
"clear-button": "_clear-button_1tskh_8"
|
|
8
|
+
};
|
|
9
|
+
let h = h__default.default.styled(styles);
|
|
10
|
+
Object.assign(h, styles);
|
|
11
|
+
module.exports = h;
|
|
12
|
+
//# sourceMappingURL=age-window-tag.module.sass.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"age-window-tag.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import h$1 from "@macrostrat/hyper";
|
|
2
|
+
const styles = {
|
|
3
|
+
"age-window-tag": "_age-window-tag_1tskh_1",
|
|
4
|
+
"clear-button": "_clear-button_1tskh_8"
|
|
5
|
+
};
|
|
6
|
+
let h = h$1.styled(styles);
|
|
7
|
+
Object.assign(h, styles);
|
|
8
|
+
export {
|
|
9
|
+
h as default
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=age-window-tag.module.sass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"age-window-tag.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -2,5 +2,6 @@ export * from './panel';
|
|
|
2
2
|
export * from './popover';
|
|
3
3
|
export * from './modal-panel';
|
|
4
4
|
export * from './age-range';
|
|
5
|
+
export * from './age-window-tag';
|
|
5
6
|
export * from './strat-names';
|
|
6
7
|
export { ClickableText, Identifier, UnitIdentifier, } from '@macrostrat/data-components';
|
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","useUnitSelectionTarget","ClippableRect","ForeignObject","SizeAwareLabel","useMemo","PatternDefsProvider","scalePattern"],"mappings":";;;;;;;;;;;;;;;AAuBA,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,SAAS,UAAU;AAAA,IAC3B,OAAO,gBAAgB,QAAQ,UAAU;AAAA,EAAA;AAE7C;AAgDA,SAAS,KAAK,OAAkB;AAC9B,QAAM;AAAA,IACJ,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA;AAAA,IACV,GAAG;AAAA,EAAA,IACD;AAEJ,QAAM,EAAE,SAAA,IAAaC,2BAAA;AAErB,QAAM,iBAAiB,EAAE,cAAc;AACvC,QAAM,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;AAAAA,IACA,EAAA,WAAER,UAAAA,yBAAWS,UAAAA,aAAA;AAAA,IACb,EAAE,eAAe,QAAQ;AAAA,EAAA;AAE7B;;;;"}
|
|
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 { 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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B;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,IAAcX,MAAAA,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,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,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,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,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A,MACA;AAAA,MACA,GAAG;AAAA,IAAA;AAAA,IAEL;AAAA,MACE,EAAE,GAAG,aAAa,CAAC,SAAS;AAAA,QAC1B;AAAA,QACA,EAAE,GAAG,QAAQ,WAAW,uBAAA;AAAA,QACxB,EAAE,gBAAgB;AAAA,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;
|