@macrostrat/column-views 3.6.1 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/dist/column-views.css +118 -89
- package/dist/column.cjs +1 -2
- package/dist/column.cjs.map +1 -1
- package/dist/column.js +1 -2
- package/dist/column.js.map +1 -1
- package/dist/column.module.sass.cjs +15 -15
- package/dist/column.module.sass.js +15 -15
- package/dist/correlation-chart/main.cjs +136 -34
- package/dist/correlation-chart/main.cjs.map +1 -1
- package/dist/correlation-chart/main.d.ts +33 -2
- package/dist/correlation-chart/main.js +118 -15
- package/dist/correlation-chart/main.js.map +1 -1
- package/dist/correlation-chart/main.module.sass.cjs +23 -20
- package/dist/correlation-chart/main.module.sass.cjs.map +1 -1
- package/dist/correlation-chart/main.module.sass.js +23 -20
- package/dist/correlation-chart/main.module.sass.js.map +1 -1
- package/dist/correlation-chart/prepare-data.cjs +0 -1
- package/dist/correlation-chart/prepare-data.cjs.map +1 -1
- package/dist/correlation-chart/prepare-data.js +0 -1
- package/dist/correlation-chart/prepare-data.js.map +1 -1
- package/dist/data-provider/unit-selection.cjs +4 -1
- package/dist/data-provider/unit-selection.cjs.map +1 -1
- package/dist/data-provider/unit-selection.d.ts +1 -1
- package/dist/data-provider/unit-selection.js +4 -1
- package/dist/data-provider/unit-selection.js.map +1 -1
- package/dist/index.cjs +14 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -2
- package/dist/maps/column-correlation/core.cjs +127 -6
- package/dist/maps/column-correlation/core.cjs.map +1 -1
- package/dist/maps/column-correlation/core.js +128 -7
- package/dist/maps/column-correlation/core.js.map +1 -1
- package/dist/maps/column-correlation/state.cjs +63 -2
- package/dist/maps/column-correlation/state.cjs.map +1 -1
- package/dist/maps/column-correlation/state.d.ts +31 -1
- package/dist/maps/column-correlation/state.js +63 -2
- package/dist/maps/column-correlation/state.js.map +1 -1
- package/dist/maps/layers/columns.cjs +5 -1
- package/dist/maps/layers/columns.cjs.map +1 -1
- package/dist/maps/layers/columns.js +5 -1
- package/dist/maps/layers/columns.js.map +1 -1
- package/dist/section.cjs +8 -2
- package/dist/section.cjs.map +1 -1
- package/dist/section.d.ts +2 -0
- package/dist/section.js +8 -2
- package/dist/section.js.map +1 -1
- package/dist/unit-details/age-range.cjs +2 -1
- package/dist/unit-details/age-range.cjs.map +1 -1
- package/dist/unit-details/age-range.js +2 -1
- package/dist/unit-details/age-range.js.map +1 -1
- package/dist/unit-details/index.d.ts +1 -1
- package/dist/unit-details/panel.cjs +2 -3
- package/dist/unit-details/panel.cjs.map +1 -1
- package/dist/unit-details/panel.js +1 -2
- package/dist/unit-details/panel.js.map +1 -1
- package/dist/unit-details/panel.module.sass.cjs +18 -22
- package/dist/unit-details/panel.module.sass.cjs.map +1 -1
- package/dist/unit-details/panel.module.sass.js +18 -22
- package/dist/unit-details/panel.module.sass.js.map +1 -1
- package/dist/unit-details/strat-names.cjs +1 -2
- package/dist/unit-details/strat-names.cjs.map +1 -1
- package/dist/unit-details/strat-names.js +1 -2
- package/dist/unit-details/strat-names.js.map +1 -1
- package/dist/units/boxes.cjs +2 -1
- package/dist/units/boxes.cjs.map +1 -1
- package/dist/units/boxes.js +2 -1
- package/dist/units/boxes.js.map +1 -1
- package/package.json +7 -7
- package/src/column.module.sass +6 -0
- package/src/correlation-chart/main.module.sass +46 -2
- package/src/correlation-chart/main.ts +180 -9
- package/src/correlation-chart/prepare-data.ts +0 -1
- package/src/data-provider/unit-selection.ts +13 -2
- package/src/maps/column-correlation/column-correlation-map.stories.ts +12 -0
- package/src/maps/column-correlation/core.ts +155 -9
- package/src/maps/column-correlation/state.ts +110 -2
- package/src/maps/layers/columns.ts +7 -1
- package/src/section.ts +9 -1
- package/src/unit-details/age-range.ts +3 -1
- package/src/unit-details/index.ts +7 -1
- package/src/unit-details/panel.module.sass +0 -8
- package/src/unit-details/panel.ts +6 -6
- package/src/unit-details/strat-names.ts +1 -1
- package/src/units/boxes.ts +4 -2
- package/dist/correlation-chart/stories/utils.d.ts +0 -6
- package/dist/unit-details/identifiers.cjs +0 -56
- package/dist/unit-details/identifiers.cjs.map +0 -1
- package/dist/unit-details/identifiers.d.ts +0 -31
- package/dist/unit-details/identifiers.js +0 -54
- package/dist/unit-details/identifiers.js.map +0 -1
- package/src/correlation-chart/stories/correlation-chart.stories.ts +0 -228
- package/src/correlation-chart/stories/namibia-correlation.stories.ts +0 -151
- package/src/correlation-chart/stories/stories.module.sass +0 -18
- package/src/correlation-chart/stories/utils.ts +0 -24
- package/src/unit-details/identifiers.ts +0 -67
|
@@ -1,7 +1,7 @@
|
|
|
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 { DataField, MacrostratInteractionProvider, Parenthetical, Value, LithologyList, EnvironmentsList, LithologyTagFeature, useInteractionManager, ItemList } from "@macrostrat/data-components";
|
|
4
|
+
import { DataField, MacrostratInteractionProvider, Parenthetical, Value, LithologyList, EnvironmentsList, LithologyTagFeature, Identifier, useInteractionManager, ItemList, UnitIdentifier } from "@macrostrat/data-components";
|
|
5
5
|
import { useMacrostratData, useMacrostratDefs, useMacrostratColumnInfo } from "@macrostrat/data-provider";
|
|
6
6
|
import { defaultNameFunction } from "../units/names.js";
|
|
7
7
|
import classNames from "classnames";
|
|
@@ -9,7 +9,6 @@ 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
11
|
import { StratNameField } from "./strat-names.js";
|
|
12
|
-
import { Identifier, UnitIdentifier } from "./identifiers.js";
|
|
13
12
|
import { useColumnUnitsMap } from "../data-provider/store.js";
|
|
14
13
|
function UnitDetailsPanel({
|
|
15
14
|
unit,
|
|
@@ -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 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,gBAA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aACA,SACA;AACA,SAAO,aAAa,IAAI,CAAC,SAAS;AAChC,WAAO;AAAA,MACL,GAAI,SAAS,IAAI,KAAK,OAAO,KAAK,CAAA;AAAA;AAAA,MAClC,GAAG;AAAA;AAAA,IAAA;AAAA,EAEP,CAAC;AACH;AAEA,SAAS,WAAW,EAAE,OAAO,YAAY,SAAS;AAChD,QAAM,WAAW,kBAAA;AAEjB,QAAM,qBAAqB,sBAAA;AAE3B,QAAM,WAAuB,QAAQ,MAAM;AACzC,UAAM,KAAK,MAAM,OAAO,CAAC,MAAM,KAAK,CAAC;AACrC,QAAI,WAAW;AACb,aAAO,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;"}
|
|
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 {\n Identifier,\n UnitIdentifier,\n UnitInfo,\n} from \"@macrostrat/data-components\";\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 | Environment | UnitLong | Interval | { 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":";;;;;;;;;;;;AAyDO,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,K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AO,KAAK,CAAA;AAAA;AAAA,MAClC,GAAG;AAAA;AAAA,IAAA;AAAA,EAEP,CAAC;AACH;AAEA,SAAS,WAAW,EAAE,OAAO,YAAY,SAAS;AAChD,QAAM,WAAW,kBAAA;AAEjB,QAAM,qBAAqB,sBAAA;AAE3B,QAAM,WAAuB,QAAQ,MAAM;AACzC,UAAM,KAAK,MAAM,OAAO,CAAC,MAAM,KAAK,CAAC;AACrC,QAAI,WAAW;AACb,aAAO,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;"}
|
|
@@ -3,40 +3,36 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
3
3
|
const h$1 = require("@macrostrat/hyper");
|
|
4
4
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
5
5
|
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
6
|
-
const spacer = "
|
|
7
|
-
const item = "
|
|
8
|
-
const proportion = "
|
|
9
|
-
const sep = "
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const clickable = "_clickable_ue390_97";
|
|
6
|
+
const spacer = "_spacer_arfxf_43";
|
|
7
|
+
const item = "_item_arfxf_61";
|
|
8
|
+
const proportion = "_proportion_arfxf_68";
|
|
9
|
+
const sep = "_sep_arfxf_68";
|
|
10
|
+
const refs = "_refs_arfxf_82";
|
|
11
|
+
const clickable = "_clickable_arfxf_88";
|
|
13
12
|
const styles = {
|
|
14
|
-
"legend-panel-header": "_legend-panel-
|
|
15
|
-
"title-container": "_title-
|
|
16
|
-
"hidden-actions-container": "_hidden-actions-
|
|
17
|
-
"unit-id": "_unit-
|
|
13
|
+
"legend-panel-header": "_legend-panel-header_arfxf_1",
|
|
14
|
+
"title-container": "_title-container_arfxf_15",
|
|
15
|
+
"hidden-actions-container": "_hidden-actions-container_arfxf_22",
|
|
16
|
+
"unit-id": "_unit-id_arfxf_39",
|
|
18
17
|
spacer,
|
|
19
|
-
"unit-details-panel": "_unit-details-
|
|
20
|
-
"unit-details-content-holder": "_unit-details-content-
|
|
21
|
-
"unit-details-content": "_unit-details-
|
|
22
|
-
"units-list": "_units-
|
|
18
|
+
"unit-details-panel": "_unit-details-panel_arfxf_47",
|
|
19
|
+
"unit-details-content-holder": "_unit-details-content-holder_arfxf_51",
|
|
20
|
+
"unit-details-content": "_unit-details-content_arfxf_51",
|
|
21
|
+
"units-list": "_units-list_arfxf_61",
|
|
23
22
|
item,
|
|
24
23
|
proportion,
|
|
25
24
|
sep,
|
|
26
|
-
"no-units": "_no-
|
|
27
|
-
"strat-name-text": "_strat-name-
|
|
28
|
-
"
|
|
29
|
-
identifier,
|
|
30
|
-
"color-swatch": "_color-swatch_ue390_82",
|
|
25
|
+
"no-units": "_no-units_arfxf_68",
|
|
26
|
+
"strat-name-text": "_strat-name-text_arfxf_68",
|
|
27
|
+
"color-swatch": "_color-swatch_arfxf_73",
|
|
31
28
|
refs,
|
|
32
29
|
clickable,
|
|
33
|
-
"hidden-actions": "_hidden-
|
|
30
|
+
"hidden-actions": "_hidden-actions_arfxf_22"
|
|
34
31
|
};
|
|
35
32
|
let h = h__default.default.styled(styles);
|
|
36
33
|
Object.assign(h, styles);
|
|
37
34
|
exports.clickable = clickable;
|
|
38
35
|
exports.default = h;
|
|
39
|
-
exports.identifier = identifier;
|
|
40
36
|
exports.item = item;
|
|
41
37
|
exports.proportion = proportion;
|
|
42
38
|
exports.refs = refs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"panel.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,39 +1,35 @@
|
|
|
1
1
|
import h$1 from "@macrostrat/hyper";
|
|
2
|
-
const spacer = "
|
|
3
|
-
const item = "
|
|
4
|
-
const proportion = "
|
|
5
|
-
const sep = "
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const clickable = "_clickable_ue390_97";
|
|
2
|
+
const spacer = "_spacer_arfxf_43";
|
|
3
|
+
const item = "_item_arfxf_61";
|
|
4
|
+
const proportion = "_proportion_arfxf_68";
|
|
5
|
+
const sep = "_sep_arfxf_68";
|
|
6
|
+
const refs = "_refs_arfxf_82";
|
|
7
|
+
const clickable = "_clickable_arfxf_88";
|
|
9
8
|
const styles = {
|
|
10
|
-
"legend-panel-header": "_legend-panel-
|
|
11
|
-
"title-container": "_title-
|
|
12
|
-
"hidden-actions-container": "_hidden-actions-
|
|
13
|
-
"unit-id": "_unit-
|
|
9
|
+
"legend-panel-header": "_legend-panel-header_arfxf_1",
|
|
10
|
+
"title-container": "_title-container_arfxf_15",
|
|
11
|
+
"hidden-actions-container": "_hidden-actions-container_arfxf_22",
|
|
12
|
+
"unit-id": "_unit-id_arfxf_39",
|
|
14
13
|
spacer,
|
|
15
|
-
"unit-details-panel": "_unit-details-
|
|
16
|
-
"unit-details-content-holder": "_unit-details-content-
|
|
17
|
-
"unit-details-content": "_unit-details-
|
|
18
|
-
"units-list": "_units-
|
|
14
|
+
"unit-details-panel": "_unit-details-panel_arfxf_47",
|
|
15
|
+
"unit-details-content-holder": "_unit-details-content-holder_arfxf_51",
|
|
16
|
+
"unit-details-content": "_unit-details-content_arfxf_51",
|
|
17
|
+
"units-list": "_units-list_arfxf_61",
|
|
19
18
|
item,
|
|
20
19
|
proportion,
|
|
21
20
|
sep,
|
|
22
|
-
"no-units": "_no-
|
|
23
|
-
"strat-name-text": "_strat-name-
|
|
24
|
-
"
|
|
25
|
-
identifier,
|
|
26
|
-
"color-swatch": "_color-swatch_ue390_82",
|
|
21
|
+
"no-units": "_no-units_arfxf_68",
|
|
22
|
+
"strat-name-text": "_strat-name-text_arfxf_68",
|
|
23
|
+
"color-swatch": "_color-swatch_arfxf_73",
|
|
27
24
|
refs,
|
|
28
25
|
clickable,
|
|
29
|
-
"hidden-actions": "_hidden-
|
|
26
|
+
"hidden-actions": "_hidden-actions_arfxf_22"
|
|
30
27
|
};
|
|
31
28
|
let h = h$1.styled(styles);
|
|
32
29
|
Object.assign(h, styles);
|
|
33
30
|
export {
|
|
34
31
|
clickable,
|
|
35
32
|
h as default,
|
|
36
|
-
identifier,
|
|
37
33
|
item,
|
|
38
34
|
proportion,
|
|
39
35
|
refs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"panel.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -4,7 +4,6 @@ const dataComponents = require("@macrostrat/data-components");
|
|
|
4
4
|
const panel_module = require("./panel.module.sass.cjs");
|
|
5
5
|
const classNames = require("classnames");
|
|
6
6
|
const dataProvider = require("@macrostrat/data-provider");
|
|
7
|
-
const identifiers = require("./identifiers.cjs");
|
|
8
7
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
8
|
const classNames__default = /* @__PURE__ */ _interopDefault(classNames);
|
|
10
9
|
function useStratNameData(strat_name_id) {
|
|
@@ -19,7 +18,7 @@ function StratNameField(props) {
|
|
|
19
18
|
...baseInteractionProps,
|
|
20
19
|
...rest
|
|
21
20
|
};
|
|
22
|
-
let inner = panel_module.default(
|
|
21
|
+
let inner = panel_module.default(dataComponents.Identifier, { id: strat_name_id });
|
|
23
22
|
const name = data?.strat_name_long;
|
|
24
23
|
if (name != null) {
|
|
25
24
|
inner = panel_module.default("span.strat-name", name);
|
|
@@ -1 +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\";\
|
|
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 Identifier,\n} from \"@macrostrat/data-components\";\nimport h from \"./panel.module.sass\";\nimport classNames from \"classnames\";\nimport { useStratNames } from \"@macrostrat/data-provider\";\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,eAAAA,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;;"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { useInteractionProps, isClickable, DataField } from "@macrostrat/data-components";
|
|
1
|
+
import { useInteractionProps, Identifier, isClickable, DataField } from "@macrostrat/data-components";
|
|
2
2
|
import h from "./panel.module.sass.js";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import { useStratNames } from "@macrostrat/data-provider";
|
|
5
|
-
import { Identifier } from "./identifiers.js";
|
|
6
5
|
function useStratNameData(strat_name_id) {
|
|
7
6
|
const stratNames = useStratNames([strat_name_id]);
|
|
8
7
|
return stratNames?.[0];
|
|
@@ -1 +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\";\
|
|
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 Identifier,\n} from \"@macrostrat/data-components\";\nimport h from \"./panel.module.sass\";\nimport classNames from \"classnames\";\nimport { useStratNames } from \"@macrostrat/data-provider\";\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/boxes.cjs
CHANGED
|
@@ -60,7 +60,7 @@ function Unit(props) {
|
|
|
60
60
|
let _fill = fill ?? columnComponents.useGeologicPattern(_patternID, defaultFill);
|
|
61
61
|
const hasBackgroundColor = backgroundColor != null;
|
|
62
62
|
const _className = classNames__default.default(className, { colored: hasBackgroundColor });
|
|
63
|
-
const [ref, selected, onClick] = unitSelection.useUnitSelectionTarget(d);
|
|
63
|
+
const [ref, selected, onClick, linked] = unitSelection.useUnitSelectionTarget(d);
|
|
64
64
|
return h(
|
|
65
65
|
"g.unit",
|
|
66
66
|
{
|
|
@@ -84,6 +84,7 @@ function Unit(props) {
|
|
|
84
84
|
onClick,
|
|
85
85
|
className: "unit"
|
|
86
86
|
}),
|
|
87
|
+
h.if(linked)(UnitRect, { ...bounds, className: "linked-overlay" }),
|
|
87
88
|
h.if(selected)(UnitRect, { ...bounds, className: "selection-overlay" }),
|
|
88
89
|
//defs,
|
|
89
90
|
children
|
package/dist/units/boxes.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boxes.cjs","sources":["../../src/units/boxes.ts"],"sourcesContent":["import {\n ColumnAxisType,\n ColumnContext,\n ColumnLayoutContext,\n ForeignObject,\n PatternDefsProvider,\n useColumn,\n useGeologicPattern,\n zigZagBoxPath,\n} from \"@macrostrat/column-components\";\nimport { SizeAwareLabel, Clickable } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport { forwardRef, ReactNode, useContext, useMemo } from \"react\";\nimport { resolveID, scalePattern } from \"./resolvers\";\nimport { useUnitSelectionTarget } from \"../data-provider\";\nimport { useLithologies } from \"@macrostrat/data-provider\";\nimport { IUnit } from \"./types\";\nimport styles from \"./boxes.module.sass\";\nimport classNames from \"classnames\";\nimport { getUnitHeightRange } from \"../prepare-units/utils\";\nimport { getMixedUnitColor } from \"./colors\";\nimport type { RectBounds } from \"./types\";\n\nconst h = hyper.styled(styles);\n\ninterface UnitRectOptions {\n widthFraction?: number;\n axisType?: ColumnAxisType;\n // Padding to create overflow for zig-zags or other ornamented edges\n padding?: number;\n}\n\ninterface UnitProps extends Clickable, Partial<RectBounds>, UnitRectOptions {\n division: IUnit;\n resolveID?(IUnit): string;\n UUID?: string;\n defaultFill?: string;\n widthFraction?: number;\n children?: ReactNode;\n className?: string;\n fill?: string;\n backgroundColor?: string;\n patternColor?: string;\n patternID?: string | number;\n}\n\nexport interface LabeledUnitProps\n extends UnitRectOptions, Clickable, Partial<RectBounds> {\n division: IUnit;\n patternID?: string | number;\n label: string;\n onLabelUpdated?(label: string, shown: boolean);\n halfWidth?: boolean;\n showLabel?: boolean;\n backgroundColor?: string;\n}\n\nfunction useUnitRect(\n division: IUnit,\n options: UnitRectOptions = {},\n): RectBounds {\n const {\n widthFraction = 1,\n axisType = ColumnAxisType.AGE,\n padding = 0,\n } = options;\n const { scale } = useContext(ColumnContext);\n const { width } = useContext(ColumnLayoutContext);\n\n const [bottomHeight, topHeight] = getUnitHeightRange(division, axisType);\n\n const y = scale(topHeight);\n const height = Math.abs(scale(bottomHeight) - y);\n\n return {\n x: width * (1 - widthFraction) - padding,\n y: y - padding,\n height: height + padding * 2,\n width: widthFraction * width + padding * 2,\n };\n}\n\nexport function MinimalUnit(props) {\n const {\n division: d,\n children,\n className,\n widthFraction = 1,\n axisType: _, // not sure why this is brought in...\n nColumns: __,\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const lithMap = useLithologies();\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n };\n\n const backgroundColor = getMixedUnitColor(d, lithMap, null, false);\n\n const [ref, selected, onClick] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n \"--column-stroke-color\": backgroundColor,\n },\n },\n [\n h(\"rect.unit.background\", {\n ref,\n ...bounds,\n fill: backgroundColor,\n fillOpacity: 0.8,\n stroke: backgroundColor,\n onClick,\n }),\n h.if(selected)(\"rect.selection-overlay\", bounds),\n ],\n );\n}\n\nfunction Unit(props: UnitProps) {\n const {\n division: d,\n children,\n fill,\n defaultFill = \"transparent\",\n className,\n widthFraction = 1,\n backgroundColor,\n patternColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n\n const hasOverflowTop = d.t_clip_pos != null;\n const hasOverflowBottom = d.b_clip_pos != null;\n\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n overflowTop: hasOverflowTop,\n overflowBottom: hasOverflowBottom,\n };\n const _patternID = patternID ?? resolveID(d);\n let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);\n\n const hasBackgroundColor = backgroundColor != null;\n\n const _className = classNames(className, { colored: hasBackgroundColor });\n\n const [ref, selected, onClick] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className: _className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n },\n },\n [\n h(UnitRect, {\n ...bounds,\n fill: backgroundColor,\n onClick,\n className: \"background\",\n }),\n h(UnitRect, {\n ref,\n ...bounds,\n fill: _fill,\n //mask,\n onClick,\n className: \"unit\",\n }),\n h.if(selected)(UnitRect, { ...bounds, className: \"selection-overlay\" }),\n //defs,\n children,\n ],\n );\n}\n\ninterface UnitRectProps {\n x: number;\n y: number;\n width: number;\n height: number;\n className: string;\n // Used to determine if the rect should have a zig-zag edge on the top or bottom\n overflowTop?: boolean;\n overflowBottom?: boolean;\n [key: string]: any;\n}\n\nconst UnitRect = forwardRef((props: UnitRectProps, ref) => {\n const {\n x,\n y,\n width,\n height,\n overflowTop = false,\n overflowBottom = false,\n ...rest\n } = props;\n\n if (!overflowTop && !overflowBottom) {\n return h(\"rect\", {\n x,\n y,\n width,\n height,\n ref,\n ...rest,\n });\n } else {\n const d = zigZagBoxPath(x, y, width, height, overflowTop, overflowBottom);\n return h(\"path\", {\n d,\n ref,\n ...rest,\n });\n }\n});\n\nfunction LabeledUnit(props: LabeledUnitProps) {\n const {\n division,\n label,\n onLabelUpdated,\n widthFraction,\n showLabel = true,\n backgroundColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const bounds = {\n ...useUnitRect(division, { widthFraction, axisType }),\n ...baseBounds,\n };\n const { width, height } = bounds;\n return h(\n Unit,\n {\n className: \"labeled-unit\",\n division,\n backgroundColor,\n patternID,\n ...bounds,\n },\n [\n h.if(showLabel)(\n ForeignObject,\n { ...bounds, className: \"unit-label-container\" },\n h(SizeAwareLabel, {\n className: \"unit-overlay\",\n labelClassName: \"unit-label\",\n style: { width, height },\n label,\n onVisibilityChanged(viz) {\n onLabelUpdated(label, viz);\n },\n }),\n ),\n ],\n );\n}\n\nfunction UnitBoxes<T>(props: {\n unitComponent: React.FunctionComponent<{ division: T }>;\n unitComponentProps?: any;\n transformDivisions?(divisions: T[]): T[];\n transformDivision?: (\n division: any,\n index: number,\n divisions: any[],\n ) => T | null;\n}) {\n const { unitComponent = Unit, unitComponentProps = {} } = props;\n const { divisions } = useContext(ColumnContext);\n\n if (divisions.length == 0) {\n console.warn(\"No divisions found in column context\");\n return null;\n }\n\n const children = useMemo(() => {\n return divisions.map((division: any, i) => {\n // @ts-ignore\n return h(unitComponent, {\n division,\n key: division.unit_id,\n ...unitComponentProps,\n });\n });\n }, [divisions, unitComponent, unitComponentProps]);\n\n return h(\n PatternDefsProvider,\n { resolveID, scalePattern },\n h(\"g.divisions\", children),\n );\n}\n\nexport { LabeledUnit, Unit, UnitBoxes, UnitProps };\n"],"names":["hyper","styles","ColumnAxisType","useContext","ColumnContext","ColumnLayoutContext","getUnitHeightRange","useColumn","resolveID","useGeologicPattern","classNames","useUnitSelectionTarget","forwardRef","zigZagBoxPath","ForeignObject","SizeAwareLabel","useMemo","PatternDefsProvider","scalePattern"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAM,IAAIA,WAAAA,QAAM,OAAOC,oBAAM;AAkC7B,SAAS,YACP,UACA,UAA2B,IACf;AACZ,QAAM;AAAA,IACJ,gBAAgB;AAAA,IAChB,WAAWC,iBAAAA,eAAe;AAAA,IAC1B,UAAU;AAAA,EAAA,IACR;AACJ,QAAM,EAAE,MAAA,IAAUC,MAAAA,WAAWC,8BAAa;AAC1C,QAAM,EAAE,MAAA,IAAUD,MAAAA,WAAWE,oCAAmB;AAEhD,QAAM,CAAC,cAAc,SAAS,IAAIC,MAAAA,mBAAmB,UAAU,QAAQ;AAEvE,QAAM,IAAI,MAAM,SAAS;AACzB,QAAM,SAAS,KAAK,IAAI,MAAM,YAAY,IAAI,CAAC;AAE/C,SAAO;AAAA,IACL,GAAG,SAAS,IAAI,iBAAiB;AAAA,IACjC,GAAG,IAAI;AAAA,IACP,QAAQ,SAAS,UAAU;AAAA,IAC3B,OAAO,gBAAgB,QAAQ,UAAU;AAAA,EAAA;AAE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AA,CACD;AAAA,MAAA;AAAA,IACH;AAAA,EACF;AAEJ;AAEA,SAAS,UAAa,OASnB;AACD,QAAM,EAAE,gBAAgB,MAAM,qBAAqB,CAAA,MAAO;AAC1D,QAAM,EAAE,UAAA,IAAcZ,MAAAA,WAAWC,8BAAa;AAE9C,MAAI,UAAU,UAAU,GAAG;AACzB,YAAQ,KAAK,sCAAsC;AACnD,WAAO;AAAA,EACT;AAEA,QAAM,WAAWY,MAAAA,QAAQ,MAAM;AAC7B,WAAO,UAAU,IAAI,CAAC,UAAe,MAAM;AAEzC,aAAO,EAAE,eAAe;AAAA,QACtB;AAAA,QACA,KAAK,SAAS;AAAA,QACd,GAAG;AAAA,MAAA,CACJ;AAAA,IACH,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,eAAe,kBAAkB,CAAC;AAEjD,SAAO;AAAA,IACLC,iBAAAA;AAAAA,IACA,EAAA,WAAET,UAAAA,yBAAWU,UAAAA,aAAA;AAAA,IACb,EAAE,eAAe,QAAQ;AAAA,EAAA;AAE7B;;;;"}
|
|
1
|
+
{"version":3,"file":"boxes.cjs","sources":["../../src/units/boxes.ts"],"sourcesContent":["import {\n ColumnAxisType,\n ColumnContext,\n ColumnLayoutContext,\n ForeignObject,\n PatternDefsProvider,\n useColumn,\n useGeologicPattern,\n zigZagBoxPath,\n} from \"@macrostrat/column-components\";\nimport { SizeAwareLabel, Clickable } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport { forwardRef, ReactNode, useContext, useMemo } from \"react\";\nimport { resolveID, scalePattern } from \"./resolvers\";\nimport { useUnitSelectionTarget } from \"../data-provider\";\nimport { useLithologies } from \"@macrostrat/data-provider\";\nimport { IUnit } from \"./types\";\nimport styles from \"./boxes.module.sass\";\nimport classNames from \"classnames\";\nimport { getUnitHeightRange } from \"../prepare-units/utils\";\nimport { getMixedUnitColor } from \"./colors\";\nimport type { RectBounds } from \"./types\";\n\nconst h = hyper.styled(styles);\n\ninterface UnitRectOptions {\n widthFraction?: number;\n axisType?: ColumnAxisType;\n // Padding to create overflow for zig-zags or other ornamented edges\n padding?: number;\n}\n\ninterface UnitProps extends Clickable, Partial<RectBounds>, UnitRectOptions {\n division: IUnit;\n resolveID?(IUnit): string;\n UUID?: string;\n defaultFill?: string;\n widthFraction?: number;\n children?: ReactNode;\n className?: string;\n fill?: string;\n backgroundColor?: string;\n patternColor?: string;\n patternID?: string | number;\n}\n\nexport interface LabeledUnitProps\n extends UnitRectOptions, Clickable, Partial<RectBounds> {\n division: IUnit;\n patternID?: string | number;\n label: string;\n onLabelUpdated?(label: string, shown: boolean);\n halfWidth?: boolean;\n showLabel?: boolean;\n backgroundColor?: string;\n}\n\nfunction useUnitRect(\n division: IUnit,\n options: UnitRectOptions = {},\n): RectBounds {\n const {\n widthFraction = 1,\n axisType = ColumnAxisType.AGE,\n padding = 0,\n } = options;\n const { scale } = useContext(ColumnContext);\n const { width } = useContext(ColumnLayoutContext);\n\n const [bottomHeight, topHeight] = getUnitHeightRange(division, axisType);\n\n const y = scale(topHeight);\n const height = Math.abs(scale(bottomHeight) - y);\n\n return {\n x: width * (1 - widthFraction) - padding,\n y: y - padding,\n height: height + padding * 2,\n width: widthFraction * width + padding * 2,\n };\n}\n\nexport function MinimalUnit(props) {\n const {\n division: d,\n children,\n className,\n widthFraction = 1,\n axisType: _, // not sure why this is brought in...\n nColumns: __,\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const lithMap = useLithologies();\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n };\n\n const backgroundColor = getMixedUnitColor(d, lithMap, null, false);\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n \"--column-stroke-color\": backgroundColor,\n },\n },\n [\n h(\"rect.unit.background\", {\n ref,\n ...bounds,\n fill: backgroundColor,\n fillOpacity: 0.8,\n stroke: backgroundColor,\n onClick,\n }),\n h.if(linked)(\"rect.linked-overlay\", bounds),\n h.if(selected)(\"rect.selection-overlay\", bounds),\n ],\n );\n}\n\nfunction Unit(props: UnitProps) {\n const {\n division: d,\n children,\n fill,\n defaultFill = \"transparent\",\n className,\n widthFraction = 1,\n backgroundColor,\n patternColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n\n const hasOverflowTop = d.t_clip_pos != null;\n const hasOverflowBottom = d.b_clip_pos != null;\n\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n overflowTop: hasOverflowTop,\n overflowBottom: hasOverflowBottom,\n };\n const _patternID = patternID ?? resolveID(d);\n let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);\n\n const hasBackgroundColor = backgroundColor != null;\n\n const _className = classNames(className, { colored: hasBackgroundColor });\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className: _className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n },\n },\n [\n h(UnitRect, {\n ...bounds,\n fill: backgroundColor,\n onClick,\n className: \"background\",\n }),\n h(UnitRect, {\n ref,\n ...bounds,\n fill: _fill,\n //mask,\n onClick,\n className: \"unit\",\n }),\n h.if(linked)(UnitRect, { ...bounds, className: \"linked-overlay\" }),\n h.if(selected)(UnitRect, { ...bounds, className: \"selection-overlay\" }),\n //defs,\n children,\n ],\n );\n}\n\ninterface UnitRectProps {\n x: number;\n y: number;\n width: number;\n height: number;\n className: string;\n // Used to determine if the rect should have a zig-zag edge on the top or bottom\n overflowTop?: boolean;\n overflowBottom?: boolean;\n [key: string]: any;\n}\n\nconst UnitRect = forwardRef((props: UnitRectProps, ref) => {\n const {\n x,\n y,\n width,\n height,\n overflowTop = false,\n overflowBottom = false,\n ...rest\n } = props;\n\n if (!overflowTop && !overflowBottom) {\n return h(\"rect\", {\n x,\n y,\n width,\n height,\n ref,\n ...rest,\n });\n } else {\n const d = zigZagBoxPath(x, y, width, height, overflowTop, overflowBottom);\n return h(\"path\", {\n d,\n ref,\n ...rest,\n });\n }\n});\n\nfunction LabeledUnit(props: LabeledUnitProps) {\n const {\n division,\n label,\n onLabelUpdated,\n widthFraction,\n showLabel = true,\n backgroundColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const bounds = {\n ...useUnitRect(division, { widthFraction, axisType }),\n ...baseBounds,\n };\n const { width, height } = bounds;\n return h(\n Unit,\n {\n className: \"labeled-unit\",\n division,\n backgroundColor,\n patternID,\n ...bounds,\n },\n [\n h.if(showLabel)(\n ForeignObject,\n { ...bounds, className: \"unit-label-container\" },\n h(SizeAwareLabel, {\n className: \"unit-overlay\",\n labelClassName: \"unit-label\",\n style: { width, height },\n label,\n onVisibilityChanged(viz) {\n onLabelUpdated(label, viz);\n },\n }),\n ),\n ],\n );\n}\n\nfunction UnitBoxes<T>(props: {\n unitComponent: React.FunctionComponent<{ division: T }>;\n unitComponentProps?: any;\n transformDivisions?(divisions: T[]): T[];\n transformDivision?: (\n division: any,\n index: number,\n divisions: any[],\n ) => T | null;\n}) {\n const { unitComponent = Unit, unitComponentProps = {} } = props;\n const { divisions } = useContext(ColumnContext);\n\n if (divisions.length == 0) {\n console.warn(\"No divisions found in column context\");\n return null;\n }\n\n const children = useMemo(() => {\n return divisions.map((division: any, i) => {\n // @ts-ignore\n return h(unitComponent, {\n division,\n key: division.unit_id,\n ...unitComponentProps,\n });\n });\n }, [divisions, unitComponent, unitComponentProps]);\n\n return h(\n PatternDefsProvider,\n { resolveID, scalePattern },\n h(\"g.divisions\", children),\n );\n}\n\nexport { LabeledUnit, Unit, UnitBoxes, UnitProps };\n"],"names":["hyper","styles","ColumnAxisType","useContext","ColumnContext","ColumnLayoutContext","getUnitHeightRange","useColumn","resolveID","useGeologicPattern","classNames","useUnitSelectionTarget","forwardRef","zigZagBoxPath","ForeignObject","SizeAwareLabel","useMemo","PatternDef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AC;AAEjD,SAAO;AAAA,IACLC,iBAAAA;AAAAA,IACA,EAAA,WAAET,UAAAA,yBAAWU,UAAAA,aAAA;AAAA,IACb,EAAE,eAAe,QAAQ;AAAA,EAAA;AAE7B;;;;"}
|
package/dist/units/boxes.js
CHANGED
|
@@ -55,7 +55,7 @@ function Unit(props) {
|
|
|
55
55
|
let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);
|
|
56
56
|
const hasBackgroundColor = backgroundColor != null;
|
|
57
57
|
const _className = classNames(className, { colored: hasBackgroundColor });
|
|
58
|
-
const [ref, selected, onClick] = useUnitSelectionTarget(d);
|
|
58
|
+
const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);
|
|
59
59
|
return h(
|
|
60
60
|
"g.unit",
|
|
61
61
|
{
|
|
@@ -79,6 +79,7 @@ function Unit(props) {
|
|
|
79
79
|
onClick,
|
|
80
80
|
className: "unit"
|
|
81
81
|
}),
|
|
82
|
+
h.if(linked)(UnitRect, { ...bounds, className: "linked-overlay" }),
|
|
82
83
|
h.if(selected)(UnitRect, { ...bounds, className: "selection-overlay" }),
|
|
83
84
|
//defs,
|
|
84
85
|
children
|
package/dist/units/boxes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boxes.js","sources":["../../src/units/boxes.ts"],"sourcesContent":["import {\n ColumnAxisType,\n ColumnContext,\n ColumnLayoutContext,\n ForeignObject,\n PatternDefsProvider,\n useColumn,\n useGeologicPattern,\n zigZagBoxPath,\n} from \"@macrostrat/column-components\";\nimport { SizeAwareLabel, Clickable } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport { forwardRef, ReactNode, useContext, useMemo } from \"react\";\nimport { resolveID, scalePattern } from \"./resolvers\";\nimport { useUnitSelectionTarget } from \"../data-provider\";\nimport { useLithologies } from \"@macrostrat/data-provider\";\nimport { IUnit } from \"./types\";\nimport styles from \"./boxes.module.sass\";\nimport classNames from \"classnames\";\nimport { getUnitHeightRange } from \"../prepare-units/utils\";\nimport { getMixedUnitColor } from \"./colors\";\nimport type { RectBounds } from \"./types\";\n\nconst h = hyper.styled(styles);\n\ninterface UnitRectOptions {\n widthFraction?: number;\n axisType?: ColumnAxisType;\n // Padding to create overflow for zig-zags or other ornamented edges\n padding?: number;\n}\n\ninterface UnitProps extends Clickable, Partial<RectBounds>, UnitRectOptions {\n division: IUnit;\n resolveID?(IUnit): string;\n UUID?: string;\n defaultFill?: string;\n widthFraction?: number;\n children?: ReactNode;\n className?: string;\n fill?: string;\n backgroundColor?: string;\n patternColor?: string;\n patternID?: string | number;\n}\n\nexport interface LabeledUnitProps\n extends UnitRectOptions, Clickable, Partial<RectBounds> {\n division: IUnit;\n patternID?: string | number;\n label: string;\n onLabelUpdated?(label: string, shown: boolean);\n halfWidth?: boolean;\n showLabel?: boolean;\n backgroundColor?: string;\n}\n\nfunction useUnitRect(\n division: IUnit,\n options: UnitRectOptions = {},\n): RectBounds {\n const {\n widthFraction = 1,\n axisType = ColumnAxisType.AGE,\n padding = 0,\n } = options;\n const { scale } = useContext(ColumnContext);\n const { width } = useContext(ColumnLayoutContext);\n\n const [bottomHeight, topHeight] = getUnitHeightRange(division, axisType);\n\n const y = scale(topHeight);\n const height = Math.abs(scale(bottomHeight) - y);\n\n return {\n x: width * (1 - widthFraction) - padding,\n y: y - padding,\n height: height + padding * 2,\n width: widthFraction * width + padding * 2,\n };\n}\n\nexport function MinimalUnit(props) {\n const {\n division: d,\n children,\n className,\n widthFraction = 1,\n axisType: _, // not sure why this is brought in...\n nColumns: __,\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const lithMap = useLithologies();\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n };\n\n const backgroundColor = getMixedUnitColor(d, lithMap, null, false);\n\n const [ref, selected, onClick] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n \"--column-stroke-color\": backgroundColor,\n },\n },\n [\n h(\"rect.unit.background\", {\n ref,\n ...bounds,\n fill: backgroundColor,\n fillOpacity: 0.8,\n stroke: backgroundColor,\n onClick,\n }),\n h.if(selected)(\"rect.selection-overlay\", bounds),\n ],\n );\n}\n\nfunction Unit(props: UnitProps) {\n const {\n division: d,\n children,\n fill,\n defaultFill = \"transparent\",\n className,\n widthFraction = 1,\n backgroundColor,\n patternColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n\n const hasOverflowTop = d.t_clip_pos != null;\n const hasOverflowBottom = d.b_clip_pos != null;\n\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n overflowTop: hasOverflowTop,\n overflowBottom: hasOverflowBottom,\n };\n const _patternID = patternID ?? resolveID(d);\n let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);\n\n const hasBackgroundColor = backgroundColor != null;\n\n const _className = classNames(className, { colored: hasBackgroundColor });\n\n const [ref, selected, onClick] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className: _className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n },\n },\n [\n h(UnitRect, {\n ...bounds,\n fill: backgroundColor,\n onClick,\n className: \"background\",\n }),\n h(UnitRect, {\n ref,\n ...bounds,\n fill: _fill,\n //mask,\n onClick,\n className: \"unit\",\n }),\n h.if(selected)(UnitRect, { ...bounds, className: \"selection-overlay\" }),\n //defs,\n children,\n ],\n );\n}\n\ninterface UnitRectProps {\n x: number;\n y: number;\n width: number;\n height: number;\n className: string;\n // Used to determine if the rect should have a zig-zag edge on the top or bottom\n overflowTop?: boolean;\n overflowBottom?: boolean;\n [key: string]: any;\n}\n\nconst UnitRect = forwardRef((props: UnitRectProps, ref) => {\n const {\n x,\n y,\n width,\n height,\n overflowTop = false,\n overflowBottom = false,\n ...rest\n } = props;\n\n if (!overflowTop && !overflowBottom) {\n return h(\"rect\", {\n x,\n y,\n width,\n height,\n ref,\n ...rest,\n });\n } else {\n const d = zigZagBoxPath(x, y, width, height, overflowTop, overflowBottom);\n return h(\"path\", {\n d,\n ref,\n ...rest,\n });\n }\n});\n\nfunction LabeledUnit(props: LabeledUnitProps) {\n const {\n division,\n label,\n onLabelUpdated,\n widthFraction,\n showLabel = true,\n backgroundColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const bounds = {\n ...useUnitRect(division, { widthFraction, axisType }),\n ...baseBounds,\n };\n const { width, height } = bounds;\n return h(\n Unit,\n {\n className: \"labeled-unit\",\n division,\n backgroundColor,\n patternID,\n ...bounds,\n },\n [\n h.if(showLabel)(\n ForeignObject,\n { ...bounds, className: \"unit-label-container\" },\n h(SizeAwareLabel, {\n className: \"unit-overlay\",\n labelClassName: \"unit-label\",\n style: { width, height },\n label,\n onVisibilityChanged(viz) {\n onLabelUpdated(label, viz);\n },\n }),\n ),\n ],\n );\n}\n\nfunction UnitBoxes<T>(props: {\n unitComponent: React.FunctionComponent<{ division: T }>;\n unitComponentProps?: any;\n transformDivisions?(divisions: T[]): T[];\n transformDivision?: (\n division: any,\n index: number,\n divisions: any[],\n ) => T | null;\n}) {\n const { unitComponent = Unit, unitComponentProps = {} } = props;\n const { divisions } = useContext(ColumnContext);\n\n if (divisions.length == 0) {\n console.warn(\"No divisions found in column context\");\n return null;\n }\n\n const children = useMemo(() => {\n return divisions.map((division: any, i) => {\n // @ts-ignore\n return h(unitComponent, {\n division,\n key: division.unit_id,\n ...unitComponentProps,\n });\n });\n }, [divisions, unitComponent, unitComponentProps]);\n\n return h(\n PatternDefsProvider,\n { resolveID, scalePattern },\n h(\"g.divisions\", children),\n );\n}\n\nexport { LabeledUnit, Unit, UnitBoxes, UnitProps };\n"],"names":["hyper","styles"],"mappings":";;;;;;;;;;AAuBA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAkC7B,SAAS,YACP,UACA,UAA2B,IACf;AACZ,QAAM;AAAA,IACJ,g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AAC1B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA;AAAA,IAEL;AAAA,MACE,EAAE,GAAG,SAAS;AAAA,QACZ;AAAA,QACA,EAAE,GAAG,QAAQ,WAAW,uBAAA;AAAA,QACxB,EAAE,gBAAgB;AAAA,UAChB,WAAW;AAAA,UACX,gBAAgB;AAAA,UAChB,OAAO,EAAE,OAAO,OAAA;AAAA,UAChB;AAAA,UACA,oBAAoB,KAAK;AACvB,2BAAe,OAAO,GAAG;AAAA,UAC3B;AAAA,QAAA,CACD;AAAA,MAAA;AAAA,IACH;AAAA,EACF;AAEJ;AAEA,SAAS,UAAa,OASnB;AACD,QAAM,EAAE,gBAAgB,MAAM,qBAAqB,CAAA,MAAO;AAC1D,QAAM,EAAE,UAAA,IAAc,WAAW,aAAa;AAE9C,MAAI,UAAU,UAAU,GAAG;AACzB,YAAQ,KAAK,sCAAsC;AACnD,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,QAAQ,MAAM;AAC7B,WAAO,UAAU,IAAI,CAAC,UAAe,MAAM;AAEzC,aAAO,EAAE,eAAe;AAAA,QACtB;AAAA,QACA,KAAK,SAAS;AAAA,QACd,GAAG;AAAA,MAAA,CACJ;AAAA,IACH,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,eAAe,kBAAkB,CAAC;AAEjD,SAAO;AAAA,IACL;AAAA,IACA,EAAE,WAAW,aAAA;AAAA,IACb,EAAE,eAAe,QAAQ;AAAA,EAAA;AAE7B;"}
|
|
1
|
+
{"version":3,"file":"boxes.js","sources":["../../src/units/boxes.ts"],"sourcesContent":["import {\n ColumnAxisType,\n ColumnContext,\n ColumnLayoutContext,\n ForeignObject,\n PatternDefsProvider,\n useColumn,\n useGeologicPattern,\n zigZagBoxPath,\n} from \"@macrostrat/column-components\";\nimport { SizeAwareLabel, Clickable } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport { forwardRef, ReactNode, useContext, useMemo } from \"react\";\nimport { resolveID, scalePattern } from \"./resolvers\";\nimport { useUnitSelectionTarget } from \"../data-provider\";\nimport { useLithologies } from \"@macrostrat/data-provider\";\nimport { IUnit } from \"./types\";\nimport styles from \"./boxes.module.sass\";\nimport classNames from \"classnames\";\nimport { getUnitHeightRange } from \"../prepare-units/utils\";\nimport { getMixedUnitColor } from \"./colors\";\nimport type { RectBounds } from \"./types\";\n\nconst h = hyper.styled(styles);\n\ninterface UnitRectOptions {\n widthFraction?: number;\n axisType?: ColumnAxisType;\n // Padding to create overflow for zig-zags or other ornamented edges\n padding?: number;\n}\n\ninterface UnitProps extends Clickable, Partial<RectBounds>, UnitRectOptions {\n division: IUnit;\n resolveID?(IUnit): string;\n UUID?: string;\n defaultFill?: string;\n widthFraction?: number;\n children?: ReactNode;\n className?: string;\n fill?: string;\n backgroundColor?: string;\n patternColor?: string;\n patternID?: string | number;\n}\n\nexport interface LabeledUnitProps\n extends UnitRectOptions, Clickable, Partial<RectBounds> {\n division: IUnit;\n patternID?: string | number;\n label: string;\n onLabelUpdated?(label: string, shown: boolean);\n halfWidth?: boolean;\n showLabel?: boolean;\n backgroundColor?: string;\n}\n\nfunction useUnitRect(\n division: IUnit,\n options: UnitRectOptions = {},\n): RectBounds {\n const {\n widthFraction = 1,\n axisType = ColumnAxisType.AGE,\n padding = 0,\n } = options;\n const { scale } = useContext(ColumnContext);\n const { width } = useContext(ColumnLayoutContext);\n\n const [bottomHeight, topHeight] = getUnitHeightRange(division, axisType);\n\n const y = scale(topHeight);\n const height = Math.abs(scale(bottomHeight) - y);\n\n return {\n x: width * (1 - widthFraction) - padding,\n y: y - padding,\n height: height + padding * 2,\n width: widthFraction * width + padding * 2,\n };\n}\n\nexport function MinimalUnit(props) {\n const {\n division: d,\n children,\n className,\n widthFraction = 1,\n axisType: _, // not sure why this is brought in...\n nColumns: __,\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const lithMap = useLithologies();\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n };\n\n const backgroundColor = getMixedUnitColor(d, lithMap, null, false);\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n \"--column-stroke-color\": backgroundColor,\n },\n },\n [\n h(\"rect.unit.background\", {\n ref,\n ...bounds,\n fill: backgroundColor,\n fillOpacity: 0.8,\n stroke: backgroundColor,\n onClick,\n }),\n h.if(linked)(\"rect.linked-overlay\", bounds),\n h.if(selected)(\"rect.selection-overlay\", bounds),\n ],\n );\n}\n\nfunction Unit(props: UnitProps) {\n const {\n division: d,\n children,\n fill,\n defaultFill = \"transparent\",\n className,\n widthFraction = 1,\n backgroundColor,\n patternColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n\n const hasOverflowTop = d.t_clip_pos != null;\n const hasOverflowBottom = d.b_clip_pos != null;\n\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n overflowTop: hasOverflowTop,\n overflowBottom: hasOverflowBottom,\n };\n const _patternID = patternID ?? resolveID(d);\n let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);\n\n const hasBackgroundColor = backgroundColor != null;\n\n const _className = classNames(className, { colored: hasBackgroundColor });\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className: _className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n },\n },\n [\n h(UnitRect, {\n ...bounds,\n fill: backgroundColor,\n onClick,\n className: \"background\",\n }),\n h(UnitRect, {\n ref,\n ...bounds,\n fill: _fill,\n //mask,\n onClick,\n className: \"unit\",\n }),\n h.if(linked)(UnitRect, { ...bounds, className: \"linked-overlay\" }),\n h.if(selected)(UnitRect, { ...bounds, className: \"selection-overlay\" }),\n //defs,\n children,\n ],\n );\n}\n\ninterface UnitRectProps {\n x: number;\n y: number;\n width: number;\n height: number;\n className: string;\n // Used to determine if the rect should have a zig-zag edge on the top or bottom\n overflowTop?: boolean;\n overflowBottom?: boolean;\n [key: string]: any;\n}\n\nconst UnitRect = forwardRef((props: UnitRectProps, ref) => {\n const {\n x,\n y,\n width,\n height,\n overflowTop = false,\n overflowBottom = false,\n ...rest\n } = props;\n\n if (!overflowTop && !overflowBottom) {\n return h(\"rect\", {\n x,\n y,\n width,\n height,\n ref,\n ...rest,\n });\n } else {\n const d = zigZagBoxPath(x, y, width, height, overflowTop, overflowBottom);\n return h(\"path\", {\n d,\n ref,\n ...rest,\n });\n }\n});\n\nfunction LabeledUnit(props: LabeledUnitProps) {\n const {\n division,\n label,\n onLabelUpdated,\n widthFraction,\n showLabel = true,\n backgroundColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const bounds = {\n ...useUnitRect(division, { widthFraction, axisType }),\n ...baseBounds,\n };\n const { width, height } = bounds;\n return h(\n Unit,\n {\n className: \"labeled-unit\",\n division,\n backgroundColor,\n patternID,\n ...bounds,\n },\n [\n h.if(showLabel)(\n ForeignObject,\n { ...bounds, className: \"unit-label-container\" },\n h(SizeAwareLabel, {\n className: \"unit-overlay\",\n labelClassName: \"unit-label\",\n style: { width, height },\n label,\n onVisibilityChanged(viz) {\n onLabelUpdated(label, viz);\n },\n }),\n ),\n ],\n );\n}\n\nfunction UnitBoxes<T>(props: {\n unitComponent: React.FunctionComponent<{ division: T }>;\n unitComponentProps?: any;\n transformDivisions?(divisions: T[]): T[];\n transformDivision?: (\n division: any,\n index: number,\n divisions: any[],\n ) => T | null;\n}) {\n const { unitComponent = Unit, unitComponentProps = {} } = props;\n const { divisions } = useContext(ColumnContext);\n\n if (divisions.length == 0) {\n console.warn(\"No divisions found in column context\");\n return null;\n }\n\n const children = useMemo(() => {\n return divisions.map((division: any, i) => {\n // @ts-ignore\n return h(unitComponent, {\n division,\n key: division.unit_id,\n ...unitComponentProps,\n });\n });\n }, [divisions, unitComponent, unitComponentProps]);\n\n return h(\n PatternDefsProvider,\n { resolveID, scalePattern },\n h(\"g.divisions\", children),\n );\n}\n\nexport { LabeledUnit, Unit, UnitBoxes, UnitProps };\n"],"names":["hyper","styles"],"mappings":";;;;;;;;;;AAuBA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAkC7B,SAAS,YACP,UACA,UAA2B,IACf;AACZ,QAAM;AAAA,IACJ,gBAAgB;AAAA,IAChB,WAAW,eAAe;AAAA,IAC1B,UAAU;AAAA,EAAA,IACR;AACJ,QAAM,EAAE,MAAA,IAAU,WAAW,aAAa;AAC1C,QAAM,EAAE,MAAA,IAAU,WAAW,mBAAmB;AAEhD,QAAM,CAAC,cAAc,SAAS,IAAI,mBAAmB,UAAU,QAAQ;AAEvE,QAAM,IAAI,MAAM,SAAS;AACzB,QAAM,SAAS,KAAK,IAAI,MAAM,YAAY,IAAI,CAAC;AAE/C,SAAO;AAAA,IACL,GAAG,SAAS,IAAI,iBAAiB;AAAA,IACjC,GAAG,IAAI;AAAA,IACP,QAAQ,SAAS,UAAU;AAAA,IAC3B,OAAO,gBAAgB,QAAQ,UAAU;AAAA,EAAA;AAE7C;AAgDA,SAAS,KAAK,OAAkB;AAC9B,QAAM;AAAA,IACJ,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA;AAAA,IACV,GAAG;AAAA,EAAA,IACD;AAEJ,QAAM,EAAE,SAAA,IAAa,UAAA;AAErB,QAAM,iBAAiB,EAAE,cAAc;AACvC,QAAM,oBAAoB,EAAE,cAAc;AAE1C,QAAM,SAAS;AAAA,IACb,GAAG,YAAY,GAAG,EAAE,eAAe,UAAU;AAAA,IAC7C,GAAG;AAAA,IACH,aAAa;AAAA,IACb,gBAAgB;AAAA,EAAA;AAElB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,GAAG,CAAC,WAAW,eAAe,kBAAkB,CAAC;AAEjD,SAAO;AAAA,IACL;AAAA,IACA,EAAE,WAAW,aAAA;AAAA,IACb,EAAE,eAAe,QAAQ;AAAA,EAAA;AAE7B;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@macrostrat/column-views",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Data views for Macrostrat stratigraphic columns",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,18 +48,18 @@
|
|
|
48
48
|
"@blueprintjs/core": "^6.14.0",
|
|
49
49
|
"@macrostrat/api-types": "^1.2.0",
|
|
50
50
|
"@macrostrat/color-utils": "^1.2.2",
|
|
51
|
-
"@macrostrat/column-components": "^2.0.
|
|
52
|
-
"@macrostrat/data-components": "^1.
|
|
53
|
-
"@macrostrat/data-provider": "^1.
|
|
51
|
+
"@macrostrat/column-components": "^2.0.10",
|
|
52
|
+
"@macrostrat/data-components": "^1.5.0",
|
|
53
|
+
"@macrostrat/data-provider": "^1.2.0",
|
|
54
54
|
"@macrostrat/hyper": "^3.1.1",
|
|
55
|
-
"@macrostrat/map-interface": "^2.3.
|
|
55
|
+
"@macrostrat/map-interface": "^2.3.1",
|
|
56
56
|
"@macrostrat/map-styles": "^2.2.6",
|
|
57
|
-
"@macrostrat/mapbox-react": "^3.3.
|
|
57
|
+
"@macrostrat/mapbox-react": "^3.3.3",
|
|
58
58
|
"@macrostrat/mapbox-utils": "^1.8.0",
|
|
59
59
|
"@macrostrat/scoped-store": "^1.0.1",
|
|
60
60
|
"@macrostrat/stratigraphy-utils": "^1.3.0",
|
|
61
61
|
"@macrostrat/svg-map-components": "^2.0.3",
|
|
62
|
-
"@macrostrat/timescale": "^3.1.
|
|
62
|
+
"@macrostrat/timescale": "^3.1.6",
|
|
63
63
|
"@macrostrat/ui-components": "^5.1.0",
|
|
64
64
|
"@turf/boolean-point-in-polygon": "^7.3.2",
|
|
65
65
|
"@turf/buffer": "^7.3.2",
|
package/src/column.module.sass
CHANGED
|
@@ -57,6 +57,12 @@ body:global(.dark-mode) .column-container
|
|
|
57
57
|
fill: var(--selection-overlay-color, red)
|
|
58
58
|
fill-opacity: var(--selection-overlay-opacity, 0.5)
|
|
59
59
|
|
|
60
|
+
// Units sharing a stratigraphic name with the selection: a subtler highlight
|
|
61
|
+
.linked-overlay
|
|
62
|
+
fill: var(--linked-overlay-color, var(--selection-overlay-color, red))
|
|
63
|
+
fill-opacity: var(--linked-overlay-opacity, 0.18)
|
|
64
|
+
pointer-events: none
|
|
65
|
+
|
|
60
66
|
g.lithology-column use.frame
|
|
61
67
|
stroke: var(--column-stroke-color)
|
|
62
68
|
stroke-width: 1.5px !important
|
|
@@ -105,11 +105,16 @@ $map-size-inset: 12em
|
|
|
105
105
|
|
|
106
106
|
.main-chart
|
|
107
107
|
position: relative
|
|
108
|
+
grid-column: 2
|
|
109
|
+
grid-row: 2
|
|
108
110
|
|
|
109
111
|
.correlation-chart-inner
|
|
110
|
-
display:
|
|
111
|
-
|
|
112
|
+
display: grid
|
|
113
|
+
// [age axis] [columns], with an optional header row above
|
|
114
|
+
grid-template-columns: auto auto
|
|
115
|
+
grid-template-rows: auto auto
|
|
112
116
|
position: relative
|
|
117
|
+
width: fit-content
|
|
113
118
|
|
|
114
119
|
.age-axis-container
|
|
115
120
|
display: flex
|
|
@@ -117,6 +122,45 @@ $map-size-inset: 12em
|
|
|
117
122
|
position: sticky
|
|
118
123
|
left: 0
|
|
119
124
|
z-index: 100
|
|
125
|
+
grid-column: 1
|
|
126
|
+
grid-row: 2
|
|
120
127
|
padding-left: 1em
|
|
121
128
|
padding-right: 2px
|
|
122
129
|
background-color: var(--panel-secondary-background-color)
|
|
130
|
+
|
|
131
|
+
// Arbitrary content rendered above each column, aligned with the columns below.
|
|
132
|
+
.column-header-spacer
|
|
133
|
+
grid-column: 1
|
|
134
|
+
grid-row: 1
|
|
135
|
+
// Anchor for absolutely-positioned content (e.g. a zoom pill) so it can sit
|
|
136
|
+
// above the timescale without widening the axis column / shifting the chart
|
|
137
|
+
position: relative
|
|
138
|
+
|
|
139
|
+
.column-header-row
|
|
140
|
+
grid-column: 2
|
|
141
|
+
grid-row: 1
|
|
142
|
+
display: flex
|
|
143
|
+
flex-direction: row
|
|
144
|
+
// Bottom-anchor cells so all labels share the neatline
|
|
145
|
+
align-items: flex-end
|
|
146
|
+
// Pin to the top while scrolling. It stays in flow (grid row 1) so it
|
|
147
|
+
// reserves space above the columns, keeping them aligned with the age axis.
|
|
148
|
+
position: sticky
|
|
149
|
+
top: 0
|
|
150
|
+
// `position: sticky` forms a stacking context; leaving z-index at auto keeps
|
|
151
|
+
// the row below later-painted floating UI (maps, popovers).
|
|
152
|
+
// Neatline separating the headers from the columns below
|
|
153
|
+
border-bottom: 1px solid var(--column-stroke-color, var(--text-color))
|
|
154
|
+
background-color: var(--panel-secondary-background-color)
|
|
155
|
+
|
|
156
|
+
.column-header-cell
|
|
157
|
+
box-sizing: border-box
|
|
158
|
+
display: flex
|
|
159
|
+
flex-direction: column
|
|
160
|
+
// Bottom-anchor content (nearest the columns), stretched to the column
|
|
161
|
+
// width so text wraps within it
|
|
162
|
+
justify-content: flex-end
|
|
163
|
+
align-items: stretch
|
|
164
|
+
// Cap very long content; excess is clipped
|
|
165
|
+
max-height: var(--column-header-max-height, 300px)
|
|
166
|
+
overflow: hidden
|