@macrostrat/column-views 3.3.5 → 3.4.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 +37 -0
- package/dist/column.cjs +2 -1
- package/dist/column.cjs.map +1 -1
- package/dist/column.js +2 -1
- package/dist/column.js.map +1 -1
- package/dist/data-provider/unit-selection.cjs +7 -3
- package/dist/data-provider/unit-selection.cjs.map +1 -1
- package/dist/data-provider/unit-selection.d.ts +1 -0
- package/dist/data-provider/unit-selection.js +7 -3
- package/dist/data-provider/unit-selection.js.map +1 -1
- package/dist/index.cjs +13 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/prepare-units/helpers.cjs +83 -49
- package/dist/prepare-units/helpers.cjs.map +1 -1
- package/dist/prepare-units/helpers.d.ts +19 -2
- package/dist/prepare-units/helpers.js +84 -50
- package/dist/prepare-units/helpers.js.map +1 -1
- package/dist/prepare-units/index.cjs.map +1 -1
- package/dist/prepare-units/index.js.map +1 -1
- package/dist/section.cjs +1 -2
- package/dist/section.cjs.map +1 -1
- package/dist/section.js +1 -2
- package/dist/section.js.map +1 -1
- package/dist/unit-details/identifiers.cjs +56 -0
- package/dist/unit-details/identifiers.cjs.map +1 -0
- package/dist/unit-details/identifiers.d.ts +31 -0
- package/dist/unit-details/identifiers.js +54 -0
- package/dist/unit-details/identifiers.js.map +1 -0
- package/dist/unit-details/index.d.ts +2 -0
- package/dist/unit-details/panel.cjs +11 -88
- package/dist/unit-details/panel.cjs.map +1 -1
- package/dist/unit-details/panel.d.ts +3 -19
- package/dist/unit-details/panel.js +10 -87
- package/dist/unit-details/panel.js.map +1 -1
- package/dist/unit-details/popover.cjs +1 -2
- package/dist/unit-details/popover.cjs.map +1 -1
- package/dist/unit-details/popover.js +2 -3
- package/dist/unit-details/popover.js.map +1 -1
- package/dist/unit-details/strat-names.cjs +44 -0
- package/dist/unit-details/strat-names.cjs.map +1 -0
- package/dist/unit-details/strat-names.d.ts +14 -0
- package/dist/unit-details/strat-names.js +42 -0
- package/dist/unit-details/strat-names.js.map +1 -0
- package/dist/units/index.cjs +20 -6
- package/dist/units/index.cjs.map +1 -1
- package/dist/units/index.d.ts +11 -20
- package/dist/units/index.js +20 -6
- package/dist/units/index.js.map +1 -1
- package/package.json +14 -14
- package/src/column.ts +1 -1
- package/src/data-provider/unit-selection.ts +8 -4
- package/src/prepare-units/helpers.ts +121 -72
- package/src/prepare-units/index.ts +1 -1
- package/src/section.ts +0 -1
- package/src/unit-details/identifiers.ts +67 -0
- package/src/unit-details/index.ts +2 -0
- package/src/unit-details/panel.ts +13 -126
- package/src/unit-details/popover.ts +2 -7
- package/src/unit-details/strat-names.ts +57 -0
- package/src/units/index.ts +31 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { LithologyTagFeature, MacrostratInteractionManager } from '@macrostrat/data-components';
|
|
3
3
|
import { Environment, Interval, Lithology, UnitLong } from '@macrostrat/api-types';
|
|
4
4
|
export interface UnitDetailsPanelProps {
|
|
5
5
|
unit: any;
|
|
@@ -12,8 +12,9 @@ export interface UnitDetailsPanelProps {
|
|
|
12
12
|
onSelectUnit?: (unitID: number) => void;
|
|
13
13
|
onClickItem?: MacrostratItemClickHandler;
|
|
14
14
|
interactionManager?: MacrostratInteractionManager;
|
|
15
|
+
showJSON?: boolean;
|
|
15
16
|
}
|
|
16
|
-
export declare function UnitDetailsPanel({ unit, onClose, className, features, lithologyFeatures, actions, hiddenActions, onSelectUnit, onClickItem, }: UnitDetailsPanelProps): import('react').ReactElement<{
|
|
17
|
+
export declare function UnitDetailsPanel({ unit, onClose, className, features, lithologyFeatures, actions, hiddenActions, onSelectUnit, onClickItem, showJSON, }: UnitDetailsPanelProps): import('react').ReactElement<{
|
|
17
18
|
className: string | undefined;
|
|
18
19
|
}, string | import('react').JSXElementConstructor<any>> | import('react').FunctionComponentElement<import('@macrostrat/data-components').InteractionManagerOptions & {
|
|
19
20
|
children: ReactNode;
|
|
@@ -64,20 +65,3 @@ export declare function ThicknessField({ unit, label }: {
|
|
|
64
65
|
unit?: string;
|
|
65
66
|
row?: boolean;
|
|
66
67
|
}>;
|
|
67
|
-
export declare function ClickableText({ className, ...rest }: {
|
|
68
|
-
className?: string;
|
|
69
|
-
children: ReactNode;
|
|
70
|
-
} & ItemInteractionProps): import('react').ReactElement<{
|
|
71
|
-
children: ReactNode;
|
|
72
|
-
href?: string | null;
|
|
73
|
-
target?: string;
|
|
74
|
-
onClick?: (event: MouseEvent) => void;
|
|
75
|
-
className: string;
|
|
76
|
-
}, string | import('react').JSXElementConstructor<any>>;
|
|
77
|
-
export declare function Identifier({ id, className, ...rest }: {
|
|
78
|
-
id: number | string;
|
|
79
|
-
className?: string;
|
|
80
|
-
} & ItemInteractionProps): import('react').FunctionComponentElement<{
|
|
81
|
-
className?: string;
|
|
82
|
-
children: ReactNode;
|
|
83
|
-
} & ItemInteractionProps>;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { JSONView } from "@macrostrat/ui-components";
|
|
2
2
|
import { ButtonGroup, Button } from "@blueprintjs/core";
|
|
3
3
|
import { useState, useMemo } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import { useMacrostratData, useMacrostratDefs, useMacrostratColumnInfo
|
|
4
|
+
import { DataField, MacrostratInteractionProvider, Parenthetical, Value, LithologyList, EnvironmentsList, LithologyTagFeature, useInteractionManager, ItemList } from "@macrostrat/data-components";
|
|
5
|
+
import { useMacrostratData, useMacrostratDefs, useMacrostratColumnInfo } from "@macrostrat/data-provider";
|
|
6
6
|
import { defaultNameFunction } from "../units/names.js";
|
|
7
7
|
import classNames from "classnames";
|
|
8
8
|
import { AgeField, Duration, IntervalProportions } from "./age-range.js";
|
|
9
9
|
import { formatSignificance, formatRange } from "./utils.js";
|
|
10
10
|
import h from "./panel.module.sass.js";
|
|
11
|
+
import { StratNameField } from "./strat-names.js";
|
|
12
|
+
import { Identifier, UnitIdentifier } from "./identifiers.js";
|
|
11
13
|
import { useColumnUnitsMap } from "../data-provider/store.js";
|
|
12
14
|
function UnitDetailsPanel({
|
|
13
15
|
unit,
|
|
@@ -24,11 +26,12 @@ function UnitDetailsPanel({
|
|
|
24
26
|
actions,
|
|
25
27
|
hiddenActions = null,
|
|
26
28
|
onSelectUnit,
|
|
27
|
-
onClickItem
|
|
29
|
+
onClickItem,
|
|
30
|
+
showJSON
|
|
28
31
|
}) {
|
|
29
|
-
const [
|
|
32
|
+
const [_showJSON, setShowJSON] = useState(false);
|
|
30
33
|
let content = null;
|
|
31
|
-
if (showJSON) {
|
|
34
|
+
if (showJSON ?? _showJSON) {
|
|
32
35
|
content = h(JSONView, { data: unit, showRoot: false });
|
|
33
36
|
} else {
|
|
34
37
|
content = h(UnitDetailsContent, {
|
|
@@ -69,7 +72,7 @@ function UnitDetailsPanel({
|
|
|
69
72
|
h("div.unit-details-content-holder", content)
|
|
70
73
|
]);
|
|
71
74
|
const clickHandlerForItem = useMemo(() => {
|
|
72
|
-
if (onSelectUnit == null
|
|
75
|
+
if (onSelectUnit == null && onClickItem == null) return null;
|
|
73
76
|
return (item) => {
|
|
74
77
|
if ("unit_id" in item && !("col_id" in item)) {
|
|
75
78
|
return (event) => {
|
|
@@ -288,39 +291,6 @@ function ReferencesField({ refs, className = null, ...rest }) {
|
|
|
288
291
|
h(BibInfo, { refs })
|
|
289
292
|
);
|
|
290
293
|
}
|
|
291
|
-
function useStratNameData(strat_name_id) {
|
|
292
|
-
const stratNames = useStratNames([strat_name_id]);
|
|
293
|
-
return stratNames?.[0];
|
|
294
|
-
}
|
|
295
|
-
function StratNameField(props) {
|
|
296
|
-
const { strat_name_id, className, ...rest } = props;
|
|
297
|
-
const data = useStratNameData(strat_name_id);
|
|
298
|
-
const baseInteractionProps = useInteractionProps({ strat_name_id });
|
|
299
|
-
const coreProps = {
|
|
300
|
-
...baseInteractionProps,
|
|
301
|
-
...rest
|
|
302
|
-
};
|
|
303
|
-
let inner = h(Identifier, { id: strat_name_id });
|
|
304
|
-
const name = data?.strat_name_long;
|
|
305
|
-
if (name != null) {
|
|
306
|
-
inner = h("span.strat-name", name);
|
|
307
|
-
}
|
|
308
|
-
const clickable = isClickable(coreProps);
|
|
309
|
-
return h(
|
|
310
|
-
DataField,
|
|
311
|
-
{
|
|
312
|
-
label: "Stratigraphic name"
|
|
313
|
-
},
|
|
314
|
-
h(
|
|
315
|
-
clickable ? "a" : "span",
|
|
316
|
-
{
|
|
317
|
-
className: classNames({ clickable }, className),
|
|
318
|
-
...coreProps
|
|
319
|
-
},
|
|
320
|
-
inner
|
|
321
|
-
)
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
294
|
function getThickness(unit) {
|
|
325
295
|
let minThickness = unit.min_thick ?? 0;
|
|
326
296
|
let maxThickness = unit.max_thick ?? unit.min_thick ?? 0;
|
|
@@ -396,28 +366,6 @@ function enhanceLithologies(lithologies, lithMap) {
|
|
|
396
366
|
};
|
|
397
367
|
});
|
|
398
368
|
}
|
|
399
|
-
function ClickableText({
|
|
400
|
-
className,
|
|
401
|
-
...rest
|
|
402
|
-
}) {
|
|
403
|
-
const clickable = isClickable(rest);
|
|
404
|
-
const tag = clickable ? "a" : "span";
|
|
405
|
-
return h(tag, { className: classNames(className, { clickable }), ...rest });
|
|
406
|
-
}
|
|
407
|
-
function Identifier({
|
|
408
|
-
id,
|
|
409
|
-
className,
|
|
410
|
-
...rest
|
|
411
|
-
}) {
|
|
412
|
-
return h(
|
|
413
|
-
ClickableText,
|
|
414
|
-
{
|
|
415
|
-
className: classNames("identifier", className),
|
|
416
|
-
...rest
|
|
417
|
-
},
|
|
418
|
-
id
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
369
|
function UnitIDList({ units, showNames = false }) {
|
|
422
370
|
const unitsMap = useColumnUnitsMap();
|
|
423
371
|
const interactionManager = useInteractionManager();
|
|
@@ -426,7 +374,7 @@ function UnitIDList({ units, showNames = false }) {
|
|
|
426
374
|
if (showNames) {
|
|
427
375
|
return u1.map((unitID) => {
|
|
428
376
|
const unitData = unitsMap?.get(unitID);
|
|
429
|
-
let name =
|
|
377
|
+
let name = null;
|
|
430
378
|
if (unitData != null) {
|
|
431
379
|
name = defaultNameFunction(unitData);
|
|
432
380
|
}
|
|
@@ -459,32 +407,7 @@ function UnitIDList({ units, showNames = false }) {
|
|
|
459
407
|
})
|
|
460
408
|
);
|
|
461
409
|
}
|
|
462
|
-
function UnitIdentifier({
|
|
463
|
-
unitID,
|
|
464
|
-
colID,
|
|
465
|
-
name,
|
|
466
|
-
...interactionProps
|
|
467
|
-
}) {
|
|
468
|
-
if (name != null) {
|
|
469
|
-
return h(
|
|
470
|
-
ClickableText,
|
|
471
|
-
{
|
|
472
|
-
className: "unit-name",
|
|
473
|
-
...interactionProps
|
|
474
|
-
},
|
|
475
|
-
name
|
|
476
|
-
);
|
|
477
|
-
}
|
|
478
|
-
return h(Identifier, {
|
|
479
|
-
className: "unit-id",
|
|
480
|
-
key: unitID,
|
|
481
|
-
id: unitID,
|
|
482
|
-
...interactionProps
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
410
|
export {
|
|
486
|
-
ClickableText,
|
|
487
|
-
Identifier,
|
|
488
411
|
LegendPanelHeader,
|
|
489
412
|
ReferencesField,
|
|
490
413
|
ThicknessField,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel.js","sources":["../../src/unit-details/panel.ts"],"sourcesContent":["import { JSONView } from \"@macrostrat/ui-components\";\nimport { Button, ButtonGroup } from \"@blueprintjs/core\";\nimport { ReactNode, useMemo, useState } from \"react\";\nimport {\n DataField,\n EnvironmentsList,\n isClickable,\n ItemInteractionProps,\n ItemList,\n LithologyList,\n LithologyTagFeature,\n MacrostratInteractionManager,\n MacrostratInteractionProvider,\n MacrostratItemIdentifier,\n Parenthetical,\n useInteractionManager,\n useInteractionProps,\n Value,\n} from \"@macrostrat/data-components\";\nimport { useColumnUnitsMap } from \"../data-provider\";\nimport {\n useMacrostratColumnInfo,\n useMacrostratData,\n useMacrostratDefs,\n useStratNames,\n} from \"@macrostrat/data-provider\";\nimport type {\n Environment,\n Interval,\n Lithology,\n UnitLithology,\n UnitLong,\n UnitLongFull,\n} from \"@macrostrat/api-types\";\nimport { defaultNameFunction } from \"../units/names\";\nimport classNames from \"classnames\";\nimport { AgeField, Duration, IntervalProportions } from \"./age-range\";\nimport { formatRange, formatSignificance } from \"./utils.ts\";\nimport h from \"./panel.module.sass\";\n\nexport interface UnitDetailsPanelProps {\n unit: any;\n onClose?: any;\n className?: string;\n actions?: ReactNode;\n hiddenActions?: ReactNode;\n features?: Set<UnitDetailsFeature>;\n lithologyFeatures?: Set<LithologyTagFeature>;\n onSelectUnit?: (unitID: number) => void;\n onClickItem?: MacrostratItemClickHandler;\n interactionManager?: MacrostratInteractionManager;\n}\n\nexport function UnitDetailsPanel({\n unit,\n onClose,\n className,\n features = new Set<UnitDetailsFeature>([\n UnitDetailsFeature.AdjacentUnits,\n UnitDetailsFeature.OutcropType,\n UnitDetailsFeature.JSONToggle,\n UnitDetailsFeature.DepthRange,\n ]),\n lithologyFeatures,\n actions,\n hiddenActions = null,\n onSelectUnit,\n onClickItem,\n}: UnitDetailsPanelProps) {\n const [showJSON, setShowJSON] = useState(false);\n\n let content: ReactNode = null;\n if (showJSON) {\n content = h(JSONView, { data: unit, showRoot: false });\n } else {\n content = h(UnitDetailsContent, {\n unit,\n features,\n lithologyFeatures,\n onClickItem,\n });\n }\n\n let title = defaultNameFunction(unit);\n\n if (features.has(UnitDetailsFeature.JSONToggle)) {\n hiddenActions = h([\n h(Button, {\n icon: \"code\",\n small: true,\n minimal: true,\n key: \"json-view-toggle\",\n className: classNames(\"json-view-toggle\", { enabled: setShowJSON }),\n onClick(evt) {\n setShowJSON(!showJSON);\n evt.stopPropagation();\n },\n }),\n hiddenActions,\n ]);\n }\n\n const main = h(\"div.unit-details-panel\", { className }, [\n h(LegendPanelHeader, {\n onClose,\n title,\n id: unit.unit_id,\n actions,\n hiddenActions,\n }),\n h(\"div.unit-details-content-holder\", content),\n ]);\n\n /** Handle unit selection clicks */\n const clickHandlerForItem = useMemo(() => {\n if (onSelectUnit == null || onClickItem == null) return null;\n return (item: MacrostratItemIdentifier) => {\n if (\"unit_id\" in item && !(\"col_id\" in item)) {\n // We are selecting a unit within the column\n return (event: MouseEvent) => {\n if (onSelectUnit != null) {\n onSelectUnit(item.unit_id);\n } else if (onClickItem != null) {\n console.warn(\n \"Unit selection: onClickItem is defined but onSelectUnit is not; ignoring click\",\n );\n }\n // Don't allow event to propagate further (e.g., to open a link)\n event.preventDefault();\n };\n }\n return undefined;\n };\n }, [onSelectUnit, onClickItem]);\n\n if (clickHandlerForItem != null) {\n // We wrap this in a MacrostratInteractionManager to handle unit selection\n return h(\n MacrostratInteractionProvider,\n {\n clickHandlerForItem,\n inherit: true,\n },\n main,\n );\n }\n\n return main;\n}\n\nexport function LegendPanelHeader({\n title,\n id,\n onClose,\n actions = null,\n hiddenActions,\n}: {\n title?: string | null;\n id?: number | null;\n onClose?: () => void;\n actions?: ReactNode | null;\n hiddenActions?: ReactNode | null;\n}) {\n return h(\"header.legend-panel-header\", [\n h(\"div.title-container\", [\n h.if(title != null)(\"h3\", title),\n h.if(hiddenActions != null)(\n \"span.hidden-actions-container\",\n h(\"div.hidden-actions\", hiddenActions),\n ),\n ]),\n h(\"div.spacer\"),\n h.if(id != null)(\"code.unit-id\", id),\n h.if(actions != null)(ButtonGroup, { minimal: true }, actions),\n h.if(onClose != null)(Button, {\n icon: \"cross\",\n minimal: true,\n small: true,\n onClick() {\n onClose?.();\n },\n }),\n ]);\n}\n\nexport enum UnitDetailsFeature {\n AdjacentUnits = \"adjacent-units\",\n Color = \"color\",\n OutcropType = \"outcrop-type\",\n JSONToggle = \"json-toggle\",\n DepthRange = \"depth-range\",\n ColumnName = \"column-name\",\n}\n\nexport type MacrostratItemClickHandler = (\n event: MouseEvent,\n item:\n | Lithology\n | Environment\n | UnitLong\n | Interval\n | { strat_name_id: number },\n) => void;\n\nfunction UnitDetailsContent({\n unit,\n lithologyFeatures = new Set([\n LithologyTagFeature.Proportion,\n LithologyTagFeature.Attributes,\n ]),\n features = new Set<UnitDetailsFeature>([\n UnitDetailsFeature.AdjacentUnits,\n UnitDetailsFeature.OutcropType,\n ]),\n onClickItem,\n getItemHref,\n}: {\n unit: UnitLong;\n lithologyFeatures?: Set<LithologyTagFeature>;\n features?: Set<UnitDetailsFeature>;\n onClickItem?: MacrostratItemClickHandler;\n getItemHref?: (item: Lithology | Environment | UnitLong) => string | null;\n}) {\n const lithMap = useMacrostratDefs(\"lithologies\");\n const envMap = useMacrostratDefs(\"environments\");\n\n const environments = enhanceEnvironments(unit.environ, envMap);\n const lithologies = enhanceLithologies(unit.lith ?? [], lithMap);\n\n let outcropField: ReactNode = null;\n if (features.has(UnitDetailsFeature.OutcropType)) {\n // Determine outcrop type\n let outcrop = unit.outcrop;\n if (outcrop == \"both\") {\n outcrop = \"surface and subsurface\";\n }\n outcropField = h(DataField, {\n label: \"Outcrop\",\n value: outcrop,\n });\n }\n\n let thicknessOrHeightRange: ReactNode = null;\n const [thickness, thicknessUnit] = getThickness(unit);\n // Proxy for actual heights in t_pos and b_pos\n if (\n features.has(UnitDetailsFeature.DepthRange) &&\n unit.t_pos != null &&\n unit.b_pos != null &&\n unit.min_thick == unit.max_thick && // We have an actual fixed height\n unit.min_thick != 0 // Not a zero thickness\n ) {\n const label = unit.t_pos < unit.b_pos ? \"Depth\" : \"Height\";\n const u1 = \"m\";\n\n thicknessOrHeightRange = h(DataField, {\n unit: u1,\n label,\n value: formatRange(unit.b_pos, unit.t_pos),\n children: h(\n Parenthetical,\n h(Value, { value: thickness, unit: thicknessUnit }),\n ),\n });\n }\n thicknessOrHeightRange ??= h(DataField, {\n label: \"Thickness\",\n value: thickness,\n unit: thicknessUnit,\n });\n\n /** We are trying to move away from passing the \"color\" parameter in the API */\n let colorSwatch: ReactNode = null;\n if (\"color\" in unit && features.has(UnitDetailsFeature.Color)) {\n const unit1 = unit as UnitLongFull;\n colorSwatch = h(\"div.color-swatch\", {\n style: { backgroundColor: unit1.color },\n });\n }\n\n return h(\"div.unit-details-content\", [\n h.if(features.has(UnitDetailsFeature.ColumnName))(ColumnNameField, {\n col_id: unit.col_id,\n }),\n thicknessOrHeightRange,\n h.if(lithologies != null)(LithologyList, {\n label: \"Lithology\",\n lithologies: lithologies ?? [],\n features: lithologyFeatures,\n }),\n h(AgeField, { unit }, [\n h(Parenthetical, h(Duration, { value: unit.b_age - unit.t_age })),\n h(IntervalProportions, {\n unit,\n onClickItem,\n }),\n ]),\n h.if(environments != null)(EnvironmentsList, {\n environments,\n }),\n h.if(unit.strat_name_id != null)(StratNameField, {\n strat_name_id: unit.strat_name_id,\n }),\n outcropField,\n h.if(features.has(UnitDetailsFeature.AdjacentUnits))([\n h.if(unit.units_above != null)(\n DataField,\n { label: \"Above\" },\n h(UnitIDList, {\n units: unit.units_above,\n showNames: true,\n }),\n ),\n h.if(unit.units_below != null)(\n DataField,\n { label: \"Below\" },\n h(UnitIDList, {\n units: unit.units_below,\n showNames: true,\n }),\n ),\n ]),\n colorSwatch,\n h(ReferencesField, { refs: unit.refs, inline: true }),\n ]);\n}\n\nfunction ColumnNameField({\n col_id,\n showIdentifier = false,\n}: {\n col_id: number;\n showIdentifier?: boolean;\n}) {\n const colData = useMacrostratColumnInfo(col_id);\n let inner: any = h(Identifier, { id: col_id });\n const name = colData?.col_name;\n if (name != null) {\n inner = h(\"span.value\", [\n h(\"span.col-name\", name),\n h.if(showIdentifier)([\" \", h(Parenthetical, inner)]),\n ]);\n }\n\n return h(\n DataField,\n {\n label: \"Column\",\n },\n inner,\n );\n}\n\nexport function ReferencesField({ refs, className = null, ...rest }) {\n if (refs == null || refs.length === 0) {\n return null;\n }\n\n return h(\n DataField,\n {\n label: \"References\",\n className: classNames(\"refs-field\", className),\n ...rest,\n },\n h(BibInfo, { refs }),\n );\n}\n\nfunction useStratNameData(strat_name_id: number) {\n const stratNames = useStratNames([strat_name_id]);\n return stratNames?.[0];\n}\n\nfunction StratNameField(\n props: {\n strat_name_id: number;\n className?: string;\n } & ItemInteractionProps,\n) {\n /** Handling for stratigraphic name field */\n const { strat_name_id, className, ...rest } = props;\n const data = useStratNameData(strat_name_id);\n\n const baseInteractionProps = useInteractionProps({ strat_name_id });\n\n const coreProps = {\n ...baseInteractionProps,\n ...rest,\n };\n\n let inner: any = h(Identifier, { id: strat_name_id });\n const name = data?.strat_name_long;\n if (name != null) {\n inner = h(\"span.strat-name\", name);\n }\n\n const clickable = isClickable(coreProps);\n\n return h(\n DataField,\n {\n label: \"Stratigraphic name\",\n },\n h(\n clickable ? \"a\" : \"span\",\n {\n className: classNames({ clickable }, className),\n ...coreProps,\n },\n inner,\n ),\n );\n}\n\nfunction getThickness(unit): [string, string] {\n let minThickness = unit.min_thick ?? 0;\n let maxThickness = unit.max_thick ?? unit.min_thick ?? 0;\n let _unit = \"m\";\n\n if (minThickness == 0 && maxThickness == 0) {\n return [\"Unknown\", null];\n }\n\n if (minThickness < 0.8 && maxThickness < 1.2) {\n // Convert to cm\n minThickness = minThickness * 100;\n maxThickness = maxThickness * 100;\n _unit = \"cm\";\n } else if (minThickness > 800 && maxThickness > 1200) {\n // Convert to km\n minThickness = minThickness / 1000;\n maxThickness = maxThickness / 1000;\n _unit = \"km\";\n }\n\n if (minThickness == maxThickness) {\n return [formatSignificance(minThickness), _unit];\n }\n\n return [formatRange(minThickness, maxThickness), _unit];\n}\n\nexport function ThicknessField({ unit, label = \"Thickness\" }) {\n const [value, thicknessUnit] = getThickness(unit);\n return h(DataField, {\n label,\n value,\n unit: thicknessUnit,\n });\n}\n\nfunction BibInfo({ refs }) {\n const refData = useMacrostratData(\"refs\", refs);\n\n if (refData == null || refData.length === 0) {\n return null;\n }\n\n if (refData.length == 1) {\n return h(Citation, {\n data: refData[0],\n tag: \"span\",\n key: refData[0].ref_id,\n });\n }\n\n return h(\n \"ul.refs\",\n refData.map((data, i) =>\n h(Citation, { data, tag: \"li\", key: data.ref_id }),\n ),\n );\n}\n\nfunction Citation({ data, tag = \"p\" }) {\n return h(tag, { className: \"citation\" }, [\n h(\"span.authors\", data.author),\n \", \",\n h(\"span.year\", data.pub_year),\n \", \",\n h(\"span.title\", data.ref),\n ]);\n}\n\nfunction enhanceEnvironments(\n environments?: Partial<Environment>[] | null,\n envMap?: Map<number, Environment> | null,\n) {\n return environments?.map((env) => {\n return {\n ...(envMap?.get(env.environ_id) ?? {}),\n ...env,\n };\n });\n}\n\ntype LithID =\n | (Partial<Lithology> & Pick<Lithology, \"lith_id\">)\n | UnitLithology\n | Lithology;\n\nfunction enhanceLithologies(\n lithologies?: LithID[] | null,\n lithMap?: Map<number, any> | null,\n) {\n return lithologies?.map((lith) => {\n return {\n ...(lithMap?.get(lith.lith_id) ?? {}), // get lithology details\n ...lith, // override with the unit's specific lithology data\n };\n });\n}\n\nexport function ClickableText({\n className,\n ...rest\n}: {\n className?: string;\n children: ReactNode;\n} & ItemInteractionProps) {\n /** An optionally clickable text element */\n const clickable = isClickable(rest);\n const tag = clickable ? \"a\" : \"span\";\n return h(tag, { className: classNames(className, { clickable }), ...rest });\n}\n\nexport function Identifier({\n id,\n className,\n ...rest\n}: {\n id: number | string;\n className?: string;\n} & ItemInteractionProps) {\n /** An item that displays a numeric identifier, optionally clickable */\n return h(\n ClickableText,\n {\n className: classNames(\"identifier\", className),\n ...rest,\n },\n id,\n );\n}\n\ntype UnitInfo = {\n unitID: number;\n colID?: number;\n name?: string;\n};\n\nfunction UnitIDList({ units, showNames = false }) {\n const unitsMap = useColumnUnitsMap();\n\n const interactionManager = useInteractionManager();\n\n const extUnits: UnitInfo[] = useMemo(() => {\n const u1 = units.filter((d) => d != 0);\n if (showNames) {\n return u1.map((unitID) => {\n const unitData = unitsMap?.get(unitID);\n let name: string = undefined;\n if (unitData != null) {\n name = defaultNameFunction(unitData);\n }\n return {\n unitID,\n colID: unitData?.col_id,\n name,\n };\n });\n } else {\n return u1.map((unitID) => ({ unitID }));\n }\n }, [units, unitsMap]);\n\n if (extUnits.length === 0) {\n return h(\"span.no-units\", \"None\");\n }\n\n return h(\n ItemList,\n { className: \"units-list\" },\n extUnits.map((info) => {\n return h(\n \"span.item\",\n h(UnitIdentifier, {\n ...info,\n ...interactionManager?.interactionPropsForItem({\n unit_id: info.unitID,\n }),\n }),\n );\n }),\n );\n}\n\nfunction UnitIdentifier({\n unitID,\n colID,\n name,\n ...interactionProps\n}: UnitInfo & ItemInteractionProps) {\n if (name != null) {\n return h(\n ClickableText,\n {\n className: \"unit-name\",\n ...interactionProps,\n },\n name,\n );\n }\n\n return h(Identifier, {\n className: \"unit-id\",\n key: unitID,\n id: unitID,\n ...interactionProps,\n });\n}\n"],"names":["UnitDetailsFeature"],"mappings":";;;;;;;;;;;AAqDO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA,+BAAe,IAAwB;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAAA,CACD;AAAA,EACD;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA;AACF,GAA0B;AACxB,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAE9C,MAAI,UAAqB;AACzB,MAAI,UAAU;AACZ,cAAU,EAAE,UAAU,EAAE,MAAM,MAAM,UAAU,OAAO;AAAA,EACvD,OAAO;AACL,cAAU,EAAE,oBAAoB;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,EACH;AAEA,MAAI,QAAQ,oBAAoB,IAAI;AAEpC,MAAI,SAAS;AAAA,IAAI;AAAA;AAAA,KAAgC;AAC/C,oBAAgB,EAAE;AAAA,MAChB,EAAE,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,QACP,SAAS;AAAA,QACT,KAAK;AAAA,QACL,WA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AAO;AACL,aAAO,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS;AAAA,IACxC;AAAA,EACF,GAAG,CAAC,OAAO,QAAQ,CAAC;AAEpB,MAAI,SAAS,WAAW,GAAG;AACzB,WAAO,EAAE,iBAAiB,MAAM;AAAA,EAClC;AAEA,SAAO;AAAA,IACL;AAAA,IACA,EAAE,WAAW,aAAA;AAAA,IACb,SAAS,IAAI,CAAC,SAAS;AACrB,aAAO;AAAA,QACL;AAAA,QACA,EAAE,gBAAgB;AAAA,UAChB,GAAG;AAAA,UACH,GAAG,oBAAoB,wBAAwB;AAAA,YAC7C,SAAS,KAAK;AAAA,UAAA,CACf;AAAA,QAAA,CACF;AAAA,MAAA;AAAA,IAEL,CAAC;AAAA,EAAA;AAEL;AAEA,SAAS,eAAe;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAoC;AAClC,MAAI,QAAQ,MAAM;AAChB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,WAAW;AAAA,QACX,GAAG;AAAA,MAAA;AAAA,MAEL;AAAA,IAAA;AAAA,EAEJ;AAEA,SAAO,EAAE,YAAY;AAAA,IACnB,WAAW;AAAA,IACX,KAAK;AAAA,IACL,IAAI;AAAA,IACJ,GAAG;AAAA,EAAA,CACJ;AACH;"}
|
|
1
|
+
{"version":3,"file":"panel.js","sources":["../../src/unit-details/panel.ts"],"sourcesContent":["import { JSONView } from \"@macrostrat/ui-components\";\nimport { Button, ButtonGroup } from \"@blueprintjs/core\";\nimport { ReactNode, useMemo, useState } from \"react\";\nimport {\n DataField,\n EnvironmentsList,\n ItemList,\n LithologyList,\n LithologyTagFeature,\n MacrostratInteractionManager,\n MacrostratInteractionProvider,\n MacrostratItemIdentifier,\n Parenthetical,\n useInteractionManager,\n Value,\n} from \"@macrostrat/data-components\";\nimport { useColumnUnitsMap } from \"../data-provider\";\nimport {\n useMacrostratColumnInfo,\n useMacrostratData,\n useMacrostratDefs,\n} from \"@macrostrat/data-provider\";\nimport type {\n Environment,\n EnvironmentIdentifier,\n Interval,\n Lithology,\n UnitLong,\n UnitLongFull,\n} from \"@macrostrat/api-types\";\nimport { defaultNameFunction } from \"../units/names\";\nimport classNames from \"classnames\";\nimport { AgeField, Duration, IntervalProportions } from \"./age-range\";\nimport { formatRange, formatSignificance } from \"./utils.ts\";\nimport h from \"./panel.module.sass\";\nimport { StratNameField } from \"./strat-names.ts\";\nimport { Identifier, UnitIdentifier, UnitInfo } from \"./identifiers.ts\";\nimport { LithologyIdentifier } from \"@macrostrat/api-types/src/lithologies\";\n\nexport interface UnitDetailsPanelProps {\n unit: any;\n onClose?: any;\n className?: string;\n actions?: ReactNode;\n hiddenActions?: ReactNode;\n features?: Set<UnitDetailsFeature>;\n lithologyFeatures?: Set<LithologyTagFeature>;\n onSelectUnit?: (unitID: number) => void;\n onClickItem?: MacrostratItemClickHandler;\n interactionManager?: MacrostratInteractionManager;\n showJSON?: boolean;\n}\n\nexport function UnitDetailsPanel({\n unit,\n onClose,\n className,\n features = new Set<UnitDetailsFeature>([\n UnitDetailsFeature.AdjacentUnits,\n UnitDetailsFeature.OutcropType,\n UnitDetailsFeature.JSONToggle,\n UnitDetailsFeature.DepthRange,\n ]),\n lithologyFeatures,\n actions,\n hiddenActions = null,\n onSelectUnit,\n onClickItem,\n showJSON,\n}: UnitDetailsPanelProps) {\n const [_showJSON, setShowJSON] = useState(false);\n\n let content: ReactNode = null;\n if (showJSON ?? _showJSON) {\n content = h(JSONView, { data: unit, showRoot: false });\n } else {\n content = h(UnitDetailsContent, {\n unit,\n features,\n lithologyFeatures,\n onClickItem,\n });\n }\n\n let title = defaultNameFunction(unit);\n\n if (features.has(UnitDetailsFeature.JSONToggle)) {\n hiddenActions = h([\n h(Button, {\n icon: \"code\",\n small: true,\n minimal: true,\n key: \"json-view-toggle\",\n className: classNames(\"json-view-toggle\", { enabled: setShowJSON }),\n onClick(evt) {\n setShowJSON(!showJSON);\n evt.stopPropagation();\n },\n }),\n hiddenActions,\n ]);\n }\n\n const main = h(\"div.unit-details-panel\", { className }, [\n h(LegendPanelHeader, {\n onClose,\n title,\n id: unit.unit_id,\n actions,\n hiddenActions,\n }),\n h(\"div.unit-details-content-holder\", content),\n ]);\n\n /** Handle unit selection clicks */\n const clickHandlerForItem = useMemo(() => {\n if (onSelectUnit == null && onClickItem == null) return null;\n return (item: MacrostratItemIdentifier) => {\n if (\"unit_id\" in item && !(\"col_id\" in item)) {\n // We are selecting a unit within the column\n return (event: MouseEvent) => {\n if (onSelectUnit != null) {\n onSelectUnit(item.unit_id);\n } else if (onClickItem != null) {\n console.warn(\n \"Unit selection: onClickItem is defined but onSelectUnit is not; ignoring click\",\n );\n }\n // Don't allow event to propagate further (e.g., to open a link)\n event.preventDefault();\n };\n }\n return undefined;\n };\n }, [onSelectUnit, onClickItem]);\n\n if (clickHandlerForItem != null) {\n // We wrap this in a MacrostratInteractionManager to handle unit selection\n return h(\n MacrostratInteractionProvider,\n {\n clickHandlerForItem,\n inherit: true,\n },\n main,\n );\n }\n\n return main;\n}\n\nexport function LegendPanelHeader({\n title,\n id,\n onClose,\n actions = null,\n hiddenActions,\n}: {\n title?: string | null;\n id?: number | null;\n onClose?: () => void;\n actions?: ReactNode | null;\n hiddenActions?: ReactNode | null;\n}) {\n return h(\"header.legend-panel-header\", [\n h(\"div.title-container\", [\n h.if(title != null)(\"h3\", title),\n h.if(hiddenActions != null)(\n \"span.hidden-actions-container\",\n h(\"div.hidden-actions\", hiddenActions),\n ),\n ]),\n h(\"div.spacer\"),\n h.if(id != null)(\"code.unit-id\", id),\n h.if(actions != null)(ButtonGroup, { minimal: true }, actions),\n h.if(onClose != null)(Button, {\n icon: \"cross\",\n minimal: true,\n small: true,\n onClick() {\n onClose?.();\n },\n }),\n ]);\n}\n\nexport enum UnitDetailsFeature {\n AdjacentUnits = \"adjacent-units\",\n Color = \"color\",\n OutcropType = \"outcrop-type\",\n JSONToggle = \"json-toggle\",\n DepthRange = \"depth-range\",\n ColumnName = \"column-name\",\n}\n\nexport type MacrostratItemClickHandler = (\n event: MouseEvent,\n item:\n | Lithology\n | Environment\n | UnitLong\n | Interval\n | { strat_name_id: number },\n) => void;\n\nfunction UnitDetailsContent({\n unit,\n lithologyFeatures = new Set([\n LithologyTagFeature.Proportion,\n LithologyTagFeature.Attributes,\n ]),\n features = new Set<UnitDetailsFeature>([\n UnitDetailsFeature.AdjacentUnits,\n UnitDetailsFeature.OutcropType,\n ]),\n onClickItem,\n getItemHref,\n}: {\n unit: UnitLong;\n lithologyFeatures?: Set<LithologyTagFeature>;\n features?: Set<UnitDetailsFeature>;\n onClickItem?: MacrostratItemClickHandler;\n getItemHref?: (item: Lithology | Environment | UnitLong) => string | null;\n}) {\n const lithMap = useMacrostratDefs(\"lithologies\");\n const envMap = useMacrostratDefs(\"environments\");\n\n const environments = enhanceEnvironments(unit.environ, envMap);\n const lithologies = enhanceLithologies(unit.lith ?? [], lithMap);\n\n let outcropField: ReactNode = null;\n if (features.has(UnitDetailsFeature.OutcropType)) {\n // Determine outcrop type\n let outcrop = unit.outcrop;\n if (outcrop == \"both\") {\n outcrop = \"surface and subsurface\";\n }\n outcropField = h(DataField, {\n label: \"Outcrop\",\n value: outcrop,\n });\n }\n\n let thicknessOrHeightRange: ReactNode = null;\n const [thickness, thicknessUnit] = getThickness(unit);\n // Proxy for actual heights in t_pos and b_pos\n if (\n features.has(UnitDetailsFeature.DepthRange) &&\n unit.t_pos != null &&\n unit.b_pos != null &&\n unit.min_thick == unit.max_thick && // We have an actual fixed height\n unit.min_thick != 0 // Not a zero thickness\n ) {\n const label = unit.t_pos < unit.b_pos ? \"Depth\" : \"Height\";\n const u1 = \"m\";\n\n thicknessOrHeightRange = h(DataField, {\n unit: u1,\n label,\n value: formatRange(unit.b_pos, unit.t_pos),\n children: h(\n Parenthetical,\n h(Value, { value: thickness, unit: thicknessUnit }),\n ),\n });\n }\n thicknessOrHeightRange ??= h(DataField, {\n label: \"Thickness\",\n value: thickness,\n unit: thicknessUnit,\n });\n\n /** We are trying to move away from passing the \"color\" parameter in the API */\n let colorSwatch: ReactNode = null;\n if (\"color\" in unit && features.has(UnitDetailsFeature.Color)) {\n const unit1 = unit as UnitLongFull;\n colorSwatch = h(\"div.color-swatch\", {\n style: { backgroundColor: unit1.color },\n });\n }\n\n return h(\"div.unit-details-content\", [\n h.if(features.has(UnitDetailsFeature.ColumnName))(ColumnNameField, {\n col_id: unit.col_id,\n }),\n thicknessOrHeightRange,\n h.if(lithologies != null)(LithologyList, {\n label: \"Lithology\",\n lithologies: lithologies ?? [],\n features: lithologyFeatures,\n }),\n h(AgeField, { unit }, [\n h(Parenthetical, h(Duration, { value: unit.b_age - unit.t_age })),\n h(IntervalProportions, {\n unit,\n onClickItem,\n }),\n ]),\n h.if(environments != null)(EnvironmentsList, {\n environments,\n }),\n h.if(unit.strat_name_id != null)(StratNameField, {\n strat_name_id: unit.strat_name_id,\n }),\n outcropField,\n h.if(features.has(UnitDetailsFeature.AdjacentUnits))([\n h.if(unit.units_above != null)(\n DataField,\n { label: \"Above\" },\n h(UnitIDList, {\n units: unit.units_above,\n showNames: true,\n }),\n ),\n h.if(unit.units_below != null)(\n DataField,\n { label: \"Below\" },\n h(UnitIDList, {\n units: unit.units_below,\n showNames: true,\n }),\n ),\n ]),\n colorSwatch,\n h(ReferencesField, { refs: unit.refs, inline: true }),\n ]);\n}\n\nfunction ColumnNameField({\n col_id,\n showIdentifier = false,\n}: {\n col_id: number;\n showIdentifier?: boolean;\n}) {\n const colData = useMacrostratColumnInfo(col_id);\n let inner: any = h(Identifier, { id: col_id });\n const name = colData?.col_name;\n if (name != null) {\n inner = h(\"span.value\", [\n h(\"span.col-name\", name),\n h.if(showIdentifier)([\" \", h(Parenthetical, inner)]),\n ]);\n }\n\n return h(\n DataField,\n {\n label: \"Column\",\n },\n inner,\n );\n}\n\nexport function ReferencesField({ refs, className = null, ...rest }) {\n if (refs == null || refs.length === 0) {\n return null;\n }\n\n return h(\n DataField,\n {\n label: \"References\",\n className: classNames(\"refs-field\", className),\n ...rest,\n },\n h(BibInfo, { refs }),\n );\n}\n\nfunction getThickness(unit): [string, string | null] {\n let minThickness = unit.min_thick ?? 0;\n let maxThickness = unit.max_thick ?? unit.min_thick ?? 0;\n let _unit = \"m\";\n\n if (minThickness == 0 && maxThickness == 0) {\n return [\"Unknown\", null];\n }\n\n if (minThickness < 0.8 && maxThickness < 1.2) {\n // Convert to cm\n minThickness = minThickness * 100;\n maxThickness = maxThickness * 100;\n _unit = \"cm\";\n } else if (minThickness > 800 && maxThickness > 1200) {\n // Convert to km\n minThickness = minThickness / 1000;\n maxThickness = maxThickness / 1000;\n _unit = \"km\";\n }\n\n if (minThickness == maxThickness) {\n return [formatSignificance(minThickness), _unit];\n }\n\n return [formatRange(minThickness, maxThickness), _unit];\n}\n\nexport function ThicknessField({ unit, label = \"Thickness\" }) {\n const [value, thicknessUnit] = getThickness(unit);\n return h(DataField, {\n label,\n value,\n unit: thicknessUnit,\n });\n}\n\nfunction BibInfo({ refs }) {\n const refData = useMacrostratData(\"refs\", refs);\n\n if (refData == null || refData.length === 0) {\n return null;\n }\n\n if (refData.length == 1) {\n return h(Citation, {\n data: refData[0],\n tag: \"span\",\n key: refData[0].ref_id,\n });\n }\n\n return h(\n \"ul.refs\",\n refData.map((data, i) =>\n h(Citation, { data, tag: \"li\", key: data.ref_id }),\n ),\n );\n}\n\nfunction Citation({ data, tag = \"p\" }) {\n return h(tag, { className: \"citation\" }, [\n h(\"span.authors\", data.author),\n \", \",\n h(\"span.year\", data.pub_year),\n \", \",\n h(\"span.title\", data.ref),\n ]);\n}\n\nfunction enhanceEnvironments(\n environments?: EnvironmentIdentifier[] | null,\n envMap?: Map<number, Environment> | null,\n) {\n return environments?.map((env) => {\n return {\n ...(envMap?.get(env.environ_id) ?? {}),\n ...env,\n };\n });\n}\n\nfunction enhanceLithologies(\n lithologies?: LithologyIdentifier[] | null,\n lithMap?: Map<number, any> | null,\n) {\n return lithologies?.map((lith) => {\n return {\n ...(lithMap?.get(lith.lith_id) ?? {}), // get lithology details\n ...lith, // override with the unit's specific lithology data\n };\n });\n}\n\nfunction UnitIDList({ units, showNames = false }) {\n const unitsMap = useColumnUnitsMap();\n\n const interactionManager = useInteractionManager();\n\n const extUnits: UnitInfo[] = useMemo(() => {\n const u1 = units.filter((d) => d != 0);\n if (showNames) {\n return u1.map((unitID) => {\n const unitData = unitsMap?.get(unitID);\n let name: string | null = null;\n if (unitData != null) {\n name = defaultNameFunction(unitData);\n }\n return {\n unitID,\n colID: unitData?.col_id,\n name,\n };\n });\n } else {\n return u1.map((unitID) => ({ unitID }));\n }\n }, [units, unitsMap]);\n\n if (extUnits.length === 0) {\n return h(\"span.no-units\", \"None\");\n }\n\n return h(\n ItemList,\n { className: \"units-list\" },\n extUnits.map((info) => {\n return h(\n \"span.item\",\n h(UnitIdentifier, {\n ...info,\n ...interactionManager?.interactionPropsForItem({\n unit_id: info.unitID,\n }),\n }),\n );\n }),\n );\n}\n"],"names":["UnitDetailsFeature"],"mappings":";;;;;;;;;;;;;AAqDO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA,+BAAe,IAAwB;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAAA,CACD;AAAA,EACD;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACF,GAA0B;AACxB,QAAM,CAAC,WAAW,WAAW,IAAI,SAAS,KAAK;AAE/C,MAAI,UAAqB;AACzB,MAAI,YAAY,WAAW;AACzB,cAAU,EAAE,UAAU,EAAE,MAAM,MAAM,UAAU,OAAO;AAAA,EACvD,OAAO;AACL,cAAU,EAAE,oBAAoB;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,EACH;AAEA,MAAI,QAAQ,oBAAoB,IAAI;AAEpC,MAAI,SAAS;AAAA,IAAI;AAAA;AAAA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GAAG,IAAI,CAAC,WAAW;AACxB,cAAM,WAAW,UAAU,IAAI,MAAM;AACrC,YAAI,OAAsB;AAC1B,YAAI,YAAY,MAAM;AACpB,iBAAO,oBAAoB,QAAQ;AAAA,QACrC;AACA,eAAO;AAAA,UACL;AAAA,UACA,OAAO,UAAU;AAAA,UACjB;AAAA,QAAA;AAAA,MAEJ,CAAC;AAAA,IACH,OAAO;AACL,aAAO,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS;AAAA,IACxC;AAAA,EACF,GAAG,CAAC,OAAO,QAAQ,CAAC;AAEpB,MAAI,SAAS,WAAW,GAAG;AACzB,WAAO,EAAE,iBAAiB,MAAM;AAAA,EAClC;AAEA,SAAO;AAAA,IACL;AAAA,IACA,EAAE,WAAW,aAAA;AAAA,IACb,SAAS,IAAI,CAAC,SAAS;AACrB,aAAO;AAAA,QACL;AAAA,QACA,EAAE,gBAAgB;AAAA,UAChB,GAAG;AAAA,UACH,GAAG,oBAAoB,wBAAwB;AAAA,YAC7C,SAAS,KAAK;AAAA,UAAA,CACf;AAAA,QAAA,CACF;AAAA,MAAA;AAAA,IAEL,CAAC;AAAA,EAAA;AAEL;"}
|
|
@@ -49,8 +49,7 @@ function InteractionBarrier({ children }) {
|
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
function UnitSelectionPopover(props) {
|
|
52
|
-
const unit = unitSelection.
|
|
53
|
-
const selectUnit = unitSelection.useUnitSelectionDispatch();
|
|
52
|
+
const [unit, selectUnit] = unitSelection.useUnitSelection();
|
|
54
53
|
const position = unitSelection.useAtomOverlayPosition();
|
|
55
54
|
if (unit == null) {
|
|
56
55
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.cjs","sources":["../../src/unit-details/popover.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport { Popover } from \"@blueprintjs/core\";\nimport styles from \"./popover.module.sass\";\nimport {
|
|
1
|
+
{"version":3,"file":"popover.cjs","sources":["../../src/unit-details/popover.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport { Popover } from \"@blueprintjs/core\";\nimport styles from \"./popover.module.sass\";\nimport { useAtomOverlayPosition, useUnitSelection } from \"../data-provider\";\nimport {\n UnitDetailsFeature,\n UnitDetailsPanel,\n UnitDetailsPanelProps,\n} from \"./panel\";\nimport { Lithology } from \"@macrostrat/api-types\";\nimport { LithologyTagFeature } from \"@macrostrat/data-components\";\nimport classNames from \"classnames\";\n\nconst h = hyper.styled(styles);\n\nexport function UnitDetailsPopover({\n style,\n children,\n viewportPadding = 20,\n}: {\n style: object;\n viewportPadding?: number;\n children: React.ReactNode;\n}) {\n const content = h(InteractionBarrier, children);\n\n return h(\n \"div.popover-main\",\n {\n style,\n },\n h(\n Popover,\n // @ts-ignore\n {\n content,\n isOpen: true,\n usePortal: false,\n position: \"right\",\n modifiers: {\n preventOverflow: { options: { padding: viewportPadding } },\n },\n },\n h(\"span.popover-target\"),\n ),\n );\n}\n\nfunction InteractionBarrier({ children }) {\n return h(\n \"div\",\n {\n onClick(e) {\n // Stop events from leaking to the parent\n e.stopPropagation();\n },\n },\n children,\n );\n}\n\nexport function UnitSelectionPopover(\n props: Omit<UnitDetailsPanelProps, \"onSelectUnit\" | \"unit\">,\n) {\n const [unit, selectUnit] = useUnitSelection();\n const position = useAtomOverlayPosition();\n if (unit == null) {\n return null;\n }\n\n return h(\n \"div.unit-popover-container\",\n h(\n UnitDetailsPopover,\n {\n style: {\n position: \"absolute\",\n top: position?.y ?? 0,\n width: position?.width ?? 100,\n left: position?.x ?? 0,\n height: position?.height ?? 100,\n },\n },\n h(UnitDetailsPanel, {\n ...props,\n unit,\n className: classNames(\"legend-panel\", props.className),\n onSelectUnit: (id: number) => {\n selectUnit(id, null);\n },\n }),\n ),\n );\n}\n"],"names":["hyper","styles","Popover","useUnitSelection","useAtomOverlayPosition","UnitDetailsPanel","classNames"],"mappings":";;;;;;;;;;;AAaA,MAAM,IAAIA,WAAAA,QAAM,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;;"}
|
|
@@ -3,7 +3,7 @@ import { Popover } from "@blueprintjs/core";
|
|
|
3
3
|
import h$2 from "./popover.module.sass.js";
|
|
4
4
|
import { UnitDetailsPanel } from "./panel.js";
|
|
5
5
|
import classNames from "classnames";
|
|
6
|
-
import {
|
|
6
|
+
import { useUnitSelection, useAtomOverlayPosition } from "../data-provider/unit-selection.js";
|
|
7
7
|
const h = h$1.styled(h$2);
|
|
8
8
|
function UnitDetailsPopover({
|
|
9
9
|
style,
|
|
@@ -44,8 +44,7 @@ function InteractionBarrier({ children }) {
|
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
function UnitSelectionPopover(props) {
|
|
47
|
-
const unit =
|
|
48
|
-
const selectUnit = useUnitSelectionDispatch();
|
|
47
|
+
const [unit, selectUnit] = useUnitSelection();
|
|
49
48
|
const position = useAtomOverlayPosition();
|
|
50
49
|
if (unit == null) {
|
|
51
50
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","sources":["../../src/unit-details/popover.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport { Popover } from \"@blueprintjs/core\";\nimport styles from \"./popover.module.sass\";\nimport {
|
|
1
|
+
{"version":3,"file":"popover.js","sources":["../../src/unit-details/popover.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport { Popover } from \"@blueprintjs/core\";\nimport styles from \"./popover.module.sass\";\nimport { useAtomOverlayPosition, useUnitSelection } from \"../data-provider\";\nimport {\n UnitDetailsFeature,\n UnitDetailsPanel,\n UnitDetailsPanelProps,\n} from \"./panel\";\nimport { Lithology } from \"@macrostrat/api-types\";\nimport { LithologyTagFeature } from \"@macrostrat/data-components\";\nimport classNames from \"classnames\";\n\nconst h = hyper.styled(styles);\n\nexport function UnitDetailsPopover({\n style,\n children,\n viewportPadding = 20,\n}: {\n style: object;\n viewportPadding?: number;\n children: React.ReactNode;\n}) {\n const content = h(InteractionBarrier, children);\n\n return h(\n \"div.popover-main\",\n {\n style,\n },\n h(\n Popover,\n // @ts-ignore\n {\n content,\n isOpen: true,\n usePortal: false,\n position: \"right\",\n modifiers: {\n preventOverflow: { options: { padding: viewportPadding } },\n },\n },\n h(\"span.popover-target\"),\n ),\n );\n}\n\nfunction InteractionBarrier({ children }) {\n return h(\n \"div\",\n {\n onClick(e) {\n // Stop events from leaking to the parent\n e.stopPropagation();\n },\n },\n children,\n );\n}\n\nexport function UnitSelectionPopover(\n props: Omit<UnitDetailsPanelProps, \"onSelectUnit\" | \"unit\">,\n) {\n const [unit, selectUnit] = useUnitSelection();\n const position = useAtomOverlayPosition();\n if (unit == null) {\n return null;\n }\n\n return h(\n \"div.unit-popover-container\",\n h(\n UnitDetailsPopover,\n {\n style: {\n position: \"absolute\",\n top: position?.y ?? 0,\n width: position?.width ?? 100,\n left: position?.x ?? 0,\n height: position?.height ?? 100,\n },\n },\n h(UnitDetailsPanel, {\n ...props,\n unit,\n className: classNames(\"legend-panel\", props.className),\n onSelectUnit: (id: number) => {\n selectUnit(id, null);\n },\n }),\n ),\n );\n}\n"],"names":["hyper","styles"],"mappings":";;;;;;AAaA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAEtB,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AAAA,EACA,kBAAkB;AACpB,GAIG;AACD,QAAM,UAAU,EAAE,oBAAoB,QAAQ;AAE9C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE;AAAA,IAAA;AAAA,IAEF;AAAA,MACE;AAAA;AAAA,MAEA;AAAA,QACE;AAAA,QACA,QAAQ;AAAA,QACR,WAAW;AAAA,QACX,UAAU;AAAA,QACV,WAAW;AAAA,UACT,iBAAiB,EAAE,SAAS,EAAE,SAAS,kBAAgB;AAAA,QAAE;AAAA,MAC3D;AAAA,MAEF,EAAE,qBAAqB;AAAA,IAAA;AAAA,EACzB;AAEJ;AAEA,SAAS,mBAAmB,EAAE,YAAY;AACxC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,QAAQ,GAAG;AAET,UAAE,gBAAA;AAAA,MACJ;AAAA,IAAA;AAAA,IAEF;AAAA,EAAA;AAEJ;AAEO,SAAS,qBACd,OACA;AACA,QAAM,CAAC,MAAM,UAAU,IAAI,iBAAA;AAC3B,QAAM,WAAW,uBAAA;AACjB,MAAI,QAAQ,MAAM;AAChB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,QACE,OAAO;AAAA,UACL,UAAU;AAAA,UACV,KAAK,UAAU,KAAK;AAAA,UACpB,OAAO,UAAU,SAAS;AAAA,UAC1B,MAAM,UAAU,KAAK;AAAA,UACrB,QAAQ,UAAU,UAAU;AAAA,QAAA;AAAA,MAC9B;AAAA,MAEF,EAAE,kBAAkB;AAAA,QAClB,GAAG;AAAA,QACH;AAAA,QACA,WAAW,WAAW,gBAAgB,MAAM,SAAS;AAAA,QACrD,cAAc,CAAC,OAAe;AAC5B,qBAAW,IAAI,IAAI;AAAA,QACrB;AAAA,MAAA,CACD;AAAA,IAAA;AAAA,EACH;AAEJ;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const dataComponents = require("@macrostrat/data-components");
|
|
4
|
+
const panel_module = require("./panel.module.sass.cjs");
|
|
5
|
+
const classNames = require("classnames");
|
|
6
|
+
const dataProvider = require("@macrostrat/data-provider");
|
|
7
|
+
const identifiers = require("./identifiers.cjs");
|
|
8
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
|
+
const classNames__default = /* @__PURE__ */ _interopDefault(classNames);
|
|
10
|
+
function useStratNameData(strat_name_id) {
|
|
11
|
+
const stratNames = dataProvider.useStratNames([strat_name_id]);
|
|
12
|
+
return stratNames?.[0];
|
|
13
|
+
}
|
|
14
|
+
function StratNameField(props) {
|
|
15
|
+
const { strat_name_id, className, ...rest } = props;
|
|
16
|
+
const data = useStratNameData(strat_name_id);
|
|
17
|
+
const baseInteractionProps = dataComponents.useInteractionProps({ strat_name_id });
|
|
18
|
+
const coreProps = {
|
|
19
|
+
...baseInteractionProps,
|
|
20
|
+
...rest
|
|
21
|
+
};
|
|
22
|
+
let inner = panel_module.default(identifiers.Identifier, { id: strat_name_id });
|
|
23
|
+
const name = data?.strat_name_long;
|
|
24
|
+
if (name != null) {
|
|
25
|
+
inner = panel_module.default("span.strat-name", name);
|
|
26
|
+
}
|
|
27
|
+
const clickable = dataComponents.isClickable(coreProps);
|
|
28
|
+
return panel_module.default(
|
|
29
|
+
dataComponents.DataField,
|
|
30
|
+
{
|
|
31
|
+
label: "Stratigraphic name"
|
|
32
|
+
},
|
|
33
|
+
panel_module.default(
|
|
34
|
+
clickable ? "a" : "span",
|
|
35
|
+
{
|
|
36
|
+
className: classNames__default.default({ clickable }, className),
|
|
37
|
+
...coreProps
|
|
38
|
+
},
|
|
39
|
+
inner
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
exports.StratNameField = StratNameField;
|
|
44
|
+
//# sourceMappingURL=strat-names.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strat-names.cjs","sources":["../../src/unit-details/strat-names.ts"],"sourcesContent":["import {\n DataField,\n isClickable,\n ItemInteractionProps,\n useInteractionProps,\n} from \"@macrostrat/data-components\";\nimport h from \"./panel.module.sass\";\nimport classNames from \"classnames\";\nimport { useStratNames } from \"@macrostrat/data-provider\";\nimport { Identifier } from \"./identifiers.ts\";\n\nfunction useStratNameData(strat_name_id: number) {\n const stratNames = useStratNames([strat_name_id]);\n return stratNames?.[0];\n}\n\nexport function StratNameField(\n props: {\n strat_name_id: number;\n className?: string;\n } & ItemInteractionProps,\n) {\n /** Handling for stratigraphic name field */\n const { strat_name_id, className, ...rest } = props;\n\n const data = useStratNameData(strat_name_id);\n\n const baseInteractionProps = useInteractionProps({ strat_name_id });\n\n const coreProps = {\n ...baseInteractionProps,\n ...rest,\n };\n\n let inner: any = h(Identifier, { id: strat_name_id });\n const name = data?.strat_name_long;\n if (name != null) {\n inner = h(\"span.strat-name\", name);\n }\n\n const clickable = isClickable(coreProps);\n\n return h(\n DataField,\n {\n label: \"Stratigraphic name\",\n },\n h(\n clickable ? \"a\" : \"span\",\n {\n className: classNames({ clickable }, className),\n ...coreProps,\n },\n inner,\n ),\n );\n}\n"],"names":["useStratNames","useInteractionProps","h","Identifier","isClickable","DataField","classNames"],"mappings":";;;;;;;;;AAWA,SAAS,iBAAiB,eAAuB;AAC/C,QAAM,aAAaA,aAAAA,cAAc,CAAC,aAAa,CAAC;AAChD,SAAO,aAAa,CAAC;AACvB;AAEO,SAAS,eACd,OAIA;AAEA,QAAM,EAAE,eAAe,WAAW,GAAG,SAAS;AAE9C,QAAM,OAAO,iBAAiB,aAAa;AAE3C,QAAM,uBAAuBC,eAAAA,oBAAoB,EAAE,eAAe;AAElE,QAAM,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAGL,MAAI,QAAaC,aAAAA,QAAEC,YAAAA,YAAY,EAAE,IAAI,eAAe;AACpD,QAAM,OAAO,MAAM;AACnB,MAAI,QAAQ,MAAM;AAChB,YAAQD,aAAAA,QAAE,mBAAmB,IAAI;AAAA,EACnC;AAEA,QAAM,YAAYE,eAAAA,YAAY,SAAS;AAEvC,SAAOF,aAAAA;AAAAA,IACLG,eAAAA;AAAAA,IACA;AAAA,MACE,OAAO;AAAA,IAAA;AAAA,IAETH,aAAAA;AAAAA,MACE,YAAY,MAAM;AAAA,MAClB;AAAA,QACE,WAAWI,oBAAAA,QAAW,EAAE,UAAA,GAAa,SAAS;AAAA,QAC9C,GAAG;AAAA,MAAA;AAAA,MAEL;AAAA,IAAA;AAAA,EACF;AAEJ;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ItemInteractionProps } from '@macrostrat/data-components';
|
|
2
|
+
export declare function StratNameField(props: {
|
|
3
|
+
strat_name_id: number;
|
|
4
|
+
className?: string;
|
|
5
|
+
} & ItemInteractionProps): import('react').FunctionComponentElement<{
|
|
6
|
+
label?: string;
|
|
7
|
+
value?: any;
|
|
8
|
+
inline?: boolean;
|
|
9
|
+
showIfEmpty?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
children?: any;
|
|
12
|
+
unit?: string;
|
|
13
|
+
row?: boolean;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useInteractionProps, isClickable, DataField } from "@macrostrat/data-components";
|
|
2
|
+
import h from "./panel.module.sass.js";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import { useStratNames } from "@macrostrat/data-provider";
|
|
5
|
+
import { Identifier } from "./identifiers.js";
|
|
6
|
+
function useStratNameData(strat_name_id) {
|
|
7
|
+
const stratNames = useStratNames([strat_name_id]);
|
|
8
|
+
return stratNames?.[0];
|
|
9
|
+
}
|
|
10
|
+
function StratNameField(props) {
|
|
11
|
+
const { strat_name_id, className, ...rest } = props;
|
|
12
|
+
const data = useStratNameData(strat_name_id);
|
|
13
|
+
const baseInteractionProps = useInteractionProps({ strat_name_id });
|
|
14
|
+
const coreProps = {
|
|
15
|
+
...baseInteractionProps,
|
|
16
|
+
...rest
|
|
17
|
+
};
|
|
18
|
+
let inner = h(Identifier, { id: strat_name_id });
|
|
19
|
+
const name = data?.strat_name_long;
|
|
20
|
+
if (name != null) {
|
|
21
|
+
inner = h("span.strat-name", name);
|
|
22
|
+
}
|
|
23
|
+
const clickable = isClickable(coreProps);
|
|
24
|
+
return h(
|
|
25
|
+
DataField,
|
|
26
|
+
{
|
|
27
|
+
label: "Stratigraphic name"
|
|
28
|
+
},
|
|
29
|
+
h(
|
|
30
|
+
clickable ? "a" : "span",
|
|
31
|
+
{
|
|
32
|
+
className: classNames({ clickable }, className),
|
|
33
|
+
...coreProps
|
|
34
|
+
},
|
|
35
|
+
inner
|
|
36
|
+
)
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
StratNameField
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=strat-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strat-names.js","sources":["../../src/unit-details/strat-names.ts"],"sourcesContent":["import {\n DataField,\n isClickable,\n ItemInteractionProps,\n useInteractionProps,\n} from \"@macrostrat/data-components\";\nimport h from \"./panel.module.sass\";\nimport classNames from \"classnames\";\nimport { useStratNames } from \"@macrostrat/data-provider\";\nimport { Identifier } from \"./identifiers.ts\";\n\nfunction useStratNameData(strat_name_id: number) {\n const stratNames = useStratNames([strat_name_id]);\n return stratNames?.[0];\n}\n\nexport function StratNameField(\n props: {\n strat_name_id: number;\n className?: string;\n } & ItemInteractionProps,\n) {\n /** Handling for stratigraphic name field */\n const { strat_name_id, className, ...rest } = props;\n\n const data = useStratNameData(strat_name_id);\n\n const baseInteractionProps = useInteractionProps({ strat_name_id });\n\n const coreProps = {\n ...baseInteractionProps,\n ...rest,\n };\n\n let inner: any = h(Identifier, { id: strat_name_id });\n const name = data?.strat_name_long;\n if (name != null) {\n inner = h(\"span.strat-name\", name);\n }\n\n const clickable = isClickable(coreProps);\n\n return h(\n DataField,\n {\n label: \"Stratigraphic name\",\n },\n h(\n clickable ? \"a\" : \"span\",\n {\n className: classNames({ clickable }, className),\n ...coreProps,\n },\n inner,\n ),\n );\n}\n"],"names":[],"mappings":";;;;;AAWA,SAAS,iBAAiB,eAAuB;AAC/C,QAAM,aAAa,cAAc,CAAC,aAAa,CAAC;AAChD,SAAO,aAAa,CAAC;AACvB;AAEO,SAAS,eACd,OAIA;AAEA,QAAM,EAAE,eAAe,WAAW,GAAG,SAAS;AAE9C,QAAM,OAAO,iBAAiB,aAAa;AAE3C,QAAM,uBAAuB,oBAAoB,EAAE,eAAe;AAElE,QAAM,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAGL,MAAI,QAAa,EAAE,YAAY,EAAE,IAAI,eAAe;AACpD,QAAM,OAAO,MAAM;AACnB,MAAI,QAAQ,MAAM;AAChB,YAAQ,EAAE,mBAAmB,IAAI;AAAA,EACnC;AAEA,QAAM,YAAY,YAAY,SAAS;AAEvC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,OAAO;AAAA,IAAA;AAAA,IAET;AAAA,MACE,YAAY,MAAM;AAAA,MAClB;AAAA,QACE,WAAW,WAAW,EAAE,UAAA,GAAa,SAAS;AAAA,QAC9C,GAAG;AAAA,MAAA;AAAA,MAEL;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
package/dist/units/index.cjs
CHANGED
|
@@ -36,13 +36,27 @@ function BasicUnitComponent({ division, ...rest }) {
|
|
|
36
36
|
patternID: division.patternID
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
function UnitComponent({
|
|
39
|
+
function UnitComponent({
|
|
40
|
+
division,
|
|
41
|
+
nColumns = 2,
|
|
42
|
+
...rest
|
|
43
|
+
}) {
|
|
40
44
|
const width = rest.width ?? columnComponents.useColumnLayout()?.width;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
let _nColumns = nColumns;
|
|
46
|
+
if (isNaN(_nColumns)) {
|
|
47
|
+
_nColumns = 2;
|
|
48
|
+
}
|
|
49
|
+
let columnIx = 0;
|
|
50
|
+
let x = 0;
|
|
51
|
+
console.log(rest, _nColumns, width);
|
|
52
|
+
let reducedWidth = _nColumns;
|
|
53
|
+
if ("overlap" in division) {
|
|
54
|
+
const overlap = division.overlap;
|
|
55
|
+
_nColumns = Math.min(_nColumns, overlap.nColumns);
|
|
56
|
+
columnIx = overlap.column;
|
|
57
|
+
reducedWidth = width / _nColumns;
|
|
58
|
+
x = columnIx * width / _nColumns;
|
|
59
|
+
}
|
|
46
60
|
return h__default.default(composite.TrackedLabeledUnit, {
|
|
47
61
|
division,
|
|
48
62
|
...rest,
|
package/dist/units/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/units/index.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n LithologyColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { UnitNamesColumn } from \"./names\";\nimport { ICompositeUnitProps } from \"./composite\";\nimport { UnitBoxes, UnitProps } from \"./boxes\";\nimport { useColumnLayout } from \"@macrostrat/column-components\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { getMixedUnitColor } from \"./colors\";\nimport { TrackedLabeledUnit } from \"./composite\";\nimport { useEnvironments, useLithologies } from \"@macrostrat/data-provider\";\nimport { useMemo } from \"react\";\nimport { resolveID } from \"./resolvers\";\nimport { Lithology } from \"@macrostrat/api-types\";\n\nexport * from \"./composite\";\nexport * from \"./types\";\nexport * from \"./colors\";\n\nexport function UnitsColumn({ width = 100 }) {\n /*\n A column showing units with USGS color fill\n */\n return h(LithologyColumn, { width }, h(UnitBoxes));\n}\n\nexport function SimpleUnitsColumn(props: ICompositeUnitProps) {\n /*\n A column with units and names either\n overlapping or offset to the right\n */\n const { columnWidth, width, gutterWidth = 0, labelOffset = 30 } = props;\n\n return h([\n h(UnitsColumn, {\n width: columnWidth,\n }),\n h(UnitNamesColumn, {\n transform: `translate(${columnWidth + gutterWidth})`,\n paddingLeft: labelOffset,\n width: width - columnWidth - gutterWidth,\n }),\n ]);\n}\n\nexport function BasicUnitComponent({ division, ...rest }) {\n /** A unit that allows directly setting colors and patterns. */\n\n return h(UnitComponent, {\n division,\n ...rest,\n backgroundColor: division.color,\n patternID: division.patternID,\n });\n}\n\nexport function UnitComponent({
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/units/index.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n LithologyColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { UnitNamesColumn } from \"./names\";\nimport { ICompositeUnitProps } from \"./composite\";\nimport { UnitBoxes, UnitProps } from \"./boxes\";\nimport { useColumnLayout } from \"@macrostrat/column-components\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { getMixedUnitColor } from \"./colors\";\nimport { TrackedLabeledUnit } from \"./composite\";\nimport { useEnvironments, useLithologies } from \"@macrostrat/data-provider\";\nimport { useMemo } from \"react\";\nimport { resolveID } from \"./resolvers\";\nimport { BaseUnit, Lithology } from \"@macrostrat/api-types\";\nimport { UnitWithDefinedOverlap } from \"../prepare-units/helpers.ts\";\n\nexport * from \"./composite\";\nexport * from \"./types\";\nexport * from \"./colors\";\n\nexport function UnitsColumn({ width = 100 }) {\n /*\n A column showing units with USGS color fill\n */\n return h(LithologyColumn, { width }, h(UnitBoxes));\n}\n\nexport function SimpleUnitsColumn(props: ICompositeUnitProps) {\n /*\n A column with units and names either\n overlapping or offset to the right\n */\n const { columnWidth, width, gutterWidth = 0, labelOffset = 30 } = props;\n\n return h([\n h(UnitsColumn, {\n width: columnWidth,\n }),\n h(UnitNamesColumn, {\n transform: `translate(${columnWidth + gutterWidth})`,\n paddingLeft: labelOffset,\n width: width - columnWidth - gutterWidth,\n }),\n ]);\n}\n\nexport function BasicUnitComponent({ division, ...rest }) {\n /** A unit that allows directly setting colors and patterns. */\n\n return h(UnitComponent, {\n division,\n ...rest,\n backgroundColor: division.color,\n patternID: division.patternID,\n });\n}\n\ninterface UnitComponentProps<T extends BaseUnit> {\n division: UnitWithDefinedOverlap<T> | T;\n nColumns: number;\n width?: number;\n}\n\nexport function UnitComponent<T extends BaseUnit>({\n division,\n nColumns = 2,\n ...rest\n}: UnitComponentProps<T>) {\n const width = rest.width ?? useColumnLayout()?.width;\n\n let _nColumns = nColumns;\n if (isNaN(_nColumns)) {\n _nColumns = 2;\n }\n let columnIx = 0;\n let x = 0;\n\n console.log(rest, _nColumns, width);\n\n let reducedWidth = _nColumns;\n //const nOverlappingUnits = division.overlappingUnits?.length ?? 0;\n if (\"overlap\" in division) {\n const overlap = division.overlap;\n _nColumns = Math.min(_nColumns, overlap.nColumns);\n columnIx = overlap.column;\n reducedWidth = width / _nColumns;\n x = (columnIx * width) / _nColumns;\n }\n return h(TrackedLabeledUnit, {\n division,\n ...rest,\n width: reducedWidth,\n x,\n });\n}\n\ninterface UnitColorOptions {\n asBackground?: boolean;\n}\n\nexport function useUnitColor(unit, opts: UnitColorOptions = {}): string | null {\n /** Get the color for a unit based on its lithology */\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || lithMap == null) return null;\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, lithMap, inDarkMode, asBackground]);\n}\n\nexport function ColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColor(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nexport function useUnitColorByEnvironment(\n unit,\n opts: UnitColorOptions = {},\n): string | null {\n /** Get the color for a unit based on its lithology */\n const environmentMap = useEnvironments();\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || environmentMap == null) return null;\n let c = getMixedUnitColor(unit, environmentMap, inDarkMode, asBackground, {\n key: \"environ\",\n id_key: \"environ_id\",\n });\n if (c != null) {\n return c;\n }\n // Fallback to lithology color if no environment color is found\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, environmentMap, lithMap, inDarkMode, asBackground]);\n}\n\nexport function EnvironmentColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColorByEnvironment(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nfunction getPatternID(\n liths: Array<Lithology>,\n lithMap: Map<number, Lithology>,\n): string | null {\n if (lithMap == null || liths == null || liths.length == 0) {\n return null;\n }\n const patternIDs = new Set<string>();\n for (const lith of liths) {\n const lithData = lithMap.get(lith.lith_id);\n if (lithData) {\n patternIDs.add(`${lithData.fill}`);\n }\n }\n let id = patternIDs.values()[0];\n if (id == \"0\") return null;\n return id;\n}\n"],"names":["h","LithologyColumn","UnitBoxes","UnitNamesColumn","useColumnLayout","TrackedLabeledUnit","useLithologies","useInDarkMode","useMemo","getMixedUnitColor","resolveID","useGeologicPattern","useEnvironments"],"mappings":";;;;;;;;;;;;;;AAsBO,SAAS,YAAY,EAAE,QAAQ,OAAO;AAI3C,SAAOA,WAAAA,QAAEC,iBAAAA,iBAAiB,EAAE,SAASD,WAAAA,QAAEE,MAAAA,SAAS,CAAC;AACnD;AAEO,SAAS,kBAAkB,OAA4B;AAK5D,QAAM,EAAE,aAAa,OAAO,cAAc,GAAG,cAAc,OAAO;AAElE,SAAOF,mBAAE;AAAA,IACPA,WAAAA,QAAE,aAAa;AAAA,MACb,OAAO;AAAA,IAAA,CACR;AAAA,IACDA,WAAAA,QAAEG,MAAAA,iBAAiB;AAAA,MACjB,WAAW,aAAa,cAAc,WAAW;AAAA,MACjD,aAAa;AAAA,MACb,OAAO,QAAQ,cAAc;AAAA,IAAA,CAC9B;AAAA,EAAA,CACF;AACH;AAEO,SAAS,mBAAmB,EAAE,UAAU,GAAG,QAAQ;AAGxD,SAAOH,WAAAA,QAAE,eAAe;AAAA,IACtB;AAAA,IACA,GAAG;AAAA,IACH,iBAAiB,SAAS;AAAA,IAC1B,WAAW,SAAS;AAAA,EAAA,CACrB;AACH;AAQO,S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G;AAAA,EAAA,CACJ;AACH;AAEO,SAAS,0BACd,MACA,OAAyB,IACV;AAEf,QAAM,iBAAiBY,aAAAA,gBAAA;AACvB,QAAM,UAAUN,aAAAA,eAAA;AAChB,QAAM,aAAaC,aAAAA,cAAA;AACnB,QAAM,EAAE,eAAe,KAAA,IAAS;AAEhC,SAAOC,MAAAA,QAAQ,MAAM;AACnB,QAAI,QAAQ,QAAQ,kBAAkB,KAAM,QAAO;AACnD,QAAI,IAAIC,OAAAA,kBAAkB,MAAM,gBAAgB,YAAY,cAAc;AAAA,MACxE,KAAK;AAAA,MACL,QAAQ;AAAA,IAAA,CACT;AACD,QAAI,KAAK,MAAM;AACb,aAAO;AAAA,IACT;AAEA,WAAOA,OAAAA,kBAAkB,MAAM,SAAS,YAAY,YAAY;AAAA,EAClE,GAAG,CAAC,MAAM,SAAS,gBAAgB,SAAS,YAAY,YAAY,CAAC;AACvE;AAEO,SAAS,gCAAgC,OAAO;AAGrD,QAAM,kBAAkB,0BAA0B,MAAM,QAAQ;AAEhE,QAAM,YAAYD,MAAAA,QAAQ,MAAM;AAC9B,WAAOE,UAAAA,UAAU,MAAM,QAAQ;AAAA,EACjC,GAAG,CAAC,MAAM,UAAU,OAAO,CAAC;AAE5B,QAAM,OAAOC,iBAAAA,mBAAmB,SAAS;AAEzC,SAAOX,WAAAA,QAAE,eAAe;AAAA,IACtB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,CACJ;AACH;;;;;;;;;;;;;;;;;;;"}
|
package/dist/units/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ICompositeUnitProps } from './composite';
|
|
2
|
+
import { BaseUnit } from '@macrostrat/api-types';
|
|
3
|
+
import { UnitWithDefinedOverlap } from '../prepare-units/helpers.ts';
|
|
2
4
|
export * from './composite';
|
|
3
5
|
export * from './types';
|
|
4
6
|
export * from './colors';
|
|
@@ -9,16 +11,13 @@ export declare function SimpleUnitsColumn(props: ICompositeUnitProps): import('r
|
|
|
9
11
|
export declare function BasicUnitComponent({ division, ...rest }: {
|
|
10
12
|
[x: string]: any;
|
|
11
13
|
division: any;
|
|
12
|
-
}): import('react').FunctionComponentElement<
|
|
13
|
-
|
|
14
|
-
division:
|
|
15
|
-
nColumns
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
division: any;
|
|
20
|
-
nColumns?: number | undefined;
|
|
21
|
-
}): import('react').FunctionComponentElement<{
|
|
14
|
+
}): import('react').FunctionComponentElement<UnitComponentProps<BaseUnit>>;
|
|
15
|
+
interface UnitComponentProps<T extends BaseUnit> {
|
|
16
|
+
division: UnitWithDefinedOverlap<T> | T;
|
|
17
|
+
nColumns: number;
|
|
18
|
+
width?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function UnitComponent<T extends BaseUnit>({ division, nColumns, ...rest }: UnitComponentProps<T>): import('react').FunctionComponentElement<{
|
|
22
21
|
[x: string]: any;
|
|
23
22
|
division: any;
|
|
24
23
|
nameForDivision?: ((div: any) => any) | undefined;
|
|
@@ -27,14 +26,6 @@ interface UnitColorOptions {
|
|
|
27
26
|
asBackground?: boolean;
|
|
28
27
|
}
|
|
29
28
|
export declare function useUnitColor(unit: any, opts?: UnitColorOptions): string | null;
|
|
30
|
-
export declare function ColoredUnitComponent(props: any): import('react').FunctionComponentElement<
|
|
31
|
-
[x: string]: any;
|
|
32
|
-
division: any;
|
|
33
|
-
nColumns?: number | undefined;
|
|
34
|
-
}>;
|
|
29
|
+
export declare function ColoredUnitComponent(props: any): import('react').FunctionComponentElement<UnitComponentProps<BaseUnit>>;
|
|
35
30
|
export declare function useUnitColorByEnvironment(unit: any, opts?: UnitColorOptions): string | null;
|
|
36
|
-
export declare function EnvironmentColoredUnitComponent(props: any): import('react').FunctionComponentElement<
|
|
37
|
-
[x: string]: any;
|
|
38
|
-
division: any;
|
|
39
|
-
nColumns?: number | undefined;
|
|
40
|
-
}>;
|
|
31
|
+
export declare function EnvironmentColoredUnitComponent(props: any): import('react').FunctionComponentElement<UnitComponentProps<BaseUnit>>;
|