@macrostrat/column-views 3.2.1 → 3.3.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 +10 -0
- package/dist/age-axis.cjs +2 -2
- package/dist/age-axis.cjs.map +1 -1
- package/dist/age-axis.js +1 -1
- package/dist/column-views.css +130 -125
- package/dist/index.cjs +30 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/dist/maps/column-correlation/core.cjs +10 -30
- package/dist/maps/column-correlation/core.cjs.map +1 -1
- package/dist/maps/column-correlation/core.d.ts +1 -1
- package/dist/maps/column-correlation/core.js +10 -30
- package/dist/maps/column-correlation/core.js.map +1 -1
- package/dist/maps/column-navigation/mapbox/index.cjs +156 -118
- package/dist/maps/column-navigation/mapbox/index.cjs.map +1 -1
- package/dist/maps/column-navigation/mapbox/index.d.ts +23 -2
- package/dist/maps/column-navigation/mapbox/index.js +158 -120
- package/dist/maps/column-navigation/mapbox/index.js.map +1 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs +7 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs.map +1 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +3 -26
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.js +9 -3
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.js.map +1 -1
- package/dist/maps/index.d.ts +2 -2
- package/dist/maps/{_shared/inset-map.cjs → inset-map/index.cjs} +1 -1
- package/dist/maps/inset-map/index.cjs.map +1 -0
- package/dist/maps/{_shared/inset-map.js → inset-map/index.js} +1 -1
- package/dist/maps/inset-map/index.js.map +1 -0
- package/dist/maps/layers/columns.cjs +161 -0
- package/dist/maps/layers/columns.cjs.map +1 -0
- package/dist/maps/layers/columns.d.ts +28 -0
- package/dist/maps/layers/columns.js +161 -0
- package/dist/maps/layers/columns.js.map +1 -0
- package/dist/maps/layers/index.d.ts +2 -0
- package/dist/maps/{units-overlay/index.cjs → layers/units.cjs} +41 -88
- package/dist/maps/layers/units.cjs.map +1 -0
- package/dist/maps/{units-overlay/index.d.ts → layers/units.d.ts} +1 -1
- package/dist/maps/{units-overlay/index.js → layers/units.js} +34 -82
- package/dist/maps/layers/units.js.map +1 -0
- package/dist/section.cjs +2 -2
- package/dist/section.cjs.map +1 -1
- package/dist/section.js +1 -1
- package/dist/unit-details/age-range.cjs +196 -0
- package/dist/unit-details/age-range.cjs.map +1 -0
- package/dist/unit-details/age-range.d.ts +70 -0
- package/dist/unit-details/age-range.js +194 -0
- package/dist/unit-details/age-range.js.map +1 -0
- package/dist/unit-details/age-range.module.sass.cjs +16 -0
- package/dist/unit-details/age-range.module.sass.cjs.map +1 -0
- package/dist/unit-details/age-range.module.sass.js +14 -0
- package/dist/unit-details/age-range.module.sass.js.map +1 -0
- package/dist/unit-details/index.d.ts +1 -0
- package/dist/unit-details/panel.cjs +8 -173
- package/dist/unit-details/panel.cjs.map +1 -1
- package/dist/unit-details/panel.js +3 -168
- package/dist/unit-details/panel.js.map +1 -1
- package/dist/unit-details/panel.module.sass.cjs +20 -22
- package/dist/unit-details/panel.module.sass.cjs.map +1 -1
- package/dist/unit-details/panel.module.sass.js +20 -22
- package/dist/unit-details/panel.module.sass.js.map +1 -1
- package/dist/unit-details/utils.cjs +31 -0
- package/dist/unit-details/utils.cjs.map +1 -0
- package/dist/unit-details/utils.d.ts +3 -0
- package/dist/unit-details/utils.js +31 -0
- package/dist/unit-details/utils.js.map +1 -0
- package/package.json +4 -4
- package/src/maps/column-correlation/core.ts +9 -29
- package/src/maps/column-navigation/mapbox/index.ts +191 -138
- package/src/maps/column-navigation/mapbox/keyboard-navigation.ts +17 -3
- package/src/maps/index.ts +2 -2
- package/src/maps/layers/columns.ts +210 -0
- package/src/maps/layers/index.ts +2 -0
- package/src/maps/{units-overlay/index.ts → layers/units.ts} +34 -84
- package/src/maps/unit-map.stories.ts +27 -12
- package/src/unit-details/age-range.module.sass +15 -0
- package/src/unit-details/age-range.ts +269 -0
- package/src/unit-details/index.ts +1 -0
- package/src/unit-details/panel.module.sass +0 -9
- package/src/unit-details/panel.ts +12 -226
- package/src/unit-details/utils.ts +33 -0
- package/dist/maps/_shared/index.d.ts +0 -2
- package/dist/maps/_shared/inset-map.cjs.map +0 -1
- package/dist/maps/_shared/inset-map.js.map +0 -1
- package/dist/maps/_shared/styles.cjs +0 -73
- package/dist/maps/_shared/styles.cjs.map +0 -1
- package/dist/maps/_shared/styles.d.ts +0 -2
- package/dist/maps/_shared/styles.js +0 -73
- package/dist/maps/_shared/styles.js.map +0 -1
- package/dist/maps/units-overlay/index.cjs.map +0 -1
- package/dist/maps/units-overlay/index.js.map +0 -1
- package/src/maps/_shared/index.ts +0 -2
- package/src/maps/_shared/styles.ts +0 -76
- /package/dist/maps/{_shared/inset-map.d.ts → inset-map/index.d.ts} +0 -0
- /package/src/maps/{_shared/inset-map.ts → inset-map/index.ts} +0 -0
- /package/src/maps/{_shared → inset-map}/inset-map.stories.ts +0 -0
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { useLithologies, useMacrostratColumns } from "@macrostrat/data-provider";
|
|
2
2
|
import { useAPIResult } from "@macrostrat/ui-components";
|
|
3
|
-
import { useMapStyleOperator } from "@macrostrat/mapbox-react";
|
|
3
|
+
import { useOverlayStyle, useMapStyleOperator } from "@macrostrat/mapbox-react";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { buildGeoJSONSource, mergeStyles, setGeoJSON } from "@macrostrat/mapbox-utils";
|
|
6
6
|
import { getBestFGDCPatternForLithologyList } from "../../units/resolvers.js";
|
|
7
7
|
import { setupStyleImageManager, loadStyleImage } from "@macrostrat/map-styles";
|
|
8
|
-
import {
|
|
8
|
+
import { asChromaColor } from "@macrostrat/color-utils";
|
|
9
9
|
import pMap from "p-map";
|
|
10
|
+
import { BaseColumnsLayer } from "./columns.js";
|
|
11
|
+
import h from "@macrostrat/hyper";
|
|
10
12
|
import { flattenLithologies, getMixedColorForData } from "../../units/colors.js";
|
|
11
13
|
function MacrostratUnitsOverlay(props) {
|
|
12
14
|
const { time, ageSpan = 0.05, patterns = false } = props;
|
|
13
15
|
const lithMap = useLithologies();
|
|
16
|
+
useOverlayStyle(() => {
|
|
17
|
+
return buildUnitsStyle({ patterns });
|
|
18
|
+
}, [patterns]);
|
|
14
19
|
useMapStyleOperator(
|
|
15
20
|
(map) => {
|
|
16
21
|
if (!patterns) return;
|
|
@@ -35,19 +40,6 @@ function MacrostratUnitsOverlay(props) {
|
|
|
35
40
|
}, [time, ageSpan, props.project]);
|
|
36
41
|
const units = useAPIResult("/units", params);
|
|
37
42
|
const columns = useMacrostratColumns(params.project, false);
|
|
38
|
-
useMapStyleOperator(
|
|
39
|
-
(map) => {
|
|
40
|
-
if (columns == null) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const data = {
|
|
44
|
-
type: "FeatureCollection",
|
|
45
|
-
features: columns
|
|
46
|
-
};
|
|
47
|
-
setGeoJSON(map, "columns", data);
|
|
48
|
-
},
|
|
49
|
-
[columns]
|
|
50
|
-
);
|
|
51
43
|
useMapStyleOperator(
|
|
52
44
|
(map) => {
|
|
53
45
|
if (units == null || columns == null || lithMap == null) {
|
|
@@ -70,7 +62,28 @@ function MacrostratUnitsOverlay(props) {
|
|
|
70
62
|
},
|
|
71
63
|
[units, lithMap, columns, patterns]
|
|
72
64
|
);
|
|
73
|
-
|
|
65
|
+
const isHovered = ["boolean", ["feature-state", "hover"], false];
|
|
66
|
+
const isShown = ["boolean", ["feature-state", "shown"], false];
|
|
67
|
+
const opacity = [
|
|
68
|
+
"case",
|
|
69
|
+
["all", isHovered, isShown],
|
|
70
|
+
0.9,
|
|
71
|
+
isShown,
|
|
72
|
+
0.8,
|
|
73
|
+
isHovered,
|
|
74
|
+
0.3,
|
|
75
|
+
0
|
|
76
|
+
];
|
|
77
|
+
return h([
|
|
78
|
+
h(BaseColumnsLayer, {
|
|
79
|
+
enabled: true,
|
|
80
|
+
columns,
|
|
81
|
+
opacity,
|
|
82
|
+
lineOpacity: 0.2,
|
|
83
|
+
lineColor: "lightgray",
|
|
84
|
+
color: "transparent"
|
|
85
|
+
})
|
|
86
|
+
]);
|
|
74
87
|
}
|
|
75
88
|
function handleUnitsLayerUpdate(map, unitsMap, columns) {
|
|
76
89
|
for (const column of columns) {
|
|
@@ -158,71 +171,10 @@ function getPatternSpec(liths, getColor) {
|
|
|
158
171
|
return `fgdc:${patternID}:${color}:transparent`;
|
|
159
172
|
}
|
|
160
173
|
function buildUnitsStyle(opts = {}) {
|
|
161
|
-
const {
|
|
162
|
-
let columnBaseColor = color ?? getCSSVariable("--text-subtle-color", "black");
|
|
163
|
-
getCSSVariable("--selection-color", "purple");
|
|
164
|
-
let columnColor = [
|
|
165
|
-
"coalesce",
|
|
166
|
-
["feature-state", "color"],
|
|
167
|
-
["get", "color"],
|
|
168
|
-
columnBaseColor
|
|
169
|
-
];
|
|
174
|
+
const { patterns = false } = opts;
|
|
170
175
|
const baseStyle = {
|
|
171
|
-
sources: {
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
version: 8,
|
|
175
|
-
layers: [
|
|
176
|
-
{
|
|
177
|
-
id: "columns-fill",
|
|
178
|
-
type: "fill",
|
|
179
|
-
source: "columns",
|
|
180
|
-
paint: {
|
|
181
|
-
"fill-color": columnColor,
|
|
182
|
-
"fill-opacity": [
|
|
183
|
-
"case",
|
|
184
|
-
["boolean", ["feature-state", "shown"], false],
|
|
185
|
-
0.8,
|
|
186
|
-
["boolean", ["feature-state", "hover"], false],
|
|
187
|
-
0.3,
|
|
188
|
-
0.1
|
|
189
|
-
]
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
id: "columns-line",
|
|
194
|
-
type: "line",
|
|
195
|
-
source: "columns",
|
|
196
|
-
paint: {
|
|
197
|
-
"line-color": columnColor,
|
|
198
|
-
"line-width": 1,
|
|
199
|
-
"line-opacity": 0.5
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
id: "columns-points",
|
|
204
|
-
type: "circle",
|
|
205
|
-
source: "columns",
|
|
206
|
-
paint: {
|
|
207
|
-
"circle-radius": 4,
|
|
208
|
-
"circle-color": [
|
|
209
|
-
"case",
|
|
210
|
-
["boolean", ["feature-state", "shown"], false],
|
|
211
|
-
columnColor,
|
|
212
|
-
columnBaseColor
|
|
213
|
-
],
|
|
214
|
-
"circle-opacity": [
|
|
215
|
-
"case",
|
|
216
|
-
["boolean", ["feature-state", "shown"], false],
|
|
217
|
-
0.8,
|
|
218
|
-
["boolean", ["feature-state", "hover"], false],
|
|
219
|
-
0.3,
|
|
220
|
-
0.1
|
|
221
|
-
]
|
|
222
|
-
},
|
|
223
|
-
filter: ["==", "$type", "Point"]
|
|
224
|
-
}
|
|
225
|
-
]
|
|
176
|
+
sources: {},
|
|
177
|
+
version: 8
|
|
226
178
|
};
|
|
227
179
|
if (!patterns) {
|
|
228
180
|
return baseStyle;
|
|
@@ -249,4 +201,4 @@ export {
|
|
|
249
201
|
MacrostratUnitsOverlay,
|
|
250
202
|
buildUnitsStyle
|
|
251
203
|
};
|
|
252
|
-
//# sourceMappingURL=
|
|
204
|
+
//# sourceMappingURL=units.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"units.js","sources":["../../../src/maps/layers/units.ts"],"sourcesContent":["import {\n useLithologies,\n useMacrostratColumns,\n} from \"@macrostrat/data-provider\";\nimport { useAPIResult } from \"@macrostrat/ui-components\";\nimport { useMapStyleOperator, useOverlayStyle } from \"@macrostrat/mapbox-react\";\nimport { FeatureCollection } from \"geojson\";\nimport { useMemo } from \"react\";\nimport { mergeStyles, setGeoJSON } from \"@macrostrat/mapbox-utils\";\nimport { UnitLithology, UnitLong } from \"@macrostrat/api-types\";\nimport { flattenLithologies, getMixedColorForData } from \"../../units\";\nimport { getBestFGDCPatternForLithologyList } from \"../../units/resolvers\";\nimport {\n setupStyleImageManager,\n loadStyleImage,\n StyleFragment,\n} from \"@macrostrat/map-styles\";\nimport { asChromaColor } from \"@macrostrat/color-utils\";\nimport { buildGeoJSONSource } from \"@macrostrat/mapbox-utils\";\nimport pMap from \"p-map\";\nimport { BaseColumnsLayer } from \"./columns\";\nimport h from \"@macrostrat/hyper\";\n\nexport interface UnitsOverlayProps {\n time: number;\n ageSpan?: number;\n project?: number | number[];\n patterns?: boolean;\n}\n\nexport function MacrostratUnitsOverlay(props: UnitsOverlayProps) {\n const { time, ageSpan = 0.05, patterns = false } = props;\n const lithMap = useLithologies();\n\n useOverlayStyle(() => {\n return buildUnitsStyle({ patterns });\n }, [patterns]);\n\n useMapStyleOperator(\n (map) => {\n if (!patterns) return;\n setupStyleImageManager(map, { verbose: false });\n },\n [patterns],\n );\n\n const params = useMemo(() => {\n let project: number[] | undefined;\n if (Number.isFinite(props.project)) {\n project = [props.project as number];\n } else if (!Array.isArray(props.project)) {\n project = undefined;\n }\n // Project can only be a single project for now\n const projectCompat =\n project != null && project.length > 0 ? project[0] : undefined;\n\n return {\n age_bottom: time + ageSpan / 2,\n age_top: time - ageSpan / 2,\n response: \"long\",\n project: projectCompat,\n };\n }, [time, ageSpan, props.project]);\n\n const units: UnitLong[] = useAPIResult(\"/units\", params);\n const columns = useMacrostratColumns(params.project, false);\n\n useMapStyleOperator(\n (map) => {\n if (units == null || columns == null || lithMap == null) {\n return;\n }\n\n const getColorForLithology = (data: UnitLithology): string | null => {\n return lithMap?.get(data.lith_id)?.color ?? null;\n };\n\n const unitsMap = postProcessUnits(units, getColorForLithology);\n handleUnitsLayerUpdate(map, unitsMap, columns);\n if (patterns) {\n handlePatternOverlayUpdate(\n map,\n unitsMap,\n columns,\n getColorForLithology,\n ).then(() => {});\n }\n },\n [units, lithMap, columns, patterns],\n );\n\n const isHovered = [\"boolean\", [\"feature-state\", \"hover\"], false];\n const isShown = [\"boolean\", [\"feature-state\", \"shown\"], false];\n\n const opacity = [\n \"case\",\n [\"all\", isHovered, isShown],\n 0.9,\n isShown,\n 0.8,\n isHovered,\n 0.3,\n 0.0,\n ];\n\n return h([\n h(BaseColumnsLayer, {\n enabled: true,\n columns,\n opacity,\n lineOpacity: 0.2,\n lineColor: \"lightgray\",\n color: \"transparent\",\n }),\n ]);\n}\n\nfunction handleUnitsLayerUpdate(\n map,\n unitsMap: Map<number, UnitsDisplayInfo>,\n columns: any[],\n) {\n // Update feature states\n for (const column of columns) {\n const col_id = column.properties.col_id;\n const info = unitsMap.get(Number(col_id));\n const color = info?.color;\n map.setFeatureState(\n { source: \"columns\", id: col_id },\n {\n color,\n shown: color != null,\n },\n );\n }\n}\n\nasync function handlePatternOverlayUpdate(\n map,\n unitsMap: Map<number, UnitsDisplayInfo>,\n columns: any[],\n getColor: LithologyColorGetter,\n) {\n // synthesize patterns not yet in cache\n\n const colsWithPatterns = [];\n const patternIDs = new Set<string>();\n // Update feature states\n for (const column of columns) {\n const col_id = column.properties.col_id;\n const info = unitsMap.get(Number(col_id));\n if (info == null) continue;\n const pattern = getPatternSpec(info?.liths, getColor);\n if (pattern == null) continue;\n\n colsWithPatterns.push({\n type: \"Feature\",\n geometry: column.geometry,\n properties: {\n col_id,\n pattern,\n },\n });\n patternIDs.add(pattern);\n }\n\n const patternsToLoad = patternIDs.values().filter((d) => !map.hasImage(d));\n\n const mapper = async (patternID) => {\n try {\n await loadStyleImage(map, patternID, { pixelRatio: 10 });\n } catch (e) {}\n };\n // Load all pattern images\n await pMap(patternsToLoad, mapper, { concurrency: 5 });\n\n // Set data for pattern layer\n // This is inefficient but the only way to set per-feature patterns in Mapbox\n const patternData: FeatureCollection = {\n type: \"FeatureCollection\",\n features: colsWithPatterns,\n };\n setGeoJSON(map, \"column-patterns\", patternData);\n}\n\nconst cachedColors = new Map<string, string>();\n\nfunction getDarkenedColor(color: string): string {\n /** Memoized function to get a darkened version of a color for pattern use */\n if (cachedColors.has(color)) {\n return cachedColors.get(color);\n }\n const c1 = asChromaColor(color).set(\"hsl.l\", 0.4).set(\"hsl.s\", 0.8).hex();\n cachedColors.set(color, c1);\n return c1;\n}\n\ninterface UnitsDisplayInfo {\n col_id: number;\n units: UnitLong[];\n color: string;\n liths: UnitLithology[];\n}\n\ntype LithologyColorGetter = (val: UnitLithology) => string | null;\n\nfunction postProcessUnits(\n units: UnitLong[],\n getColor: LithologyColorGetter,\n): Map<number, UnitsDisplayInfo> {\n // Group by col_id\n const unitsByColumn: Map<number, UnitLong[]> = new Map();\n for (const unit of units) {\n const col_id = Number(unit.col_id);\n if (!unitsByColumn.has(col_id)) {\n unitsByColumn.set(col_id, [unit]);\n } else {\n unitsByColumn.set(col_id, [...unitsByColumn.get(col_id), unit]);\n }\n }\n\n // Summarize units for display\n const res = new Map<number, UnitsDisplayInfo>();\n for (const [col_id, unitList] of unitsByColumn.entries()) {\n const liths = flattenLithologies(unitList.map((u) => u.lith));\n res.set(col_id, {\n col_id,\n units: unitList,\n liths,\n color: getMixedColorForData(liths, getColor),\n });\n }\n\n return res;\n}\n\nfunction getPatternSpec(\n liths: UnitLithology[],\n getColor: LithologyColorGetter,\n): string | null {\n const patternData = getBestFGDCPatternForLithologyList(liths);\n if (patternData == null) return null;\n let { patternID, lith } = patternData;\n const color = getDarkenedColor(getColor(lith));\n return `fgdc:${patternID}:${color}:transparent`;\n}\n\ntype UnitsStyleOptions = {\n color?: string;\n patterns?: boolean;\n};\n\nexport function buildUnitsStyle(opts: UnitsStyleOptions = {}): StyleFragment {\n const { patterns = false } = opts;\n\n // If color is in the feature state or geojson properties, use that as second choice\n\n const baseStyle: StyleFragment = {\n sources: {},\n version: 8,\n };\n\n if (!patterns) {\n return baseStyle;\n }\n\n const patternStyle: StyleFragment = {\n sources: {\n \"column-patterns\": buildGeoJSONSource(),\n },\n layers: [\n {\n id: \"columns-fill-pattern\",\n type: \"fill\",\n source: \"column-patterns\",\n paint: {\n \"fill-pattern\": [\"get\", \"pattern\"],\n \"fill-opacity\": 1,\n },\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AC,MAAM,EAAE,IAAI,CAAC;AAC5D,QAAI,IAAI,QAAQ;AAAA,MACd;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA,OAAO,qBAAqB,OAAO,QAAQ;AAAA,IAAA,CAC5C;AAAA,EACH;AAEA,SAAO;AACT;AAEA,SAAS,eACP,OACA,UACe;AACf,QAAM,cAAc,mCAAmC,KAAK;AAC5D,MAAI,eAAe,KAAM,QAAO;AAChC,MAAI,EAAE,WAAW,KAAA,IAAS;AAC1B,QAAM,QAAQ,iBAAiB,SAAS,IAAI,CAAC;AAC7C,SAAO,QAAQ,SAAS,IAAI,KAAK;AACnC;AAOO,SAAS,gBAAgB,OAA0B,IAAmB;AAC3E,QAAM,EAAE,WAAW,MAAA,IAAU;AAI7B,QAAM,YAA2B;AAAA,IAC/B,SAAS,CAAA;AAAA,IACT,SAAS;AAAA,EAAA;AAGX,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,QAAM,eAA8B;AAAA,IAClC,SAAS;AAAA,MACP,mBAAmB,mBAAA;AAAA,IAAmB;AAAA,IAExC,QAAQ;AAAA,MACN;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,OAAO;AAAA,UACL,gBAAgB,CAAC,OAAO,SAAS;AAAA,UACjC,gBAAgB;AAAA,QAAA;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AAGF,SAAO,YAAY,WAAW,YAAY;AAC5C;"}
|
package/dist/section.cjs
CHANGED
|
@@ -9,7 +9,7 @@ const dataProvider = require("@macrostrat/data-provider");
|
|
|
9
9
|
const dataComponents = require("@macrostrat/data-components");
|
|
10
10
|
const store = require("./data-provider/store.cjs");
|
|
11
11
|
const composite = require("./units/composite.cjs");
|
|
12
|
-
const
|
|
12
|
+
const ageRange = require("./unit-details/age-range.cjs");
|
|
13
13
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
14
14
|
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
15
15
|
const h = h__default.default.styled(column_module.default);
|
|
@@ -254,7 +254,7 @@ function Unconformity({
|
|
|
254
254
|
const _txt = ageGap.toLocaleString("en-US", { maximumFractionDigits });
|
|
255
255
|
val = h(dataComponents.Value, { value: _txt, unit: "m" });
|
|
256
256
|
} else {
|
|
257
|
-
val = h(
|
|
257
|
+
val = h(ageRange.Duration, { value: ageGap, maximumFractionDigits });
|
|
258
258
|
}
|
|
259
259
|
let prefix = null;
|
|
260
260
|
if (verbose) {
|
package/dist/section.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section.cjs","sources":["../src/section.ts"],"sourcesContent":["import {\n CompositeUnitsColumn,\n LabelTrackerProvider,\n SectionLabelsColumn,\n} from \"./units\";\nimport { ReactNode, FunctionComponent, useMemo } from \"react\";\nimport {\n Timescale,\n TimescaleOrientation,\n useMacrostratIntervals,\n} from \"@macrostrat/timescale\";\nimport { ColumnAxisType, SVG } from \"@macrostrat/column-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./column.module.sass\";\nimport {\n useMacrostratColumnData,\n useMacrostratUnits,\n MacrostratColumnProvider,\n} from \"./data-provider\";\nimport { useMacrostratBaseURL } from \"@macrostrat/data-provider\";\nimport { Duration } from \"./unit-details\";\nimport { Value } from \"@macrostrat/data-components\";\nimport type { ExtUnit, PackageScaleLayoutData } from \"./prepare-units/types\";\n\nconst h = hyper.styled(styles);\n\nexport interface SectionSharedProps {\n unitComponent?: FunctionComponent<any>;\n unitComponentProps?: any;\n showLabels?: boolean;\n width?: number;\n columnWidth?: number;\n children?: ReactNode;\n showLabelColumn?: boolean;\n axisType?: ColumnAxisType;\n className?: string;\n clipUnits?: boolean;\n maxInternalColumns?: number;\n // Space between sections\n verticalSpacing?: number;\n // Whether to render unconformity labels\n unconformityLabels?: boolean;\n}\n\nexport interface SectionProps extends SectionSharedProps {\n units: ExtUnit[];\n scaleInfo: PackageScaleLayoutData;\n}\n\nexport function SectionsColumn(props: SectionSharedProps) {\n const {\n unconformityLabels = true,\n unitComponent,\n unitComponentProps,\n showLabels = true,\n width = 300,\n columnWidth = 150,\n showLabelColumn = true,\n clipUnits = true,\n maxInternalColumns,\n } = props;\n\n const units = useMacrostratUnits();\n\n // Get a unique key for the column\n const key = units[0]?.col_id;\n\n return h(LabelTrackerProvider, { units, key }, [\n h(SectionUnitsColumn, {\n width: columnWidth,\n unitComponent,\n unitComponentProps,\n showLabels,\n clipUnits,\n maxInternalColumns,\n unconformityLabels,\n }),\n h.if(showLabelColumn)(SectionLabelsColumn, {\n width: width - columnWidth,\n }),\n ]);\n}\n\nfunction SectionUnitsColumn(props: SectionSharedProps) {\n const {\n width,\n showLabels,\n unitComponent,\n unitComponentProps,\n clipUnits,\n maxInternalColumns,\n axisType,\n unconformityLabels = true,\n } = props;\n\n const { sections, totalHeight } = useMacrostratColumnData();\n\n const scaleData: PackageScaleLayoutData[] = sections.map((section) => {\n return section.scaleInfo;\n });\n\n const innerWidth = width - 2;\n\n return h(\"div.section-units-container\", { style: { width } }, [\n h(\n SVG,\n {\n className: \"sections\",\n height: totalHeight,\n innerWidth,\n paddingH: 1,\n },\n sections.map((group) => {\n const { units, scaleInfo, section_id } = group;\n\n const key = `section-${section_id}`;\n return h(\n SectionUnits,\n {\n units,\n scaleInfo,\n key,\n unitComponent,\n unitComponentProps,\n showLabels,\n width: innerWidth,\n clipUnits,\n maxInternalColumns,\n }, // This unconformity is with the section _above_\n );\n }),\n ),\n h.if(unconformityLabels)(UnconformityLabels, {\n width,\n sections: scaleData,\n verbose: false,\n }),\n ]);\n}\n\nfunction SectionUnits(props: SectionProps) {\n // Section with \"squishy\" timescale\n const {\n units,\n scaleInfo,\n unitComponent,\n showLabels = true,\n width = 300,\n unitComponentProps,\n className,\n clipUnits = true,\n maxInternalColumns,\n } = props;\n\n const { domain, pixelScale, pixelHeight, scale } = scaleInfo;\n\n /** Ensure that we can arrange units into the maximum number\n * of columns defined by unitComponentProps, but that we don't\n * use more than necessary.\n */\n const _unitComponentProps = useMemo(() => {\n return {\n ...unitComponentProps,\n nColumns: Math.min(\n maxInternalColumns ?? Math.floor(width / 10),\n unitComponentProps?.nColumns ?? Infinity,\n Math.max(...units.map((d) => d.column)) + 1,\n ),\n //axisType,\n };\n }, [units, unitComponentProps, maxInternalColumns, width]);\n\n const style = {\n \"--section-height\": `${pixelHeight}px`,\n \"--section-width\": `${width}px`,\n };\n\n return h(\n \"g.section\",\n { className, style, transform: `translate(0 ${scaleInfo.offset})` },\n h(\n MacrostratColumnProvider,\n {\n units,\n domain,\n pixelScale, // Actually pixels per myr,\n scale,\n },\n h(CompositeUnitsColumn, {\n width,\n showLabels,\n unitComponent,\n unitComponentProps: _unitComponentProps,\n clipToFrame: clipUnits,\n }),\n ),\n );\n}\n\ninterface CompositeTimescaleProps {\n levels?: [number, number] | number;\n unconformityLabels?: boolean;\n}\n\nexport function CompositeTimescale(props: CompositeTimescaleProps) {\n const { sections } = useMacrostratColumnData();\n const sectionScales = sections.map((section) => {\n return section.scaleInfo;\n });\n\n return h(CompositeTimescaleCore, {\n packages: sectionScales,\n ...props,\n });\n}\n\ntype CompositeTimescaleCoreProps = CompositeTimescaleProps & {\n packages: PackageScaleLayoutData[];\n};\n\nexport function CompositeTimescaleCore(props: CompositeTimescaleCoreProps) {\n const { levels = 3, packages, unconformityLabels = false } = props;\n\n // Use intervals from Macrostrat API\n const baseURL = useMacrostratBaseURL();\n const intervals = useMacrostratIntervals(baseURL);\n\n let _levels: [number, number];\n if (typeof levels === \"number\") {\n // If levels is a number, use the most common starting level\n _levels = [2, Math.max(2 + Math.min(levels, 5) - 1, 1)];\n } else {\n _levels = levels;\n }\n\n const nCols = _levels[1] - _levels[0] + 1;\n\n return h(\"div.timescale-column\", [\n h(\n \"div.timescales\",\n packages.map((group) => {\n const { pixelHeight, paddingTop, key, scale } = group;\n return h(\n \"div.timescale-container\",\n { style: { paddingTop, \"--timescale-level-count\": nCols }, key },\n [\n h(Timescale, {\n orientation: TimescaleOrientation.VERTICAL,\n length: pixelHeight,\n levels: _levels,\n absoluteAgeScale: true,\n showAgeAxis: false,\n scale,\n intervals,\n }),\n ],\n );\n }),\n ),\n h.if(unconformityLabels)(UnconformityLabels, {\n width: \"100%\",\n sections: packages,\n className: \"unconformity-labels\",\n axisType: ColumnAxisType.AGE,\n }),\n ]);\n}\n\nexport function UnconformityLabels(props: {\n width: string | number;\n sections: PackageScaleLayoutData[];\n axisType?: ColumnAxisType;\n className?: string;\n verbose?: boolean;\n}) {\n const { width, sections, className, axisType, verbose } = props;\n\n return h(\n \"div.unconformity-labels\",\n {\n style: {\n width,\n },\n className,\n },\n sections.map((scaleInfo, i) => {\n const lastGroup = sections[i - 1];\n const top = scaleInfo.offset - scaleInfo.paddingTop;\n const upperAge = lastGroup?.domain[0];\n const lowerAge = scaleInfo.domain[1];\n return h(Unconformity, {\n axisType,\n upperAge,\n lowerAge,\n style: {\n width,\n height: scaleInfo.paddingTop,\n top,\n },\n verbose,\n });\n }),\n );\n}\n\nfunction Unconformity({\n upperAge,\n lowerAge,\n style,\n axisType,\n verbose = false,\n}) {\n if (upperAge == null || lowerAge == null) {\n return null;\n }\n\n const ageGap = Math.abs(upperAge - lowerAge);\n\n let maximumFractionDigits = 0;\n\n let className: string = null;\n if (ageGap > 1000) {\n className = \"giga\";\n } else if (ageGap > 100) {\n className = \"mega\";\n } else if (ageGap > 10) {\n className = \"large\";\n } else if (ageGap < 1) {\n className = \"small\";\n maximumFractionDigits = 2;\n } else {\n maximumFractionDigits = 1;\n }\n\n let val: ReactNode;\n if (axisType === ColumnAxisType.DEPTH || axisType === ColumnAxisType.HEIGHT) {\n const _txt = ageGap.toLocaleString(\"en-US\", { maximumFractionDigits });\n val = h(Value, { value: _txt, unit: \"m\" });\n } else {\n val = h(Duration, { value: ageGap, maximumFractionDigits });\n }\n\n let prefix: ReactNode = null;\n if (verbose) {\n prefix = h([\" \", h(\"span.prefix\", \" gap\")]);\n }\n\n return h(\"div.unconformity\", { style, className }, [\n h(\"div.unconformity-inner\", h(\"div.unconformity-text\", [val, prefix])),\n ]);\n}\n"],"names":["hyper","styles","useMacrostratUnits","LabelTrackerProvider","SectionLabelsColumn","useMacrostratColumnData","SVG","useMemo","MacrostratColumnProvider","CompositeUnitsColumn","useMacrostratBaseURL","useMacrostratIntervals","Timescale","TimescaleOrientation","ColumnAxisType","Value","Duration"],"mappings":";;;;;;;;;;;;;;AAwBA,MAAM,IAAIA,WAAAA,QAAM,OAAOC,qBAAM;AAyBtB,SAAS,eAAe,OAA2B;AACxD,QAAM;AAAA,IACJ,qBAAqB;AAAA,IACrB;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,YAAY;AAAA,IACZ;AAAA,EAAA,IACE;AAEJ,QAAM,QAAQC,MAAAA,mBAAA;AAGd,QAAM,MAAM,MAAM,CAAC,GAAG;AAEtB,SAAO,EAAEC,UAAAA,sBAAsB,EAAE,OAAO,OAAO;AAAA,IAC7C,EAAE,oBAAoB;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,IACD,EAAE,GAAG,eAAe,EAAEC,+BAAqB;AAAA,MACzC,OAAO,QAAQ;AAAA,IAAA,CAChB;AAAA,EAAA,CACF;AACH;AAEA,SAAS,mBAAmB,OAA2B;AACrD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,EAAA,IACnB;AAEJ,QAAM,EAAE,UAAU,YAAA,IAAgBC,8BAAA;AAElC,QAAM,YAAsC,SAAS,IAAI,CAAC,YAAY;AACpE,WAAO,QAAQ;AAAA,EACjB,CAAC;AAED,QAAM,aAAa,QAAQ;AAE3B,SAAO,EAAE,+BAA+B,EAAE,OAAO,EAAE,MAA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,EACd,WAAW,SAAS,IAAI;AACtB,gBAAY;AAAA,EACd,WAAW,SAAS,GAAG;AACrB,gBAAY;AACZ,4BAAwB;AAAA,EAC1B,OAAO;AACL,4BAAwB;AAAA,EAC1B;AAEA,MAAI;AACJ,MAAI,aAAaA,iBAAAA,eAAe,SAAS,aAAaA,iBAAAA,eAAe,QAAQ;AAC3E,UAAM,OAAO,OAAO,eAAe,SAAS,EAAE,uBAAuB;AACrE,UAAM,EAAEC,sBAAO,EAAE,OAAO,MAAM,MAAM,KAAK;AAAA,EAC3C,OAAO;AACL,UAAM,EAAEC,MAAAA,UAAU,EAAE,OAAO,QAAQ,uBAAuB;AAAA,EAC5D;AAEA,MAAI,SAAoB;AACxB,MAAI,SAAS;AACX,aAAS,EAAE,CAAC,KAAK,EAAE,eAAe,MAAM,CAAC,CAAC;AAAA,EAC5C;AAEA,SAAO,EAAE,oBAAoB,EAAE,OAAO,aAAa;AAAA,IACjD,EAAE,0BAA0B,EAAE,yBAAyB,CAAC,KAAK,MAAM,CAAC,CAAC;AAAA,EAAA,CACtE;AACH;;;;;"}
|
|
1
|
+
{"version":3,"file":"section.cjs","sources":["../src/section.ts"],"sourcesContent":["import {\n CompositeUnitsColumn,\n LabelTrackerProvider,\n SectionLabelsColumn,\n} from \"./units\";\nimport { ReactNode, FunctionComponent, useMemo } from \"react\";\nimport {\n Timescale,\n TimescaleOrientation,\n useMacrostratIntervals,\n} from \"@macrostrat/timescale\";\nimport { ColumnAxisType, SVG } from \"@macrostrat/column-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./column.module.sass\";\nimport {\n useMacrostratColumnData,\n useMacrostratUnits,\n MacrostratColumnProvider,\n} from \"./data-provider\";\nimport { useMacrostratBaseURL } from \"@macrostrat/data-provider\";\nimport { Duration } from \"./unit-details\";\nimport { Value } from \"@macrostrat/data-components\";\nimport type { ExtUnit, PackageScaleLayoutData } from \"./prepare-units/types\";\n\nconst h = hyper.styled(styles);\n\nexport interface SectionSharedProps {\n unitComponent?: FunctionComponent<any>;\n unitComponentProps?: any;\n showLabels?: boolean;\n width?: number;\n columnWidth?: number;\n children?: ReactNode;\n showLabelColumn?: boolean;\n axisType?: ColumnAxisType;\n className?: string;\n clipUnits?: boolean;\n maxInternalColumns?: number;\n // Space between sections\n verticalSpacing?: number;\n // Whether to render unconformity labels\n unconformityLabels?: boolean;\n}\n\nexport interface SectionProps extends SectionSharedProps {\n units: ExtUnit[];\n scaleInfo: PackageScaleLayoutData;\n}\n\nexport function SectionsColumn(props: SectionSharedProps) {\n const {\n unconformityLabels = true,\n unitComponent,\n unitComponentProps,\n showLabels = true,\n width = 300,\n columnWidth = 150,\n showLabelColumn = true,\n clipUnits = true,\n maxInternalColumns,\n } = props;\n\n const units = useMacrostratUnits();\n\n // Get a unique key for the column\n const key = units[0]?.col_id;\n\n return h(LabelTrackerProvider, { units, key }, [\n h(SectionUnitsColumn, {\n width: columnWidth,\n unitComponent,\n unitComponentProps,\n showLabels,\n clipUnits,\n maxInternalColumns,\n unconformityLabels,\n }),\n h.if(showLabelColumn)(SectionLabelsColumn, {\n width: width - columnWidth,\n }),\n ]);\n}\n\nfunction SectionUnitsColumn(props: SectionSharedProps) {\n const {\n width,\n showLabels,\n unitComponent,\n unitComponentProps,\n clipUnits,\n maxInternalColumns,\n axisType,\n unconformityLabels = true,\n } = props;\n\n const { sections, totalHeight } = useMacrostratColumnData();\n\n const scaleData: PackageScaleLayoutData[] = sections.map((section) => {\n return section.scaleInfo;\n });\n\n const innerWidth = width - 2;\n\n return h(\"div.section-units-container\", { style: { width } }, [\n h(\n SVG,\n {\n className: \"sections\",\n height: totalHeight,\n innerWidth,\n paddingH: 1,\n },\n sections.map((group) => {\n const { units, scaleInfo, section_id } = group;\n\n const key = `section-${section_id}`;\n return h(\n SectionUnits,\n {\n units,\n scaleInfo,\n key,\n unitComponent,\n unitComponentProps,\n showLabels,\n width: innerWidth,\n clipUnits,\n maxInternalColumns,\n }, // This unconformity is with the section _above_\n );\n }),\n ),\n h.if(unconformityLabels)(UnconformityLabels, {\n width,\n sections: scaleData,\n verbose: false,\n }),\n ]);\n}\n\nfunction SectionUnits(props: SectionProps) {\n // Section with \"squishy\" timescale\n const {\n units,\n scaleInfo,\n unitComponent,\n showLabels = true,\n width = 300,\n unitComponentProps,\n className,\n clipUnits = true,\n maxInternalColumns,\n } = props;\n\n const { domain, pixelScale, pixelHeight, scale } = scaleInfo;\n\n /** Ensure that we can arrange units into the maximum number\n * of columns defined by unitComponentProps, but that we don't\n * use more than necessary.\n */\n const _unitComponentProps = useMemo(() => {\n return {\n ...unitComponentProps,\n nColumns: Math.min(\n maxInternalColumns ?? Math.floor(width / 10),\n unitComponentProps?.nColumns ?? Infinity,\n Math.max(...units.map((d) => d.column)) + 1,\n ),\n //axisType,\n };\n }, [units, unitComponentProps, maxInternalColumns, width]);\n\n const style = {\n \"--section-height\": `${pixelHeight}px`,\n \"--section-width\": `${width}px`,\n };\n\n return h(\n \"g.section\",\n { className, style, transform: `translate(0 ${scaleInfo.offset})` },\n h(\n MacrostratColumnProvider,\n {\n units,\n domain,\n pixelScale, // Actually pixels per myr,\n scale,\n },\n h(CompositeUnitsColumn, {\n width,\n showLabels,\n unitComponent,\n unitComponentProps: _unitComponentProps,\n clipToFrame: clipUnits,\n }),\n ),\n );\n}\n\ninterface CompositeTimescaleProps {\n levels?: [number, number] | number;\n unconformityLabels?: boolean;\n}\n\nexport function CompositeTimescale(props: CompositeTimescaleProps) {\n const { sections } = useMacrostratColumnData();\n const sectionScales = sections.map((section) => {\n return section.scaleInfo;\n });\n\n return h(CompositeTimescaleCore, {\n packages: sectionScales,\n ...props,\n });\n}\n\ntype CompositeTimescaleCoreProps = CompositeTimescaleProps & {\n packages: PackageScaleLayoutData[];\n};\n\nexport function CompositeTimescaleCore(props: CompositeTimescaleCoreProps) {\n const { levels = 3, packages, unconformityLabels = false } = props;\n\n // Use intervals from Macrostrat API\n const baseURL = useMacrostratBaseURL();\n const intervals = useMacrostratIntervals(baseURL);\n\n let _levels: [number, number];\n if (typeof levels === \"number\") {\n // If levels is a number, use the most common starting level\n _levels = [2, Math.max(2 + Math.min(levels, 5) - 1, 1)];\n } else {\n _levels = levels;\n }\n\n const nCols = _levels[1] - _levels[0] + 1;\n\n return h(\"div.timescale-column\", [\n h(\n \"div.timescales\",\n packages.map((group) => {\n const { pixelHeight, paddingTop, key, scale } = group;\n return h(\n \"div.timescale-container\",\n { style: { paddingTop, \"--timescale-level-count\": nCols }, key },\n [\n h(Timescale, {\n orientation: TimescaleOrientation.VERTICAL,\n length: pixelHeight,\n levels: _levels,\n absoluteAgeScale: true,\n showAgeAxis: false,\n scale,\n intervals,\n }),\n ],\n );\n }),\n ),\n h.if(unconformityLabels)(UnconformityLabels, {\n width: \"100%\",\n sections: packages,\n className: \"unconformity-labels\",\n axisType: ColumnAxisType.AGE,\n }),\n ]);\n}\n\nexport function UnconformityLabels(props: {\n width: string | number;\n sections: PackageScaleLayoutData[];\n axisType?: ColumnAxisType;\n className?: string;\n verbose?: boolean;\n}) {\n const { width, sections, className, axisType, verbose } = props;\n\n return h(\n \"div.unconformity-labels\",\n {\n style: {\n width,\n },\n className,\n },\n sections.map((scaleInfo, i) => {\n const lastGroup = sections[i - 1];\n const top = scaleInfo.offset - scaleInfo.paddingTop;\n const upperAge = lastGroup?.domain[0];\n const lowerAge = scaleInfo.domain[1];\n return h(Unconformity, {\n axisType,\n upperAge,\n lowerAge,\n style: {\n width,\n height: scaleInfo.paddingTop,\n top,\n },\n verbose,\n });\n }),\n );\n}\n\nfunction Unconformity({\n upperAge,\n lowerAge,\n style,\n axisType,\n verbose = false,\n}) {\n if (upperAge == null || lowerAge == null) {\n return null;\n }\n\n const ageGap = Math.abs(upperAge - lowerAge);\n\n let maximumFractionDigits = 0;\n\n let className: string = null;\n if (ageGap > 1000) {\n className = \"giga\";\n } else if (ageGap > 100) {\n className = \"mega\";\n } else if (ageGap > 10) {\n className = \"large\";\n } else if (ageGap < 1) {\n className = \"small\";\n maximumFractionDigits = 2;\n } else {\n maximumFractionDigits = 1;\n }\n\n let val: ReactNode;\n if (axisType === ColumnAxisType.DEPTH || axisType === ColumnAxisType.HEIGHT) {\n const _txt = ageGap.toLocaleString(\"en-US\", { maximumFractionDigits });\n val = h(Value, { value: _txt, unit: \"m\" });\n } else {\n val = h(Duration, { value: ageGap, maximumFractionDigits });\n }\n\n let prefix: ReactNode = null;\n if (verbose) {\n prefix = h([\" \", h(\"span.prefix\", \" gap\")]);\n }\n\n return h(\"div.unconformity\", { style, className }, [\n h(\"div.unconformity-inner\", h(\"div.unconformity-text\", [val, prefix])),\n ]);\n}\n"],"names":["hyper","styles","useMacrostratUnits","LabelTrackerProvider","SectionLabelsColumn","useMacrostratColumnData","SVG","useMemo","MacrostratColumnProvider","CompositeUnitsColumn","useMacrostratBaseURL","useMacrostratIntervals","Timescale","TimescaleOrientation","ColumnAxisType","Value","Duration"],"mappings":";;;;;;;;;;;;;;AAwBA,MAAM,IAAIA,WAAAA,QAAM,OAAOC,qBAAM;AAyBtB,SAAS,eAAe,OAA2B;AACxD,QAAM;AAAA,IACJ,qBAAqB;AAAA,IACrB;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,YAAY;AAAA,IACZ;AAAA,EAAA,IACE;AAEJ,QAAM,QAAQC,MAAAA,mBAAA;AAGd,QAAM,MAAM,MAAM,CAAC,GAAG;AAEtB,SAAO,EAAEC,UAAAA,sBAAsB,EAAE,OAAO,OAAO;AAAA,IAC7C,EAAE,oBAAoB;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,IACD,EAAE,GAAG,eAAe,EAAEC,+BAAqB;AAAA,MACzC,OAAO,QAAQ;AAAA,IAAA,CAChB;AAAA,EAAA,CACF;AACH;AAEA,SAAS,mBAAmB,OAA2B;AACrD,QA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AEA,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AACZ,GAAG;AACD,MAAI,YAAY,QAAQ,YAAY,MAAM;AACxC,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,KAAK,IAAI,WAAW,QAAQ;AAE3C,MAAI,wBAAwB;AAE5B,MAAI,YAAoB;AACxB,MAAI,SAAS,KAAM;AACjB,gBAAY;AAAA,EACd,WAAW,SAAS,KAAK;AACvB,gBAAY;AAAA,EACd,WAAW,SAAS,IAAI;AACtB,gBAAY;AAAA,EACd,WAAW,SAAS,GAAG;AACrB,gBAAY;AACZ,4BAAwB;AAAA,EAC1B,OAAO;AACL,4BAAwB;AAAA,EAC1B;AAEA,MAAI;AACJ,MAAI,aAAaA,iBAAAA,eAAe,SAAS,aAAaA,iBAAAA,eAAe,QAAQ;AAC3E,UAAM,OAAO,OAAO,eAAe,SAAS,EAAE,uBAAuB;AACrE,UAAM,EAAEC,sBAAO,EAAE,OAAO,MAAM,MAAM,KAAK;AAAA,EAC3C,OAAO;AACL,UAAM,EAAEC,SAAAA,UAAU,EAAE,OAAO,QAAQ,uBAAuB;AAAA,EAC5D;AAEA,MAAI,SAAoB;AACxB,MAAI,SAAS;AACX,aAAS,EAAE,CAAC,KAAK,EAAE,eAAe,MAAM,CAAC,CAAC;AAAA,EAC5C;AAEA,SAAO,EAAE,oBAAoB,EAAE,OAAO,aAAa;AAAA,IACjD,EAAE,0BAA0B,EAAE,yBAAyB,CAAC,KAAK,MAAM,CAAC,CAAC;AAAA,EAAA,CACtE;AACH;;;;;"}
|
package/dist/section.js
CHANGED
|
@@ -7,7 +7,7 @@ import { useMacrostratBaseURL } from "@macrostrat/data-provider";
|
|
|
7
7
|
import { Value } from "@macrostrat/data-components";
|
|
8
8
|
import { useMacrostratColumnData, useMacrostratUnits, MacrostratColumnProvider } from "./data-provider/store.js";
|
|
9
9
|
import { LabelTrackerProvider, SectionLabelsColumn, CompositeUnitsColumn } from "./units/composite.js";
|
|
10
|
-
import { Duration } from "./unit-details/
|
|
10
|
+
import { Duration } from "./unit-details/age-range.js";
|
|
11
11
|
const h = h$1.styled(h$2);
|
|
12
12
|
function SectionsColumn(props) {
|
|
13
13
|
const {
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const dataComponents = require("@macrostrat/data-components");
|
|
4
|
+
const dataProvider = require("@macrostrat/data-provider");
|
|
5
|
+
const ageRange_module = require("./age-range.module.sass.cjs");
|
|
6
|
+
const utils = require("./utils.cjs");
|
|
7
|
+
const classNames = require("classnames");
|
|
8
|
+
const React = require("react");
|
|
9
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
10
|
+
const classNames__default = /* @__PURE__ */ _interopDefault(classNames);
|
|
11
|
+
function AgeField({ unit, children, ...rest }) {
|
|
12
|
+
const [_b_age, _t_age, _unit] = getAgeRange(unit);
|
|
13
|
+
return ageRange_module.default(
|
|
14
|
+
dataComponents.DataField,
|
|
15
|
+
{
|
|
16
|
+
label: "Age",
|
|
17
|
+
value: utils.formatRange(_b_age, _t_age),
|
|
18
|
+
unit: _unit,
|
|
19
|
+
...rest
|
|
20
|
+
},
|
|
21
|
+
children
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
function AgeRange({
|
|
25
|
+
data,
|
|
26
|
+
className
|
|
27
|
+
}) {
|
|
28
|
+
const [_b_age, _t_age, _unit] = getAgeRange(data);
|
|
29
|
+
return ageRange_module.default(dataComponents.Value, {
|
|
30
|
+
value: utils.formatRange(_b_age, _t_age),
|
|
31
|
+
unit: _unit,
|
|
32
|
+
className
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function AgeLabel({
|
|
36
|
+
age,
|
|
37
|
+
maximumFractionDigits = 2,
|
|
38
|
+
minimumFractionDigits = 0,
|
|
39
|
+
className
|
|
40
|
+
}) {
|
|
41
|
+
const [value, unit] = getAge(age);
|
|
42
|
+
const _value = value.toLocaleString("en-US", {
|
|
43
|
+
maximumFractionDigits,
|
|
44
|
+
minimumFractionDigits
|
|
45
|
+
});
|
|
46
|
+
return ageRange_module.default(dataComponents.Value, { value: _value, unit, className });
|
|
47
|
+
}
|
|
48
|
+
function Duration({
|
|
49
|
+
value,
|
|
50
|
+
maximumFractionDigits = 2,
|
|
51
|
+
minimumFractionDigits = 0
|
|
52
|
+
}) {
|
|
53
|
+
let unit = "Myr";
|
|
54
|
+
if (value < 0.8) {
|
|
55
|
+
unit = "kyr";
|
|
56
|
+
value *= 1e3;
|
|
57
|
+
if (value < 5) {
|
|
58
|
+
unit = "yr";
|
|
59
|
+
value *= 1e3;
|
|
60
|
+
}
|
|
61
|
+
} else if (value > 1e3) {
|
|
62
|
+
unit = "Gyr";
|
|
63
|
+
value /= 1e3;
|
|
64
|
+
}
|
|
65
|
+
let _value = value.toLocaleString("en-US", {
|
|
66
|
+
maximumFractionDigits,
|
|
67
|
+
minimumFractionDigits
|
|
68
|
+
});
|
|
69
|
+
return ageRange_module.default(dataComponents.Value, { value: _value, unit });
|
|
70
|
+
}
|
|
71
|
+
function IntervalProportions({
|
|
72
|
+
unit,
|
|
73
|
+
className,
|
|
74
|
+
showProportions,
|
|
75
|
+
calculateProportionsFromAges = true,
|
|
76
|
+
...rest
|
|
77
|
+
}) {
|
|
78
|
+
if (unit.b_int_id == null && unit.t_int_id == null) return null;
|
|
79
|
+
let _showProps = showProportions;
|
|
80
|
+
const i0 = unit.b_int_id;
|
|
81
|
+
const i1 = unit.t_int_id;
|
|
82
|
+
const intervalMap = dataProvider.useMacrostratDefs("intervals");
|
|
83
|
+
const [int0, int1] = React.useMemo(() => {
|
|
84
|
+
const int02 = intervalMap?.get(i0) ?? {};
|
|
85
|
+
if (i0 === i1) {
|
|
86
|
+
return [int02, int02];
|
|
87
|
+
}
|
|
88
|
+
const int12 = intervalMap?.get(i1) ?? {};
|
|
89
|
+
return [int02, int12];
|
|
90
|
+
}, [intervalMap, i0, i1]);
|
|
91
|
+
const interval0 = {
|
|
92
|
+
id: i0,
|
|
93
|
+
name: unit.b_int_name,
|
|
94
|
+
...int0
|
|
95
|
+
};
|
|
96
|
+
let b_prop = unit.b_prop;
|
|
97
|
+
let t_prop = unit.t_prop;
|
|
98
|
+
if (b_prop == null && unit.b_age != null && calculateProportionsFromAges) {
|
|
99
|
+
b_prop = getProportion(unit.b_age, int0);
|
|
100
|
+
}
|
|
101
|
+
if (t_prop == null && unit.t_age != null && calculateProportionsFromAges) {
|
|
102
|
+
t_prop = getProportion(unit.t_age, int1);
|
|
103
|
+
}
|
|
104
|
+
if (b_prop == null && t_prop == null) {
|
|
105
|
+
_showProps ??= false;
|
|
106
|
+
}
|
|
107
|
+
b_prop ??= 0;
|
|
108
|
+
t_prop ??= 1;
|
|
109
|
+
let p0 = null;
|
|
110
|
+
let p1 = null;
|
|
111
|
+
if (_showProps !== false) {
|
|
112
|
+
p1 = ageRange_module.default(Proportion, { value: t_prop });
|
|
113
|
+
if (i0 !== i1 || b_prop !== 0 || t_prop !== 1) {
|
|
114
|
+
p0 = ageRange_module.default(Proportion, { value: b_prop });
|
|
115
|
+
}
|
|
116
|
+
if (i0 === i1 && (b_prop !== 0 || t_prop !== 1)) {
|
|
117
|
+
p0 = ageRange_module.default("span.joint-proportion", [p0, " ", ageRange_module.default("span.sep", "to"), " ", p1]);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return ageRange_module.default(
|
|
121
|
+
dataComponents.ItemList,
|
|
122
|
+
{ className: classNames__default.default("interval-proportions", className) },
|
|
123
|
+
[
|
|
124
|
+
ageRange_module.default(dataComponents.IntervalTag, {
|
|
125
|
+
interval: interval0,
|
|
126
|
+
prefix: p0,
|
|
127
|
+
...rest
|
|
128
|
+
}),
|
|
129
|
+
ageRange_module.default.if(i0 != i1)("span.discourage-break", [
|
|
130
|
+
ageRange_module.default("span.sep", " to "),
|
|
131
|
+
ageRange_module.default(dataComponents.IntervalTag, {
|
|
132
|
+
interval: {
|
|
133
|
+
id: i1,
|
|
134
|
+
name: unit.t_int_name,
|
|
135
|
+
...int1
|
|
136
|
+
},
|
|
137
|
+
prefix: p1,
|
|
138
|
+
...rest
|
|
139
|
+
})
|
|
140
|
+
])
|
|
141
|
+
]
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
function getProportion(age, interval) {
|
|
145
|
+
console.log(age, interval);
|
|
146
|
+
return (interval.b_age - age) / (interval.b_age - interval.t_age);
|
|
147
|
+
}
|
|
148
|
+
function Proportion({ value }) {
|
|
149
|
+
let content = null;
|
|
150
|
+
if (value == 0) {
|
|
151
|
+
content = "base";
|
|
152
|
+
} else if (value == 1) {
|
|
153
|
+
content = "top";
|
|
154
|
+
} else {
|
|
155
|
+
content = utils.formatProportion(value * 100) + "%";
|
|
156
|
+
}
|
|
157
|
+
return ageRange_module.default("span.proportion", content);
|
|
158
|
+
}
|
|
159
|
+
function getAgeRange(_unit) {
|
|
160
|
+
let b_age = _unit.b_age;
|
|
161
|
+
let t_age = _unit.t_age;
|
|
162
|
+
let unit = "Ma";
|
|
163
|
+
if (b_age < 0.8 && t_age < 1.2) {
|
|
164
|
+
b_age *= 1e3;
|
|
165
|
+
t_age *= 1e3;
|
|
166
|
+
unit = "ka";
|
|
167
|
+
} else if (b_age > 800 && t_age > 1200) {
|
|
168
|
+
b_age /= 1e3;
|
|
169
|
+
t_age /= 1e3;
|
|
170
|
+
unit = "Ga";
|
|
171
|
+
}
|
|
172
|
+
return [b_age, t_age, unit];
|
|
173
|
+
}
|
|
174
|
+
function getAge(value) {
|
|
175
|
+
let unit = "Ma";
|
|
176
|
+
if (value < 0.8) {
|
|
177
|
+
unit = "ka";
|
|
178
|
+
value *= 1e3;
|
|
179
|
+
if (value < 5) {
|
|
180
|
+
unit = "yr";
|
|
181
|
+
value *= 1e3;
|
|
182
|
+
}
|
|
183
|
+
} else if (value > 1e3) {
|
|
184
|
+
unit = "Ga";
|
|
185
|
+
value /= 1e3;
|
|
186
|
+
}
|
|
187
|
+
return [value, unit];
|
|
188
|
+
}
|
|
189
|
+
exports.AgeField = AgeField;
|
|
190
|
+
exports.AgeLabel = AgeLabel;
|
|
191
|
+
exports.AgeRange = AgeRange;
|
|
192
|
+
exports.Duration = Duration;
|
|
193
|
+
exports.IntervalProportions = IntervalProportions;
|
|
194
|
+
exports.getAge = getAge;
|
|
195
|
+
exports.getAgeRange = getAgeRange;
|
|
196
|
+
//# sourceMappingURL=age-range.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"age-range.cjs","sources":["../../src/unit-details/age-range.ts"],"sourcesContent":["import {\n DataField,\n IntervalShort,\n IntervalTag,\n type IntervalTagProps,\n ItemList,\n Value,\n} from \"@macrostrat/data-components\";\nimport { useMacrostratDefs } from \"@macrostrat/data-provider\";\nimport h from \"./age-range.module.sass\";\nimport { formatProportion, formatRange } from \"./utils\";\nimport classNames from \"classnames\";\nimport { useMemo } from \"react\";\n\nexport function AgeField({ unit, children, ...rest }) {\n const [_b_age, _t_age, _unit] = getAgeRange(unit);\n\n return h(\n DataField,\n {\n label: \"Age\",\n value: formatRange(_b_age, _t_age),\n unit: _unit,\n ...rest,\n },\n children,\n );\n}\n\nexport function AgeRange({\n data,\n className,\n}: {\n data: {\n t_age: number;\n b_age: number;\n };\n className?: string;\n}) {\n const [_b_age, _t_age, _unit] = getAgeRange(data);\n\n return h(Value, {\n value: formatRange(_b_age, _t_age),\n unit: _unit,\n className,\n });\n}\n\nexport function AgeLabel({\n age,\n maximumFractionDigits = 2,\n minimumFractionDigits = 0,\n className,\n}: {\n age: number;\n className?: string;\n maximumFractionDigits?: number;\n minimumFractionDigits?: number;\n}) {\n /** Component to display a single age value with unit conversion from\n * Ma to ka or Ga as appropriate.\n */\n const [value, unit] = getAge(age);\n\n const _value = value.toLocaleString(\"en-US\", {\n maximumFractionDigits,\n minimumFractionDigits,\n });\n\n return h(Value, { value: _value, unit, className });\n}\n\nexport function Duration({\n value,\n maximumFractionDigits = 2,\n minimumFractionDigits = 0,\n}) {\n let unit = \"Myr\";\n if (value < 0.8) {\n unit = \"kyr\";\n value *= 1000;\n if (value < 5) {\n unit = \"yr\";\n value *= 1000;\n }\n } else if (value > 1000) {\n unit = \"Gyr\";\n value /= 1000;\n }\n\n let _value = value.toLocaleString(\"en-US\", {\n maximumFractionDigits,\n minimumFractionDigits,\n });\n\n return h(Value, { value: _value, unit });\n}\n\ninterface UnitIntervalConstraints {\n b_int_id?: number;\n t_int_id?: number;\n b_prop?: number;\n t_prop?: number;\n b_int_name?: string;\n t_int_name?: string;\n b_age?: number;\n t_age?: number;\n}\n\nexport interface IntervalProportionsProps extends Omit<\n IntervalTagProps,\n \"interval\"\n> {\n unit: UnitIntervalConstraints;\n showProportions?: boolean;\n calculateProportionsFromAges?: boolean;\n}\n\nexport function IntervalProportions({\n unit,\n className,\n showProportions,\n calculateProportionsFromAges = true,\n ...rest\n}: IntervalProportionsProps) {\n /** Display the proportions of the unit that belong to the base and top intervals, if they are different */\n if (unit.b_int_id == null && unit.t_int_id == null) return null;\n\n let _showProps = showProportions;\n\n const i0 = unit.b_int_id;\n const i1 = unit.t_int_id;\n\n /** Get interval information */\n const intervalMap = useMacrostratDefs(\"intervals\");\n const [int0, int1] = useMemo(() => {\n const int0 = intervalMap?.get(i0) ?? {};\n if (i0 === i1) {\n return [int0, int0];\n }\n const int1 = intervalMap?.get(i1) ?? {};\n return [int0, int1];\n }, [intervalMap, i0, i1]);\n\n const interval0: IntervalShort = {\n id: i0,\n name: unit.b_int_name,\n ...int0,\n };\n\n let b_prop = unit.b_prop;\n let t_prop = unit.t_prop;\n\n // If we have b_age and t_age, then we can calculate proportions if they are not given\n if (b_prop == null && unit.b_age != null && calculateProportionsFromAges) {\n b_prop = getProportion(unit.b_age, int0);\n }\n if (t_prop == null && unit.t_age != null && calculateProportionsFromAges) {\n t_prop = getProportion(unit.t_age, int1);\n }\n\n // If there are no proportions given and we are not explicitly directed to show them,\n // then we set them to hidden.\n if (b_prop == null && t_prop == null) {\n _showProps ??= false;\n }\n\n /*\n Set default proportions to 0 and 1 if they are not given,\n so that we can display \"base\" and \"top\" labels\n */\n b_prop ??= 0;\n t_prop ??= 1;\n\n let p0: any = null;\n let p1: any = null;\n\n if (_showProps !== false) {\n p1 = h(Proportion, { value: t_prop });\n\n if (i0 !== i1 || b_prop !== 0 || t_prop !== 1) {\n // We have a single interval with undefined proportions\n p0 = h(Proportion, { value: b_prop });\n }\n\n if (i0 === i1 && (b_prop !== 0 || t_prop !== 1)) {\n p0 = h(\"span.joint-proportion\", [p0, \" \", h(\"span.sep\", \"to\"), \" \", p1]);\n }\n }\n\n return h(\n ItemList,\n { className: classNames(\"interval-proportions\", className) },\n [\n h(IntervalTag, {\n interval: interval0,\n prefix: p0,\n ...rest,\n }),\n h.if(i0 != i1)(\"span.discourage-break\", [\n h(\"span.sep\", \" to \"),\n h(IntervalTag, {\n interval: {\n id: i1,\n name: unit.t_int_name,\n ...int1,\n },\n prefix: p1,\n ...rest,\n }),\n ]),\n ],\n );\n}\n\nfunction getProportion(age: number, interval: IntervalShort): number | null {\n /** Get proportion with the age */\n console.log(age, interval);\n return (interval.b_age - age) / (interval.b_age - interval.t_age);\n}\n\nfunction Proportion({ value }) {\n let content = null;\n if (value == 0) {\n content = \"base\";\n } else if (value == 1) {\n content = \"top\";\n } else {\n content = formatProportion(value * 100) + \"%\";\n }\n\n return h(\"span.proportion\", content);\n}\n\nexport function getAgeRange(_unit) {\n let b_age = _unit.b_age;\n let t_age = _unit.t_age;\n let unit = \"Ma\";\n\n if (b_age < 0.8 && t_age < 1.2) {\n b_age *= 1000;\n t_age *= 1000;\n unit = \"ka\";\n } else if (b_age > 800 && t_age > 1200) {\n b_age /= 1000;\n t_age /= 1000;\n unit = \"Ga\";\n }\n\n return [b_age, t_age, unit];\n}\n\nexport function getAge(value) {\n /** Get the age value in Ma, ka, or Ga as appropriate */\n let unit = \"Ma\";\n if (value < 0.8) {\n unit = \"ka\";\n value *= 1000;\n if (value < 5) {\n unit = \"yr\";\n value *= 1000;\n }\n } else if (value > 1000) {\n unit = \"Ga\";\n value /= 1000;\n }\n\n return [value, unit];\n}\n"],"names":["h","DataField","formatRange","Value","useMacrostratDefs","useMemo","int0","int1","ItemList","classNames","IntervalTag","formatProportion"],"mappings":";;;;;;;;;;AAcO,SAAS,SAAS,EAAE,MAAM,UAAU,GAAG,QAAQ;AACpD,QAAM,CAAC,QAAQ,QAAQ,KAAK,IAAI,YAAY,IAAI;AAEhD,SAAOA,gBAAAA;AAAAA,IACLC,eAAAA;AAAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,OAAOC,MAAAA,YAAY,QAAQ,MAAM;AAAA,MACjC,MAAM;AAAA,MACN,GAAG;AAAA,IAAA;AAAA,IAEL;AAAA,EAAA;AAEJ;AAEO,SAAS,SAAS;AAAA,EACvB;AAAA,EACA;AACF,GAMG;AACD,QAAM,CAAC,QAAQ,QAAQ,KAAK,IAAI,YAAY,IAAI;AAEhD,SAAOF,gBAAAA,QAAEG,eAAAA,OAAO;AAAA,IACd,OAAOD,MAAAA,YAAY,QAAQ,MAAM;AAAA,IACjC,MAAM;AAAA,IACN;AAAA,EAAA,CACD;AACH;AAEO,SAAS,SAAS;AAAA,EACvB;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB;AACF,GAKG;AAID,QAAM,CAAC,OAAO,IAAI,IAAI,OAAO,GAAG;AAEhC,QAAM,SAAS,MAAM,eAAe,SAAS;AAAA,IAC3C;AAAA,IACA;AAAA,EAAA,CACD;AAED,SAAOF,gBAAAA,QAAEG,eAAAA,OAAO,EAAE,OAAO,QAAQ,MAAM,WAAW;AACpD;AAEO,SAAS,SAAS;AAAA,EACvB;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAC1B,GAAG;AACD,MAAI,OAAO;AACX,MAAI,QAAQ,KAAK;AACf,WAAO;AACP,aAAS;AACT,QAAI,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A,EACZ,OAAO;AACL,cAAUC,MAAAA,iBAAiB,QAAQ,GAAG,IAAI;AAAA,EAC5C;AAEA,SAAOX,gBAAAA,QAAE,mBAAmB,OAAO;AACrC;AAEO,SAAS,YAAY,OAAO;AACjC,MAAI,QAAQ,MAAM;AAClB,MAAI,QAAQ,MAAM;AAClB,MAAI,OAAO;AAEX,MAAI,QAAQ,OAAO,QAAQ,KAAK;AAC9B,aAAS;AACT,aAAS;AACT,WAAO;AAAA,EACT,WAAW,QAAQ,OAAO,QAAQ,MAAM;AACtC,aAAS;AACT,aAAS;AACT,WAAO;AAAA,EACT;AAEA,SAAO,CAAC,OAAO,OAAO,IAAI;AAC5B;AAEO,SAAS,OAAO,OAAO;AAE5B,MAAI,OAAO;AACX,MAAI,QAAQ,KAAK;AACf,WAAO;AACP,aAAS;AACT,QAAI,QAAQ,GAAG;AACb,aAAO;AACP,eAAS;AAAA,IACX;AAAA,EACF,WAAW,QAAQ,KAAM;AACvB,WAAO;AACP,aAAS;AAAA,EACX;AAEA,SAAO,CAAC,OAAO,IAAI;AACrB;;;;;;;;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { IntervalTagProps } from '@macrostrat/data-components';
|
|
2
|
+
export declare function AgeField({ unit, children, ...rest }: {
|
|
3
|
+
[x: string]: any;
|
|
4
|
+
unit: any;
|
|
5
|
+
children: any;
|
|
6
|
+
}): import('react').FunctionComponentElement<{
|
|
7
|
+
label?: string;
|
|
8
|
+
value?: any;
|
|
9
|
+
inline?: boolean;
|
|
10
|
+
showIfEmpty?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
children?: any;
|
|
13
|
+
unit?: string;
|
|
14
|
+
row?: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function AgeRange({ data, className, }: {
|
|
17
|
+
data: {
|
|
18
|
+
t_age: number;
|
|
19
|
+
b_age: number;
|
|
20
|
+
};
|
|
21
|
+
className?: string;
|
|
22
|
+
}): import('react').FunctionComponentElement<{
|
|
23
|
+
value?: any;
|
|
24
|
+
unit?: string;
|
|
25
|
+
children?: any;
|
|
26
|
+
className?: string;
|
|
27
|
+
}>;
|
|
28
|
+
export declare function AgeLabel({ age, maximumFractionDigits, minimumFractionDigits, className, }: {
|
|
29
|
+
age: number;
|
|
30
|
+
className?: string;
|
|
31
|
+
maximumFractionDigits?: number;
|
|
32
|
+
minimumFractionDigits?: number;
|
|
33
|
+
}): import('react').FunctionComponentElement<{
|
|
34
|
+
value?: any;
|
|
35
|
+
unit?: string;
|
|
36
|
+
children?: any;
|
|
37
|
+
className?: string;
|
|
38
|
+
}>;
|
|
39
|
+
export declare function Duration({ value, maximumFractionDigits, minimumFractionDigits, }: {
|
|
40
|
+
value: any;
|
|
41
|
+
maximumFractionDigits?: number;
|
|
42
|
+
minimumFractionDigits?: number;
|
|
43
|
+
}): import('react').FunctionComponentElement<{
|
|
44
|
+
value?: any;
|
|
45
|
+
unit?: string;
|
|
46
|
+
children?: any;
|
|
47
|
+
className?: string;
|
|
48
|
+
}>;
|
|
49
|
+
interface UnitIntervalConstraints {
|
|
50
|
+
b_int_id?: number;
|
|
51
|
+
t_int_id?: number;
|
|
52
|
+
b_prop?: number;
|
|
53
|
+
t_prop?: number;
|
|
54
|
+
b_int_name?: string;
|
|
55
|
+
t_int_name?: string;
|
|
56
|
+
b_age?: number;
|
|
57
|
+
t_age?: number;
|
|
58
|
+
}
|
|
59
|
+
export interface IntervalProportionsProps extends Omit<IntervalTagProps, "interval"> {
|
|
60
|
+
unit: UnitIntervalConstraints;
|
|
61
|
+
showProportions?: boolean;
|
|
62
|
+
calculateProportionsFromAges?: boolean;
|
|
63
|
+
}
|
|
64
|
+
export declare function IntervalProportions({ unit, className, showProportions, calculateProportionsFromAges, ...rest }: IntervalProportionsProps): import('react').FunctionComponentElement<{
|
|
65
|
+
children?: import('react').ReactNode;
|
|
66
|
+
className: string;
|
|
67
|
+
}>;
|
|
68
|
+
export declare function getAgeRange(_unit: any): any[];
|
|
69
|
+
export declare function getAge(value: any): any[];
|
|
70
|
+
export {};
|