@macrostrat/column-views 3.12.2 → 3.14.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 +32 -0
- package/dist/age-model/surfaces.cjs +0 -1
- package/dist/age-model/surfaces.cjs.map +1 -1
- package/dist/age-model/surfaces.d.ts +2 -2
- package/dist/age-model/surfaces.js +1 -2
- package/dist/age-model/surfaces.js.map +1 -1
- package/dist/column.cjs +6 -20
- package/dist/column.cjs.map +1 -1
- package/dist/column.d.ts +6 -0
- package/dist/column.js +7 -21
- package/dist/column.js.map +1 -1
- package/dist/data-provider/store.cjs +1 -34
- package/dist/data-provider/store.cjs.map +1 -1
- package/dist/data-provider/store.d.ts +0 -5
- package/dist/data-provider/store.js +2 -35
- package/dist/data-provider/store.js.map +1 -1
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -3
- package/dist/unit-details/panel.cjs +1 -1
- package/dist/unit-details/panel.cjs.map +1 -1
- package/dist/unit-details/panel.js +1 -1
- package/dist/unit-details/panel.js.map +1 -1
- package/package.json +2 -2
- package/src/age-model/surfaces.ts +6 -9
- package/src/column.ts +14 -28
- package/src/data-provider/store.ts +1 -50
- package/src/unit-details/panel.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.14.0] - 2026-09-27 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/column-views-v3.13.0...@macrostrat/column-views-v3.14.0)
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Remove the label-column claim (`useClaimLabelColumn`, `useLabelColumnClaimed`
|
|
8
|
+
[ca5ff733](https://github.com/UW-Macrostrat/web-components/commit/ca5ff73328471627d6cb3638f1b85336f9fefcc3)
|
|
9
|
+
and the layout-overrides context behind them). `ColumnSurfaceLabels` no longer
|
|
10
|
+
hides the unit labels on its own: pass `showLabelColumn: false` to the
|
|
11
|
+
`Column` while surface labels are shown, as the facet columns already do.
|
|
12
|
+
|
|
13
|
+
Remove height easing functions for sections with few units.
|
|
14
|
+
|
|
15
|
+
## [3.13.0] - 2026-09-27 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/column-views-v3.12.2...@macrostrat/column-views-v3.13.0)
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- - `Column` takes `showAgeAxis` (default `true`), to leave out the axis for a
|
|
20
|
+
column whose coordinates aren't a measure
|
|
21
|
+
[ccb88cad](https://github.com/UW-Macrostrat/web-components/commit/ccb88cad7400784437d346c1d3e3c4f969f3fa2a)
|
|
22
|
+
- An explicit `showTimescale: false` wins over `timescaleLevels` /
|
|
23
|
+
`timescales`, which used to turn the timescale back on
|
|
24
|
+
- The unit details panel skips references `/defs/refs` doesn't know instead of
|
|
25
|
+
throwing
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies
|
|
30
|
+
[ccb88cad](https://github.com/UW-Macrostrat/web-components/commit/ccb88cad7400784437d346c1d3e3c4f969f3fa2a)
|
|
31
|
+
- Updated dependencies
|
|
32
|
+
[e9f9084e](https://github.com/UW-Macrostrat/web-components/commit/e9f9084ee66e5a8da3ff4bcaeba1eee17b986042)
|
|
33
|
+
- @macrostrat/data-components@1.8.0
|
|
34
|
+
|
|
3
35
|
## [3.12.2] - 2026-09-25 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/column-views-v3.12.1...@macrostrat/column-views-v3.12.2)
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
|
@@ -146,7 +146,6 @@ function ColumnSurfaceLabels(props) {
|
|
|
146
146
|
const { axisType } = store.useMacrostratColumnData();
|
|
147
147
|
const scale = store.useCompositeScale();
|
|
148
148
|
const intervalMap = useSurfaceIntervalDefs(surfaces);
|
|
149
|
-
store.useClaimLabelColumn();
|
|
150
149
|
const labeled = React.useMemo(() => {
|
|
151
150
|
const byStatus = filterByStatus(surfaces, labelStatuses);
|
|
152
151
|
return thinByPixelSpacing(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surfaces.cjs","sources":["../../src/age-model/surfaces.ts"],"sourcesContent":["/** The surfaces view: age-model calibration surfaces drawn on a column.\n *\n * `ColumnSurfaces` is dropped into a `Column` as a child. It draws one line\n * per surface across the units (`ColumnSurfaceLines`) and a notes column of\n * labels beside them (`ColumnSurfaceLabels`), styled by `boundary_status` and\n * `boundary_type`, with hover and selection.\n */\nimport hyper from \"@macrostrat/hyper\";\nimport classNames from \"classnames\";\nimport {\n type CSSProperties,\n type RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { NoteData } from \"@macrostrat/column-components\";\nimport {\n type IntervalShort,\n IntervalTag,\n TagSize,\n} from \"@macrostrat/data-components\";\nimport { useMacrostratDefs } from \"@macrostrat/data-provider\";\nimport {\n useClaimLabelColumn,\n useCompositeScale,\n useMacrostratColumnData,\n} from \"../data-provider\";\nimport { ColumnNotes } from \"../notes\";\nimport { AgeLabel } from \"../unit-details/age-range\";\nimport columnStyles from \"../column.module.sass\";\nimport styles from \"./surfaces.module.sass\";\nimport {\n type ColumnSurface,\n type SurfaceStatus,\n formatProportion,\n surfaceLabel,\n surfacePosition,\n surfaceStatusLabels,\n surfaceToken,\n TIE_POINT_STATUSES,\n} from \"./types\";\nimport { type UseColumnSurfacesOptions, useColumnSurfaces } from \"./data\";\n\nconst h = hyper.styled(styles);\n\n/** How far the surface lines extend: across the units column only, or the\n * full width of the column including its axes. */\nexport type SurfaceLinesExtent = \"units\" | \"column\";\n\nexport type SurfaceSelectionHandler = (surface: ColumnSurface | null) => void;\n\nexport interface SurfaceSelectionProps {\n /** The selected surface's id. Pass `null` for a controlled, empty\n * selection; leave undefined for the component to manage selection. */\n selectedSurface?: ColumnSurface[\"id\"] | null;\n onSelectSurface?: SurfaceSelectionHandler;\n}\n\nexport interface ColumnSurfacesProps\n extends UseColumnSurfacesOptions, SurfaceSelectionProps {\n showLines?: boolean;\n showLabels?: boolean;\n extent?: SurfaceLinesExtent;\n /** Width of the labels column, connector included (default 200) */\n labelWidth?: number;\n labelPaddingLeft?: number;\n /** Only show surfaces with these statuses */\n statuses?: SurfaceStatus[] | null;\n /** Which surfaces get a label. Defaults to the tie points — the statuses\n * at which the age model was constrained — so interpolated (`modeled`),\n * unspecified and unit-derived surfaces are drawn as lines only. Pass\n * `null` to label every surface shown. */\n labelStatuses?: SurfaceStatus[] | null;\n /** Labels closer than this (in pixels) are thinned out, since the column\n * has finite room; the selected surface's label is always kept. */\n minLabelSpacing?: number;\n className?: string;\n}\n\nexport function ColumnSurfaces(props: ColumnSurfacesProps) {\n const {\n showLines = true,\n showLabels = true,\n extent = \"units\",\n labelWidth,\n labelPaddingLeft,\n statuses,\n labelStatuses = TIE_POINT_STATUSES,\n minLabelSpacing,\n selectedSurface,\n onSelectSurface,\n className,\n ...dataOptions\n } = props;\n\n const { surfaces: allSurfaces } = useColumnSurfaces(dataOptions);\n const surfaces = useMemo(\n () => filterByStatus(allSurfaces, statuses),\n [allSurfaces, statuses],\n );\n\n const [selectedID, select] = useSurfaceSelection(\n selectedSurface,\n onSelectSurface,\n );\n\n return h([\n h.if(showLines)(ColumnSurfaceLines, {\n surfaces,\n extent,\n selectedSurface: selectedID,\n onSelectSurface: select,\n className,\n }),\n h.if(showLabels)(ColumnSurfaceLabels, {\n surfaces,\n labelStatuses,\n minLabelSpacing,\n width: labelWidth,\n paddingLeft: labelPaddingLeft,\n selectedSurface: selectedID,\n onSelectSurface: select,\n className,\n }),\n ]);\n}\n\nexport interface ColumnSurfaceLinesProps extends SurfaceSelectionProps {\n surfaces: ColumnSurface[];\n extent?: SurfaceLinesExtent;\n className?: string;\n}\n\n/** One horizontal line per surface, overlaid on the column at the surface's\n * age (or measured position, for height and depth columns). */\nexport function ColumnSurfaceLines(props: ColumnSurfaceLinesProps) {\n const {\n surfaces,\n extent = \"units\",\n selectedSurface,\n onSelectSurface,\n className,\n } = props;\n const scale = useCompositeScale();\n const { axisType, totalHeight } = useMacrostratColumnData();\n const intervalMap = useSurfaceIntervalDefs(surfaces);\n\n const ref = useRef<HTMLDivElement>(null);\n const unitsExtent = useUnitsColumnExtent(ref, extent === \"units\");\n\n let style: CSSProperties = { height: totalHeight };\n if (unitsExtent != null) {\n style = { ...style, left: unitsExtent.left, width: unitsExtent.width };\n }\n const measuring = extent === \"units\" && unitsExtent == null;\n\n return h(\n \"div.column-surface-lines\",\n { ref, style, className: classNames(className, { measuring }) },\n surfaces.map((surface) => {\n const position = surfacePosition(surface, axisType);\n if (position == null) return null;\n const y = scale(position);\n if (y == null) return null;\n return h(SurfaceLine, {\n key: surface.id,\n surface,\n y,\n color: surfaceIntervalColor(surface, intervalMap),\n selected: surface.id === selectedSurface,\n onSelect: onSelectSurface,\n });\n }),\n );\n}\n\nfunction SurfaceLine({\n surface,\n y,\n color,\n selected,\n onSelect,\n}: {\n surface: ColumnSurface;\n y: number;\n /** The interval color, when known; otherwise the status color is used */\n color?: string | null;\n selected: boolean;\n onSelect?: SurfaceSelectionHandler;\n}) {\n const onClick = useCallback(\n (evt: MouseEvent) => {\n // Don't let the column deselect its unit\n evt.stopPropagation();\n if (selected) {\n onSelect?.(null);\n } else {\n onSelect?.(surface);\n }\n },\n [surface, selected, onSelect],\n );\n\n let style: CSSProperties = { top: y };\n if (color != null) {\n style = { ...style, \"--surface-color\": color } as CSSProperties;\n }\n\n return h(\n \"div.surface-line\",\n {\n style,\n className: classNames(surfaceClasses(surface), {\n selected,\n interactive: onSelect != null,\n }),\n title: surfaceLabel(surface),\n onClick,\n },\n h(\"div.surface-line-inner\"),\n );\n}\n\nexport interface ColumnSurfaceLabelsProps extends SurfaceSelectionProps {\n surfaces: ColumnSurface[];\n /** Which surfaces get a label (see `ColumnSurfacesProps.labelStatuses`) */\n labelStatuses?: SurfaceStatus[] | null;\n /** Minimum pixel spacing between labels (see `ColumnSurfacesProps`) */\n minLabelSpacing?: number;\n /** Total width, connector included */\n width?: number;\n paddingLeft?: number;\n className?: string;\n}\n\ninterface SurfaceNote extends NoteData {\n /** The interval color, which the note's connector picks up */\n color?: string;\n surface: ColumnSurface;\n /** The calibration interval, with color and rank from the definitions */\n interval: IntervalShort | null;\n selected: boolean;\n}\n\n/** A notes column of surface labels, laid out beside the units with the\n * collision avoidance of `NotesColumn`. It takes the label column over from\n * the unit labels while mounted: labels are one or the other. */\nexport function ColumnSurfaceLabels(props: ColumnSurfaceLabelsProps) {\n const {\n surfaces,\n labelStatuses = TIE_POINT_STATUSES,\n minLabelSpacing = 22,\n width = 200,\n paddingLeft = 24,\n selectedSurface,\n onSelectSurface,\n className,\n } = props;\n const { axisType } = useMacrostratColumnData();\n const scale = useCompositeScale();\n const intervalMap = useSurfaceIntervalDefs(surfaces);\n useClaimLabelColumn();\n\n const labeled = useMemo(() => {\n const byStatus = filterByStatus(surfaces, labelStatuses);\n return thinByPixelSpacing(\n byStatus,\n (s) => scale(surfacePosition(s, axisType) ?? NaN),\n minLabelSpacing,\n selectedSurface,\n );\n }, [\n surfaces,\n labelStatuses,\n minLabelSpacing,\n selectedSurface,\n scale,\n axisType,\n ]);\n\n const notes: SurfaceNote[] = useMemo(() => {\n const _notes: SurfaceNote[] = [];\n for (const surface of labeled) {\n const position = surfacePosition(surface, axisType);\n if (position == null) continue;\n _notes.push({\n id: surface.id,\n height: position,\n note: surfaceLabel(surface),\n // The note's color reaches its connector, so a label's leader line\n // matches the surface line it points at\n color: surfaceIntervalColor(surface, intervalMap) ?? undefined,\n surface,\n interval: calibrationInterval(surface, intervalMap),\n selected: surface.id === selectedSurface,\n });\n }\n return _notes;\n }, [labeled, axisType, selectedSurface, intervalMap]);\n\n const onClickNote = useCallback(\n (note: NoteData) => {\n const { surface, selected } = note as SurfaceNote;\n if (selected) {\n onSelectSurface?.(null);\n } else {\n onSelectSurface?.(surface);\n }\n },\n [onSelectSurface],\n );\n\n return h(\n \"div.column-surface-labels\",\n { className },\n h(ColumnNotes, {\n notes,\n width,\n paddingLeft,\n noteComponent: SurfaceNoteLabel,\n onClickNote,\n forceOptions: LABEL_FORCE_OPTIONS,\n // The leader runs from the surface line in the column to the tag body,\n // continuing a little past both ends rather than stopping in the gap —\n // so it needs no endpoint marker of its own\n connectorOverhang: LABEL_CONNECTOR_OVERHANG,\n showPointMarker: false,\n }),\n );\n}\n\n/** Breathing room between stacked labels, in pixels */\nconst LABEL_FORCE_OPTIONS = { nodeSpacing: 2 };\n\n/** How far the label's leader line continues past each end, in pixels: left\n * into the column to meet the surface line, right under the tag body. */\nconst LABEL_CONNECTOR_OVERHANG: [number, number] = [8, 6];\n\n/** A surface's label: its calibration interval as the standard interval tag\n * (with the position within the interval as the tag's detail), and the\n * modeled age beneath. Surfaces without a calibration show their status. */\nfunction SurfaceNoteLabel({ note }: { note: SurfaceNote }) {\n const { surface, interval, selected } = note;\n\n let primary: any;\n if (interval != null) {\n primary = h(IntervalTag, {\n interval,\n size: TagSize.Small,\n proportion: surface.proportion,\n className: \"surface-interval-tag\",\n });\n } else {\n primary = h(\n \"span.surface-label-status\",\n `${surfaceStatusLabels[surface.status]} surface`,\n );\n }\n\n return h(\n \"div.surface-label\",\n { className: classNames(surfaceClasses(surface), { selected }) },\n h(\"div.surface-label-primary\", primary),\n );\n}\n\n/** The interval definitions for the surfaces' calibration intervals. The age\n * model carries interval ids and names but no colors, so they come from the\n * definitions store (which holds them all, and fetches once). */\nfunction useSurfaceIntervalDefs(\n surfaces: ColumnSurface[],\n): Map<number, any> | null {\n const intervalIDs = useMemo(() => {\n const ids = new Set<number>();\n for (const surface of surfaces) {\n if (surface.calibration != null) ids.add(surface.calibration.id);\n }\n return Array.from(ids);\n }, [surfaces]);\n return useMacrostratDefs(\"intervals\", intervalIDs, null);\n}\n\n/** The color a surface is drawn in: its calibration interval's, so the line\n * and its label's leader read as the interval the surface is tied to. `null`\n * for an uncalibrated surface, or before the definitions load — the status\n * color stands in. */\nfunction surfaceIntervalColor(\n surface: ColumnSurface,\n intervalMap: Map<number, any> | null,\n): string | null {\n const id = surface.calibration?.id;\n if (id == null) return null;\n return intervalMap?.get(id)?.color ?? null;\n}\n\n/** The calibration interval in the shape the interval tag takes, colored\n * from the definitions when they have loaded. */\nfunction calibrationInterval(\n surface: ColumnSurface,\n intervalMap: Map<number, any> | null,\n): IntervalShort | null {\n const { calibration } = surface;\n if (calibration == null) return null;\n const def = intervalMap?.get(calibration.id);\n return {\n id: calibration.id,\n name: calibration.name,\n b_age: calibration.b_age,\n t_age: calibration.t_age,\n color: def?.color,\n rank: def?.rank,\n };\n}\n\n/** Class names shared by the lines, labels, legend and tags, so a status or\n * type reads the same everywhere. */\nexport function surfaceClasses(surface: {\n status?: SurfaceStatus | null;\n type?: string | null;\n}): string {\n return classNames(\n `status-${surfaceToken(surface.status)}`,\n `type-${surfaceToken(surface.type)}`,\n );\n}\n\n/** Walk the surfaces down the column and drop any whose label would sit\n * within `minSpacing` pixels of the last one kept. The selected surface is\n * always kept (and displaces a neighbor if need be). */\nfunction thinByPixelSpacing(\n surfaces: ColumnSurface[],\n pixelPosition: (s: ColumnSurface) => number | null,\n minSpacing: number,\n selectedSurface: ColumnSurface[\"id\"] | null | undefined,\n): ColumnSurface[] {\n if (minSpacing <= 0) return surfaces;\n const positioned = surfaces\n .map((surface) => ({ surface, y: pixelPosition(surface) }))\n .filter((d) => d.y != null && !Number.isNaN(d.y))\n .sort((a, b) => a.y - b.y);\n\n const kept: { surface: ColumnSurface; y: number }[] = [];\n for (const item of positioned) {\n const selected = item.surface.id === selectedSurface;\n const last = kept[kept.length - 1];\n if (last == null || item.y - last.y >= minSpacing) {\n kept.push(item);\n } else if (selected) {\n // The selection wins its slot\n kept[kept.length - 1] = item;\n }\n }\n return kept.map((d) => d.surface);\n}\n\nfunction filterByStatus(\n surfaces: ColumnSurface[],\n statuses: SurfaceStatus[] | null | undefined,\n): ColumnSurface[] {\n if (statuses == null) return surfaces;\n const allowed = new Set(statuses);\n return surfaces.filter((d) => allowed.has(d.status));\n}\n\n/** Controlled-or-uncontrolled selection: when `selectedID` is passed (even as\n * `null`) the consumer owns it; otherwise it is kept internally. */\nfunction useSurfaceSelection(\n selectedID: ColumnSurface[\"id\"] | null | undefined,\n onSelect: SurfaceSelectionHandler | undefined,\n): [ColumnSurface[\"id\"] | null, SurfaceSelectionHandler] {\n const [internal, setInternal] = useState<ColumnSurface[\"id\"] | null>(null);\n const isControlled = selectedID !== undefined;\n\n const select: SurfaceSelectionHandler = useCallback(\n (surface) => {\n setInternal(surface?.id ?? null);\n onSelect?.(surface);\n },\n [onSelect],\n );\n\n let current = internal;\n if (isControlled) {\n current = selectedID;\n }\n return [current, select];\n}\n\ninterface HorizontalExtent {\n left: number;\n width: number;\n}\n\n/** `useLayoutEffect` in the browser, `useEffect` on the server — where it\n * would warn and has nothing to measure anyway. */\nconst useMeasureEffect =\n typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\n/** Measure where the units column sits within the `Column`, so an overlay\n * can cover exactly the units rather than the axes. `null` while unmeasured,\n * when disabled, or when the units column can't be found. */\nfunction useUnitsColumnExtent(\n ref: RefObject<HTMLDivElement | null>,\n enabled: boolean,\n): HorizontalExtent | null {\n const [extent, setExtent] = useState<HorizontalExtent | null>(null);\n\n const measure = useCallback(() => {\n if (!enabled) return;\n const parent = ref.current?.parentElement;\n const target = parent?.querySelector<HTMLElement>(\n `.${unitsContainerClass()}`,\n );\n if (parent == null || target == null) return;\n\n const p = parent.getBoundingClientRect();\n const t = target.getBoundingClientRect();\n const next = { left: t.left - p.left, width: t.width };\n setExtent((prev) => {\n if (prev?.left === next.left && prev?.width === next.width) {\n return prev;\n }\n return next;\n });\n }, [enabled]);\n\n // Re-measure on every render as a backstop: cheap, and it catches layout\n // changes that no observer reports.\n useMeasureEffect(measure);\n\n useMeasureEffect(() => {\n if (!enabled) {\n setExtent(null);\n return;\n }\n const parent = ref.current?.parentElement;\n if (parent == null) return;\n if (typeof ResizeObserver === \"undefined\") return;\n\n const observer = new ResizeObserver(measure);\n // The units column *moves* when a sibling changes width — the timescale\n // widening once its intervals load, or its level count changing — and\n // that is not a resize of the units column or of the column itself, so\n // the siblings have to be watched too.\n observer.observe(parent);\n for (const child of Array.from(parent.children)) {\n observer.observe(child);\n }\n return () => observer.disconnect();\n }, [enabled, measure]);\n\n return extent;\n}\n\n/** The (module-scoped) class of the units container rendered by\n * `SectionsColumn`. */\nfunction unitsContainerClass(): string {\n const s = columnStyles as any;\n return (\n s[\"section-units-container\"] ??\n s.sectionUnitsContainer ??\n \"section-units-container\"\n );\n}\n"],"names":["hyper","styles","TIE_POINT_STATUSES","useColumnSurfaces","useMemo","useCompositeScale","useMacrostratColumnData","useRef","classNames","surfacePosition","useCallback","surfaceLabel","useClaimLabelColumn","notes","ColumnNotes","IntervalTag","TagSize","surfaceStatusLabels","useMacrostratDefs","surfaceToken","useState","useEffect","useLayoutEffect","columnStyles"],"mappings":";;;;;;;;;;;;;;;;AA+CA,MAAM,IAAIA,WAAAA,QAAM,OAAOC,uBAAM;AAoCtB,SAAS,eAAe,OAA4B;AACzD,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgBC,MAAAA;AAAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AAEJ,QAAM,EAAE,UAAU,gBAAgBC,KAAAA,kBAAkB,WAAW;AAC/D,QAAM,WAAWC,MAAAA;AAAAA,IACf,MAAM,eAAe,aAAa,QAAQ;AAAA,IAC1C,CAAC,aAAa,QAAQ;AAAA,EAAA;AAGxB,QAAM,CAAC,YAAY,MAAM,IAAI;AAAA,IAC3B;AAAA,IACA;AAAA,EAAA;AAGF,SAAO,EAAE;AAAA,IACP,EAAE,GAAG,S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EAAE,yBACF;AAEJ;;;;;"}
|
|
1
|
+
{"version":3,"file":"surfaces.cjs","sources":["../../src/age-model/surfaces.ts"],"sourcesContent":["/** The surfaces view: age-model calibration surfaces drawn on a column.\n *\n * `ColumnSurfaces` is dropped into a `Column` as a child. It draws one line\n * per surface across the units (`ColumnSurfaceLines`) and a notes column of\n * labels beside them (`ColumnSurfaceLabels`), styled by `boundary_status` and\n * `boundary_type`, with hover and selection. The labels sit where the unit\n * labels would, so pass `showLabelColumn: false` to the `Column` while they\n * are shown.\n */\nimport hyper from \"@macrostrat/hyper\";\nimport classNames from \"classnames\";\nimport {\n type CSSProperties,\n type RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { NoteData } from \"@macrostrat/column-components\";\nimport {\n type IntervalShort,\n IntervalTag,\n TagSize,\n} from \"@macrostrat/data-components\";\nimport { useMacrostratDefs } from \"@macrostrat/data-provider\";\nimport { useCompositeScale, useMacrostratColumnData } from \"../data-provider\";\nimport { ColumnNotes } from \"../notes\";\nimport { AgeLabel } from \"../unit-details/age-range\";\nimport columnStyles from \"../column.module.sass\";\nimport styles from \"./surfaces.module.sass\";\nimport {\n type ColumnSurface,\n type SurfaceStatus,\n formatProportion,\n surfaceLabel,\n surfacePosition,\n surfaceStatusLabels,\n surfaceToken,\n TIE_POINT_STATUSES,\n} from \"./types\";\nimport { type UseColumnSurfacesOptions, useColumnSurfaces } from \"./data\";\n\nconst h = hyper.styled(styles);\n\n/** How far the surface lines extend: across the units column only, or the\n * full width of the column including its axes. */\nexport type SurfaceLinesExtent = \"units\" | \"column\";\n\nexport type SurfaceSelectionHandler = (surface: ColumnSurface | null) => void;\n\nexport interface SurfaceSelectionProps {\n /** The selected surface's id. Pass `null` for a controlled, empty\n * selection; leave undefined for the component to manage selection. */\n selectedSurface?: ColumnSurface[\"id\"] | null;\n onSelectSurface?: SurfaceSelectionHandler;\n}\n\nexport interface ColumnSurfacesProps\n extends UseColumnSurfacesOptions, SurfaceSelectionProps {\n showLines?: boolean;\n showLabels?: boolean;\n extent?: SurfaceLinesExtent;\n /** Width of the labels column, connector included (default 200) */\n labelWidth?: number;\n labelPaddingLeft?: number;\n /** Only show surfaces with these statuses */\n statuses?: SurfaceStatus[] | null;\n /** Which surfaces get a label. Defaults to the tie points — the statuses\n * at which the age model was constrained — so interpolated (`modeled`),\n * unspecified and unit-derived surfaces are drawn as lines only. Pass\n * `null` to label every surface shown. */\n labelStatuses?: SurfaceStatus[] | null;\n /** Labels closer than this (in pixels) are thinned out, since the column\n * has finite room; the selected surface's label is always kept. */\n minLabelSpacing?: number;\n className?: string;\n}\n\nexport function ColumnSurfaces(props: ColumnSurfacesProps) {\n const {\n showLines = true,\n showLabels = true,\n extent = \"units\",\n labelWidth,\n labelPaddingLeft,\n statuses,\n labelStatuses = TIE_POINT_STATUSES,\n minLabelSpacing,\n selectedSurface,\n onSelectSurface,\n className,\n ...dataOptions\n } = props;\n\n const { surfaces: allSurfaces } = useColumnSurfaces(dataOptions);\n const surfaces = useMemo(\n () => filterByStatus(allSurfaces, statuses),\n [allSurfaces, statuses],\n );\n\n const [selectedID, select] = useSurfaceSelection(\n selectedSurface,\n onSelectSurface,\n );\n\n return h([\n h.if(showLines)(ColumnSurfaceLines, {\n surfaces,\n extent,\n selectedSurface: selectedID,\n onSelectSurface: select,\n className,\n }),\n h.if(showLabels)(ColumnSurfaceLabels, {\n surfaces,\n labelStatuses,\n minLabelSpacing,\n width: labelWidth,\n paddingLeft: labelPaddingLeft,\n selectedSurface: selectedID,\n onSelectSurface: select,\n className,\n }),\n ]);\n}\n\nexport interface ColumnSurfaceLinesProps extends SurfaceSelectionProps {\n surfaces: ColumnSurface[];\n extent?: SurfaceLinesExtent;\n className?: string;\n}\n\n/** One horizontal line per surface, overlaid on the column at the surface's\n * age (or measured position, for height and depth columns). */\nexport function ColumnSurfaceLines(props: ColumnSurfaceLinesProps) {\n const {\n surfaces,\n extent = \"units\",\n selectedSurface,\n onSelectSurface,\n className,\n } = props;\n const scale = useCompositeScale();\n const { axisType, totalHeight } = useMacrostratColumnData();\n const intervalMap = useSurfaceIntervalDefs(surfaces);\n\n const ref = useRef<HTMLDivElement>(null);\n const unitsExtent = useUnitsColumnExtent(ref, extent === \"units\");\n\n let style: CSSProperties = { height: totalHeight };\n if (unitsExtent != null) {\n style = { ...style, left: unitsExtent.left, width: unitsExtent.width };\n }\n const measuring = extent === \"units\" && unitsExtent == null;\n\n return h(\n \"div.column-surface-lines\",\n { ref, style, className: classNames(className, { measuring }) },\n surfaces.map((surface) => {\n const position = surfacePosition(surface, axisType);\n if (position == null) return null;\n const y = scale(position);\n if (y == null) return null;\n return h(SurfaceLine, {\n key: surface.id,\n surface,\n y,\n color: surfaceIntervalColor(surface, intervalMap),\n selected: surface.id === selectedSurface,\n onSelect: onSelectSurface,\n });\n }),\n );\n}\n\nfunction SurfaceLine({\n surface,\n y,\n color,\n selected,\n onSelect,\n}: {\n surface: ColumnSurface;\n y: number;\n /** The interval color, when known; otherwise the status color is used */\n color?: string | null;\n selected: boolean;\n onSelect?: SurfaceSelectionHandler;\n}) {\n const onClick = useCallback(\n (evt: MouseEvent) => {\n // Don't let the column deselect its unit\n evt.stopPropagation();\n if (selected) {\n onSelect?.(null);\n } else {\n onSelect?.(surface);\n }\n },\n [surface, selected, onSelect],\n );\n\n let style: CSSProperties = { top: y };\n if (color != null) {\n style = { ...style, \"--surface-color\": color } as CSSProperties;\n }\n\n return h(\n \"div.surface-line\",\n {\n style,\n className: classNames(surfaceClasses(surface), {\n selected,\n interactive: onSelect != null,\n }),\n title: surfaceLabel(surface),\n onClick,\n },\n h(\"div.surface-line-inner\"),\n );\n}\n\nexport interface ColumnSurfaceLabelsProps extends SurfaceSelectionProps {\n surfaces: ColumnSurface[];\n /** Which surfaces get a label (see `ColumnSurfacesProps.labelStatuses`) */\n labelStatuses?: SurfaceStatus[] | null;\n /** Minimum pixel spacing between labels (see `ColumnSurfacesProps`) */\n minLabelSpacing?: number;\n /** Total width, connector included */\n width?: number;\n paddingLeft?: number;\n className?: string;\n}\n\ninterface SurfaceNote extends NoteData {\n /** The interval color, which the note's connector picks up */\n color?: string;\n surface: ColumnSurface;\n /** The calibration interval, with color and rank from the definitions */\n interval: IntervalShort | null;\n selected: boolean;\n}\n\n/** A notes column of surface labels, laid out beside the units with the\n * collision avoidance of `NotesColumn`. It draws over the unit labels, so the\n * `Column` should hide its label column (`showLabelColumn: false`). */\nexport function ColumnSurfaceLabels(props: ColumnSurfaceLabelsProps) {\n const {\n surfaces,\n labelStatuses = TIE_POINT_STATUSES,\n minLabelSpacing = 22,\n width = 200,\n paddingLeft = 24,\n selectedSurface,\n onSelectSurface,\n className,\n } = props;\n const { axisType } = useMacrostratColumnData();\n const scale = useCompositeScale();\n const intervalMap = useSurfaceIntervalDefs(surfaces);\n\n const labeled = useMemo(() => {\n const byStatus = filterByStatus(surfaces, labelStatuses);\n return thinByPixelSpacing(\n byStatus,\n (s) => scale(surfacePosition(s, axisType) ?? NaN),\n minLabelSpacing,\n selectedSurface,\n );\n }, [\n surfaces,\n labelStatuses,\n minLabelSpacing,\n selectedSurface,\n scale,\n axisType,\n ]);\n\n const notes: SurfaceNote[] = useMemo(() => {\n const _notes: SurfaceNote[] = [];\n for (const surface of labeled) {\n const position = surfacePosition(surface, axisType);\n if (position == null) continue;\n _notes.push({\n id: surface.id,\n height: position,\n note: surfaceLabel(surface),\n // The note's color reaches its connector, so a label's leader line\n // matches the surface line it points at\n color: surfaceIntervalColor(surface, intervalMap) ?? undefined,\n surface,\n interval: calibrationInterval(surface, intervalMap),\n selected: surface.id === selectedSurface,\n });\n }\n return _notes;\n }, [labeled, axisType, selectedSurface, intervalMap]);\n\n const onClickNote = useCallback(\n (note: NoteData) => {\n const { surface, selected } = note as SurfaceNote;\n if (selected) {\n onSelectSurface?.(null);\n } else {\n onSelectSurface?.(surface);\n }\n },\n [onSelectSurface],\n );\n\n return h(\n \"div.column-surface-labels\",\n { className },\n h(ColumnNotes, {\n notes,\n width,\n paddingLeft,\n noteComponent: SurfaceNoteLabel,\n onClickNote,\n forceOptions: LABEL_FORCE_OPTIONS,\n // The leader runs from the surface line in the column to the tag body,\n // continuing a little past both ends rather than stopping in the gap —\n // so it needs no endpoint marker of its own\n connectorOverhang: LABEL_CONNECTOR_OVERHANG,\n showPointMarker: false,\n }),\n );\n}\n\n/** Breathing room between stacked labels, in pixels */\nconst LABEL_FORCE_OPTIONS = { nodeSpacing: 2 };\n\n/** How far the label's leader line continues past each end, in pixels: left\n * into the column to meet the surface line, right under the tag body. */\nconst LABEL_CONNECTOR_OVERHANG: [number, number] = [8, 6];\n\n/** A surface's label: its calibration interval as the standard interval tag\n * (with the position within the interval as the tag's detail), and the\n * modeled age beneath. Surfaces without a calibration show their status. */\nfunction SurfaceNoteLabel({ note }: { note: SurfaceNote }) {\n const { surface, interval, selected } = note;\n\n let primary: any;\n if (interval != null) {\n primary = h(IntervalTag, {\n interval,\n size: TagSize.Small,\n proportion: surface.proportion,\n className: \"surface-interval-tag\",\n });\n } else {\n primary = h(\n \"span.surface-label-status\",\n `${surfaceStatusLabels[surface.status]} surface`,\n );\n }\n\n return h(\n \"div.surface-label\",\n { className: classNames(surfaceClasses(surface), { selected }) },\n h(\"div.surface-label-primary\", primary),\n );\n}\n\n/** The interval definitions for the surfaces' calibration intervals. The age\n * model carries interval ids and names but no colors, so they come from the\n * definitions store (which holds them all, and fetches once). */\nfunction useSurfaceIntervalDefs(\n surfaces: ColumnSurface[],\n): Map<number, any> | null {\n const intervalIDs = useMemo(() => {\n const ids = new Set<number>();\n for (const surface of surfaces) {\n if (surface.calibration != null) ids.add(surface.calibration.id);\n }\n return Array.from(ids);\n }, [surfaces]);\n return useMacrostratDefs(\"intervals\", intervalIDs, null);\n}\n\n/** The color a surface is drawn in: its calibration interval's, so the line\n * and its label's leader read as the interval the surface is tied to. `null`\n * for an uncalibrated surface, or before the definitions load — the status\n * color stands in. */\nfunction surfaceIntervalColor(\n surface: ColumnSurface,\n intervalMap: Map<number, any> | null,\n): string | null {\n const id = surface.calibration?.id;\n if (id == null) return null;\n return intervalMap?.get(id)?.color ?? null;\n}\n\n/** The calibration interval in the shape the interval tag takes, colored\n * from the definitions when they have loaded. */\nfunction calibrationInterval(\n surface: ColumnSurface,\n intervalMap: Map<number, any> | null,\n): IntervalShort | null {\n const { calibration } = surface;\n if (calibration == null) return null;\n const def = intervalMap?.get(calibration.id);\n return {\n id: calibration.id,\n name: calibration.name,\n b_age: calibration.b_age,\n t_age: calibration.t_age,\n color: def?.color,\n rank: def?.rank,\n };\n}\n\n/** Class names shared by the lines, labels, legend and tags, so a status or\n * type reads the same everywhere. */\nexport function surfaceClasses(surface: {\n status?: SurfaceStatus | null;\n type?: string | null;\n}): string {\n return classNames(\n `status-${surfaceToken(surface.status)}`,\n `type-${surfaceToken(surface.type)}`,\n );\n}\n\n/** Walk the surfaces down the column and drop any whose label would sit\n * within `minSpacing` pixels of the last one kept. The selected surface is\n * always kept (and displaces a neighbor if need be). */\nfunction thinByPixelSpacing(\n surfaces: ColumnSurface[],\n pixelPosition: (s: ColumnSurface) => number | null,\n minSpacing: number,\n selectedSurface: ColumnSurface[\"id\"] | null | undefined,\n): ColumnSurface[] {\n if (minSpacing <= 0) return surfaces;\n const positioned = surfaces\n .map((surface) => ({ surface, y: pixelPosition(surface) }))\n .filter((d) => d.y != null && !Number.isNaN(d.y))\n .sort((a, b) => a.y - b.y);\n\n const kept: { surface: ColumnSurface; y: number }[] = [];\n for (const item of positioned) {\n const selected = item.surface.id === selectedSurface;\n const last = kept[kept.length - 1];\n if (last == null || item.y - last.y >= minSpacing) {\n kept.push(item);\n } else if (selected) {\n // The selection wins its slot\n kept[kept.length - 1] = item;\n }\n }\n return kept.map((d) => d.surface);\n}\n\nfunction filterByStatus(\n surfaces: ColumnSurface[],\n statuses: SurfaceStatus[] | null | undefined,\n): ColumnSurface[] {\n if (statuses == null) return surfaces;\n const allowed = new Set(statuses);\n return surfaces.filter((d) => allowed.has(d.status));\n}\n\n/** Controlled-or-uncontrolled selection: when `selectedID` is passed (even as\n * `null`) the consumer owns it; otherwise it is kept internally. */\nfunction useSurfaceSelection(\n selectedID: ColumnSurface[\"id\"] | null | undefined,\n onSelect: SurfaceSelectionHandler | undefined,\n): [ColumnSurface[\"id\"] | null, SurfaceSelectionHandler] {\n const [internal, setInternal] = useState<ColumnSurface[\"id\"] | null>(null);\n const isControlled = selectedID !== undefined;\n\n const select: SurfaceSelectionHandler = useCallback(\n (surface) => {\n setInternal(surface?.id ?? null);\n onSelect?.(surface);\n },\n [onSelect],\n );\n\n let current = internal;\n if (isControlled) {\n current = selectedID;\n }\n return [current, select];\n}\n\ninterface HorizontalExtent {\n left: number;\n width: number;\n}\n\n/** `useLayoutEffect` in the browser, `useEffect` on the server — where it\n * would warn and has nothing to measure anyway. */\nconst useMeasureEffect =\n typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\n/** Measure where the units column sits within the `Column`, so an overlay\n * can cover exactly the units rather than the axes. `null` while unmeasured,\n * when disabled, or when the units column can't be found. */\nfunction useUnitsColumnExtent(\n ref: RefObject<HTMLDivElement | null>,\n enabled: boolean,\n): HorizontalExtent | null {\n const [extent, setExtent] = useState<HorizontalExtent | null>(null);\n\n const measure = useCallback(() => {\n if (!enabled) return;\n const parent = ref.current?.parentElement;\n const target = parent?.querySelector<HTMLElement>(\n `.${unitsContainerClass()}`,\n );\n if (parent == null || target == null) return;\n\n const p = parent.getBoundingClientRect();\n const t = target.getBoundingClientRect();\n const next = { left: t.left - p.left, width: t.width };\n setExtent((prev) => {\n if (prev?.left === next.left && prev?.width === next.width) {\n return prev;\n }\n return next;\n });\n }, [enabled]);\n\n // Re-measure on every render as a backstop: cheap, and it catches layout\n // changes that no observer reports.\n useMeasureEffect(measure);\n\n useMeasureEffect(() => {\n if (!enabled) {\n setExtent(null);\n return;\n }\n const parent = ref.current?.parentElement;\n if (parent == null) return;\n if (typeof ResizeObserver === \"undefined\") return;\n\n const observer = new ResizeObserver(measure);\n // The units column *moves* when a sibling changes width — the timescale\n // widening once its intervals load, or its level count changing — and\n // that is not a resize of the units column or of the column itself, so\n // the siblings have to be watched too.\n observer.observe(parent);\n for (const child of Array.from(parent.children)) {\n observer.observe(child);\n }\n return () => observer.disconnect();\n }, [enabled, measure]);\n\n return extent;\n}\n\n/** The (module-scoped) class of the units container rendered by\n * `SectionsColumn`. */\nfunction unitsContainerClass(): string {\n const s = columnStyles as any;\n return (\n s[\"section-units-container\"] ??\n s.sectionUnitsContainer ??\n \"section-units-container\"\n );\n}\n"],"names":["hyper","styles","TIE_POINT_STATUSES","useColumnSurfaces","useMemo","useCompositeScale","useMacrostratColumnData","useRef","classNames","surfacePosition","useCallback","surfaceLabel","notes","ColumnNotes","IntervalTag","TagSize","surfaceStatusLabels","useMacrostratDefs","surfaceToken","useState","useEffect","useLayoutEffect","columnStyles"],"mappings":";;;;;;;;;;;;;;;;AA6CA,MAAM,IAAIA,WAAAA,QAAM,OAAOC,uBAAM;AAoCtB,SAAS,eAAe,OAA4B;AACzD,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgBC,MAAAA;AAAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AAEJ,QAAM,EAAE,UAAU,gBAAgBC,KAAAA,kBAAkB,WAAW;AAC/D,QAAM,WAAWC,MAAAA;AAAAA,IACf,MAAM,eAAe,aAAa,QAAQ;AAAA,IAC1C,CAAC,aAAa,QAAQ;AAAA,EAAA;AAGxB,QAAM,CAAC,YAAY,MAAM,IAAI;AAAA,IAC3B;AAAA,IACA;AAAA,EAAA;AAGF,SAAO,EAAE;AAAA,IACP,EAAE,GAAG,SAAS,EAAE,oBAAoB;AAAA,MAClC;AAAA,MACA;AAAA,MACA,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,MACj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
className?: string;
|
|
56
56
|
}
|
|
57
57
|
/** A notes column of surface labels, laid out beside the units with the
|
|
58
|
-
* collision avoidance of `NotesColumn`. It
|
|
59
|
-
*
|
|
58
|
+
* collision avoidance of `NotesColumn`. It draws over the unit labels, so the
|
|
59
|
+
* `Column` should hide its label column (`showLabelColumn: false`). */
|
|
60
60
|
export declare function ColumnSurfaceLabels(props: ColumnSurfaceLabelsProps): import('react').ReactElement<{
|
|
61
61
|
className: string | undefined;
|
|
62
62
|
}, string | import('react').JSXElementConstructor<any>>;
|
|
@@ -8,7 +8,7 @@ import h$3 from "../column.module.sass.js";
|
|
|
8
8
|
import h$2 from "./surfaces.module.sass.js";
|
|
9
9
|
import { TIE_POINT_STATUSES, surfacePosition, surfaceLabel, surfaceToken, surfaceStatusLabels } from "./types.js";
|
|
10
10
|
import { useColumnSurfaces } from "./data.js";
|
|
11
|
-
import { useMacrostratColumnData, useCompositeScale
|
|
11
|
+
import { useMacrostratColumnData, useCompositeScale } from "../data-provider/store.js";
|
|
12
12
|
const h = h$1.styled(h$2);
|
|
13
13
|
function ColumnSurfaces(props) {
|
|
14
14
|
const {
|
|
@@ -141,7 +141,6 @@ function ColumnSurfaceLabels(props) {
|
|
|
141
141
|
const { axisType } = useMacrostratColumnData();
|
|
142
142
|
const scale = useCompositeScale();
|
|
143
143
|
const intervalMap = useSurfaceIntervalDefs(surfaces);
|
|
144
|
-
useClaimLabelColumn();
|
|
145
144
|
const labeled = useMemo(() => {
|
|
146
145
|
const byStatus = filterByStatus(surfaces, labelStatuses);
|
|
147
146
|
return thinByPixelSpacing(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surfaces.js","sources":["../../src/age-model/surfaces.ts"],"sourcesContent":["/** The surfaces view: age-model calibration surfaces drawn on a column.\n *\n * `ColumnSurfaces` is dropped into a `Column` as a child. It draws one line\n * per surface across the units (`ColumnSurfaceLines`) and a notes column of\n * labels beside them (`ColumnSurfaceLabels`), styled by `boundary_status` and\n * `boundary_type`, with hover and selection.\n */\nimport hyper from \"@macrostrat/hyper\";\nimport classNames from \"classnames\";\nimport {\n type CSSProperties,\n type RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { NoteData } from \"@macrostrat/column-components\";\nimport {\n type IntervalShort,\n IntervalTag,\n TagSize,\n} from \"@macrostrat/data-components\";\nimport { useMacrostratDefs } from \"@macrostrat/data-provider\";\nimport {\n useClaimLabelColumn,\n useCompositeScale,\n useMacrostratColumnData,\n} from \"../data-provider\";\nimport { ColumnNotes } from \"../notes\";\nimport { AgeLabel } from \"../unit-details/age-range\";\nimport columnStyles from \"../column.module.sass\";\nimport styles from \"./surfaces.module.sass\";\nimport {\n type ColumnSurface,\n type SurfaceStatus,\n formatProportion,\n surfaceLabel,\n surfacePosition,\n surfaceStatusLabels,\n surfaceToken,\n TIE_POINT_STATUSES,\n} from \"./types\";\nimport { type UseColumnSurfacesOptions, useColumnSurfaces } from \"./data\";\n\nconst h = hyper.styled(styles);\n\n/** How far the surface lines extend: across the units column only, or the\n * full width of the column including its axes. */\nexport type SurfaceLinesExtent = \"units\" | \"column\";\n\nexport type SurfaceSelectionHandler = (surface: ColumnSurface | null) => void;\n\nexport interface SurfaceSelectionProps {\n /** The selected surface's id. Pass `null` for a controlled, empty\n * selection; leave undefined for the component to manage selection. */\n selectedSurface?: ColumnSurface[\"id\"] | null;\n onSelectSurface?: SurfaceSelectionHandler;\n}\n\nexport interface ColumnSurfacesProps\n extends UseColumnSurfacesOptions, SurfaceSelectionProps {\n showLines?: boolean;\n showLabels?: boolean;\n extent?: SurfaceLinesExtent;\n /** Width of the labels column, connector included (default 200) */\n labelWidth?: number;\n labelPaddingLeft?: number;\n /** Only show surfaces with these statuses */\n statuses?: SurfaceStatus[] | null;\n /** Which surfaces get a label. Defaults to the tie points — the statuses\n * at which the age model was constrained — so interpolated (`modeled`),\n * unspecified and unit-derived surfaces are drawn as lines only. Pass\n * `null` to label every surface shown. */\n labelStatuses?: SurfaceStatus[] | null;\n /** Labels closer than this (in pixels) are thinned out, since the column\n * has finite room; the selected surface's label is always kept. */\n minLabelSpacing?: number;\n className?: string;\n}\n\nexport function ColumnSurfaces(props: ColumnSurfacesProps) {\n const {\n showLines = true,\n showLabels = true,\n extent = \"units\",\n labelWidth,\n labelPaddingLeft,\n statuses,\n labelStatuses = TIE_POINT_STATUSES,\n minLabelSpacing,\n selectedSurface,\n onSelectSurface,\n className,\n ...dataOptions\n } = props;\n\n const { surfaces: allSurfaces } = useColumnSurfaces(dataOptions);\n const surfaces = useMemo(\n () => filterByStatus(allSurfaces, statuses),\n [allSurfaces, statuses],\n );\n\n const [selectedID, select] = useSurfaceSelection(\n selectedSurface,\n onSelectSurface,\n );\n\n return h([\n h.if(showLines)(ColumnSurfaceLines, {\n surfaces,\n extent,\n selectedSurface: selectedID,\n onSelectSurface: select,\n className,\n }),\n h.if(showLabels)(ColumnSurfaceLabels, {\n surfaces,\n labelStatuses,\n minLabelSpacing,\n width: labelWidth,\n paddingLeft: labelPaddingLeft,\n selectedSurface: selectedID,\n onSelectSurface: select,\n className,\n }),\n ]);\n}\n\nexport interface ColumnSurfaceLinesProps extends SurfaceSelectionProps {\n surfaces: ColumnSurface[];\n extent?: SurfaceLinesExtent;\n className?: string;\n}\n\n/** One horizontal line per surface, overlaid on the column at the surface's\n * age (or measured position, for height and depth columns). */\nexport function ColumnSurfaceLines(props: ColumnSurfaceLinesProps) {\n const {\n surfaces,\n extent = \"units\",\n selectedSurface,\n onSelectSurface,\n className,\n } = props;\n const scale = useCompositeScale();\n const { axisType, totalHeight } = useMacrostratColumnData();\n const intervalMap = useSurfaceIntervalDefs(surfaces);\n\n const ref = useRef<HTMLDivElement>(null);\n const unitsExtent = useUnitsColumnExtent(ref, extent === \"units\");\n\n let style: CSSProperties = { height: totalHeight };\n if (unitsExtent != null) {\n style = { ...style, left: unitsExtent.left, width: unitsExtent.width };\n }\n const measuring = extent === \"units\" && unitsExtent == null;\n\n return h(\n \"div.column-surface-lines\",\n { ref, style, className: classNames(className, { measuring }) },\n surfaces.map((surface) => {\n const position = surfacePosition(surface, axisType);\n if (position == null) return null;\n const y = scale(position);\n if (y == null) return null;\n return h(SurfaceLine, {\n key: surface.id,\n surface,\n y,\n color: surfaceIntervalColor(surface, intervalMap),\n selected: surface.id === selectedSurface,\n onSelect: onSelectSurface,\n });\n }),\n );\n}\n\nfunction SurfaceLine({\n surface,\n y,\n color,\n selected,\n onSelect,\n}: {\n surface: ColumnSurface;\n y: number;\n /** The interval color, when known; otherwise the status color is used */\n color?: string | null;\n selected: boolean;\n onSelect?: SurfaceSelectionHandler;\n}) {\n const onClick = useCallback(\n (evt: MouseEvent) => {\n // Don't let the column deselect its unit\n evt.stopPropagation();\n if (selected) {\n onSelect?.(null);\n } else {\n onSelect?.(surface);\n }\n },\n [surface, selected, onSelect],\n );\n\n let style: CSSProperties = { top: y };\n if (color != null) {\n style = { ...style, \"--surface-color\": color } as CSSProperties;\n }\n\n return h(\n \"div.surface-line\",\n {\n style,\n className: classNames(surfaceClasses(surface), {\n selected,\n interactive: onSelect != null,\n }),\n title: surfaceLabel(surface),\n onClick,\n },\n h(\"div.surface-line-inner\"),\n );\n}\n\nexport interface ColumnSurfaceLabelsProps extends SurfaceSelectionProps {\n surfaces: ColumnSurface[];\n /** Which surfaces get a label (see `ColumnSurfacesProps.labelStatuses`) */\n labelStatuses?: SurfaceStatus[] | null;\n /** Minimum pixel spacing between labels (see `ColumnSurfacesProps`) */\n minLabelSpacing?: number;\n /** Total width, connector included */\n width?: number;\n paddingLeft?: number;\n className?: string;\n}\n\ninterface SurfaceNote extends NoteData {\n /** The interval color, which the note's connector picks up */\n color?: string;\n surface: ColumnSurface;\n /** The calibration interval, with color and rank from the definitions */\n interval: IntervalShort | null;\n selected: boolean;\n}\n\n/** A notes column of surface labels, laid out beside the units with the\n * collision avoidance of `NotesColumn`. It takes the label column over from\n * the unit labels while mounted: labels are one or the other. */\nexport function ColumnSurfaceLabels(props: ColumnSurfaceLabelsProps) {\n const {\n surfaces,\n labelStatuses = TIE_POINT_STATUSES,\n minLabelSpacing = 22,\n width = 200,\n paddingLeft = 24,\n selectedSurface,\n onSelectSurface,\n className,\n } = props;\n const { axisType } = useMacrostratColumnData();\n const scale = useCompositeScale();\n const intervalMap = useSurfaceIntervalDefs(surfaces);\n useClaimLabelColumn();\n\n const labeled = useMemo(() => {\n const byStatus = filterByStatus(surfaces, labelStatuses);\n return thinByPixelSpacing(\n byStatus,\n (s) => scale(surfacePosition(s, axisType) ?? NaN),\n minLabelSpacing,\n selectedSurface,\n );\n }, [\n surfaces,\n labelStatuses,\n minLabelSpacing,\n selectedSurface,\n scale,\n axisType,\n ]);\n\n const notes: SurfaceNote[] = useMemo(() => {\n const _notes: SurfaceNote[] = [];\n for (const surface of labeled) {\n const position = surfacePosition(surface, axisType);\n if (position == null) continue;\n _notes.push({\n id: surface.id,\n height: position,\n note: surfaceLabel(surface),\n // The note's color reaches its connector, so a label's leader line\n // matches the surface line it points at\n color: surfaceIntervalColor(surface, intervalMap) ?? undefined,\n surface,\n interval: calibrationInterval(surface, intervalMap),\n selected: surface.id === selectedSurface,\n });\n }\n return _notes;\n }, [labeled, axisType, selectedSurface, intervalMap]);\n\n const onClickNote = useCallback(\n (note: NoteData) => {\n const { surface, selected } = note as SurfaceNote;\n if (selected) {\n onSelectSurface?.(null);\n } else {\n onSelectSurface?.(surface);\n }\n },\n [onSelectSurface],\n );\n\n return h(\n \"div.column-surface-labels\",\n { className },\n h(ColumnNotes, {\n notes,\n width,\n paddingLeft,\n noteComponent: SurfaceNoteLabel,\n onClickNote,\n forceOptions: LABEL_FORCE_OPTIONS,\n // The leader runs from the surface line in the column to the tag body,\n // continuing a little past both ends rather than stopping in the gap —\n // so it needs no endpoint marker of its own\n connectorOverhang: LABEL_CONNECTOR_OVERHANG,\n showPointMarker: false,\n }),\n );\n}\n\n/** Breathing room between stacked labels, in pixels */\nconst LABEL_FORCE_OPTIONS = { nodeSpacing: 2 };\n\n/** How far the label's leader line continues past each end, in pixels: left\n * into the column to meet the surface line, right under the tag body. */\nconst LABEL_CONNECTOR_OVERHANG: [number, number] = [8, 6];\n\n/** A surface's label: its calibration interval as the standard interval tag\n * (with the position within the interval as the tag's detail), and the\n * modeled age beneath. Surfaces without a calibration show their status. */\nfunction SurfaceNoteLabel({ note }: { note: SurfaceNote }) {\n const { surface, interval, selected } = note;\n\n let primary: any;\n if (interval != null) {\n primary = h(IntervalTag, {\n interval,\n size: TagSize.Small,\n proportion: surface.proportion,\n className: \"surface-interval-tag\",\n });\n } else {\n primary = h(\n \"span.surface-label-status\",\n `${surfaceStatusLabels[surface.status]} surface`,\n );\n }\n\n return h(\n \"div.surface-label\",\n { className: classNames(surfaceClasses(surface), { selected }) },\n h(\"div.surface-label-primary\", primary),\n );\n}\n\n/** The interval definitions for the surfaces' calibration intervals. The age\n * model carries interval ids and names but no colors, so they come from the\n * definitions store (which holds them all, and fetches once). */\nfunction useSurfaceIntervalDefs(\n surfaces: ColumnSurface[],\n): Map<number, any> | null {\n const intervalIDs = useMemo(() => {\n const ids = new Set<number>();\n for (const surface of surfaces) {\n if (surface.calibration != null) ids.add(surface.calibration.id);\n }\n return Array.from(ids);\n }, [surfaces]);\n return useMacrostratDefs(\"intervals\", intervalIDs, null);\n}\n\n/** The color a surface is drawn in: its calibration interval's, so the line\n * and its label's leader read as the interval the surface is tied to. `null`\n * for an uncalibrated surface, or before the definitions load — the status\n * color stands in. */\nfunction surfaceIntervalColor(\n surface: ColumnSurface,\n intervalMap: Map<number, any> | null,\n): string | null {\n const id = surface.calibration?.id;\n if (id == null) return null;\n return intervalMap?.get(id)?.color ?? null;\n}\n\n/** The calibration interval in the shape the interval tag takes, colored\n * from the definitions when they have loaded. */\nfunction calibrationInterval(\n surface: ColumnSurface,\n intervalMap: Map<number, any> | null,\n): IntervalShort | null {\n const { calibration } = surface;\n if (calibration == null) return null;\n const def = intervalMap?.get(calibration.id);\n return {\n id: calibration.id,\n name: calibration.name,\n b_age: calibration.b_age,\n t_age: calibration.t_age,\n color: def?.color,\n rank: def?.rank,\n };\n}\n\n/** Class names shared by the lines, labels, legend and tags, so a status or\n * type reads the same everywhere. */\nexport function surfaceClasses(surface: {\n status?: SurfaceStatus | null;\n type?: string | null;\n}): string {\n return classNames(\n `status-${surfaceToken(surface.status)}`,\n `type-${surfaceToken(surface.type)}`,\n );\n}\n\n/** Walk the surfaces down the column and drop any whose label would sit\n * within `minSpacing` pixels of the last one kept. The selected surface is\n * always kept (and displaces a neighbor if need be). */\nfunction thinByPixelSpacing(\n surfaces: ColumnSurface[],\n pixelPosition: (s: ColumnSurface) => number | null,\n minSpacing: number,\n selectedSurface: ColumnSurface[\"id\"] | null | undefined,\n): ColumnSurface[] {\n if (minSpacing <= 0) return surfaces;\n const positioned = surfaces\n .map((surface) => ({ surface, y: pixelPosition(surface) }))\n .filter((d) => d.y != null && !Number.isNaN(d.y))\n .sort((a, b) => a.y - b.y);\n\n const kept: { surface: ColumnSurface; y: number }[] = [];\n for (const item of positioned) {\n const selected = item.surface.id === selectedSurface;\n const last = kept[kept.length - 1];\n if (last == null || item.y - last.y >= minSpacing) {\n kept.push(item);\n } else if (selected) {\n // The selection wins its slot\n kept[kept.length - 1] = item;\n }\n }\n return kept.map((d) => d.surface);\n}\n\nfunction filterByStatus(\n surfaces: ColumnSurface[],\n statuses: SurfaceStatus[] | null | undefined,\n): ColumnSurface[] {\n if (statuses == null) return surfaces;\n const allowed = new Set(statuses);\n return surfaces.filter((d) => allowed.has(d.status));\n}\n\n/** Controlled-or-uncontrolled selection: when `selectedID` is passed (even as\n * `null`) the consumer owns it; otherwise it is kept internally. */\nfunction useSurfaceSelection(\n selectedID: ColumnSurface[\"id\"] | null | undefined,\n onSelect: SurfaceSelectionHandler | undefined,\n): [ColumnSurface[\"id\"] | null, SurfaceSelectionHandler] {\n const [internal, setInternal] = useState<ColumnSurface[\"id\"] | null>(null);\n const isControlled = selectedID !== undefined;\n\n const select: SurfaceSelectionHandler = useCallback(\n (surface) => {\n setInternal(surface?.id ?? null);\n onSelect?.(surface);\n },\n [onSelect],\n );\n\n let current = internal;\n if (isControlled) {\n current = selectedID;\n }\n return [current, select];\n}\n\ninterface HorizontalExtent {\n left: number;\n width: number;\n}\n\n/** `useLayoutEffect` in the browser, `useEffect` on the server — where it\n * would warn and has nothing to measure anyway. */\nconst useMeasureEffect =\n typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\n/** Measure where the units column sits within the `Column`, so an overlay\n * can cover exactly the units rather than the axes. `null` while unmeasured,\n * when disabled, or when the units column can't be found. */\nfunction useUnitsColumnExtent(\n ref: RefObject<HTMLDivElement | null>,\n enabled: boolean,\n): HorizontalExtent | null {\n const [extent, setExtent] = useState<HorizontalExtent | null>(null);\n\n const measure = useCallback(() => {\n if (!enabled) return;\n const parent = ref.current?.parentElement;\n const target = parent?.querySelector<HTMLElement>(\n `.${unitsContainerClass()}`,\n );\n if (parent == null || target == null) return;\n\n const p = parent.getBoundingClientRect();\n const t = target.getBoundingClientRect();\n const next = { left: t.left - p.left, width: t.width };\n setExtent((prev) => {\n if (prev?.left === next.left && prev?.width === next.width) {\n return prev;\n }\n return next;\n });\n }, [enabled]);\n\n // Re-measure on every render as a backstop: cheap, and it catches layout\n // changes that no observer reports.\n useMeasureEffect(measure);\n\n useMeasureEffect(() => {\n if (!enabled) {\n setExtent(null);\n return;\n }\n const parent = ref.current?.parentElement;\n if (parent == null) return;\n if (typeof ResizeObserver === \"undefined\") return;\n\n const observer = new ResizeObserver(measure);\n // The units column *moves* when a sibling changes width — the timescale\n // widening once its intervals load, or its level count changing — and\n // that is not a resize of the units column or of the column itself, so\n // the siblings have to be watched too.\n observer.observe(parent);\n for (const child of Array.from(parent.children)) {\n observer.observe(child);\n }\n return () => observer.disconnect();\n }, [enabled, measure]);\n\n return extent;\n}\n\n/** The (module-scoped) class of the units container rendered by\n * `SectionsColumn`. */\nfunction unitsContainerClass(): string {\n const s = columnStyles as any;\n return (\n s[\"section-units-container\"] ??\n s.sectionUnitsContainer ??\n \"section-units-container\"\n );\n}\n"],"names":["hyper","styles","columnStyles"],"mappings":";;;;;;;;;;;AA+CA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAoCtB,SAAS,eAAe,OAA4B;AACzD,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AAEJ,QAAM,EAAE,UAAU,gBAAgB,kBAAkB,WAAW;AAC/D,QAAM,WAAW;AAAA,IACf,MAAM,eAAe,aAAa,QAAQ;AAAA,IAC1C,CAAC,aAAa,QAAQ;AAAA,EAAA;AAGxB,QAAM,CAAC,YAAY,MAAM,IAAI;AAAA,IAC3B;AAAA,IACA;AAAA,EAAA;AAGF,SAAO,EAAE;AAAA,IACP,EAAE,GAAG,SAAS,EAAE,oBAAoB;AAAA,MAClC;AAAA,MACA;AAAA,MACA,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,MACjB;AAAA,IAAA,CACD;AAAA,IACD,EAAE,GAAG,UAAU,EAAE,qBAAqB;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,aAAa;AAAA,MACb,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,MACjB;AAAA,IAAA,CACD;AAAA,EAAA,CACF;AACH;AAUO,SAAS,mBAAmB,OAAgC;AACjE,QAAM;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE;AACJ,QAAM,QAAQ,kBAAA;AACd,QAAM,EAAE,UAAU,YAAA,IAAgB,wBAAA;AAClC,QAAM,cAAc,uBAAuB,QAAQ;AAEnD,QAAM,MAAM,OAAuB,IAAI;AACvC,QAAM,cAAc,qBAAq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AC5B,QAAI,UAAU,KAAM;AACpB,QAAI,OAAO,mBAAmB,YAAa;AAE3C,UAAM,WAAW,IAAI,eAAe,OAAO;AAK3C,aAAS,QAAQ,MAAM;AACvB,eAAW,SAAS,MAAM,KAAK,OAAO,QAAQ,GAAG;AAC/C,eAAS,QAAQ,KAAK;AAAA,IACxB;AACA,WAAO,MAAM,SAAS,WAAA;AAAA,EACxB,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,SAAO;AACT;AAIA,SAAS,sBAA8B;AACrC,QAAM,IAAIC;AACV,SACE,EAAE,yBAAyB,KAC3B,EAAE,yBACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"surfaces.js","sources":["../../src/age-model/surfaces.ts"],"sourcesContent":["/** The surfaces view: age-model calibration surfaces drawn on a column.\n *\n * `ColumnSurfaces` is dropped into a `Column` as a child. It draws one line\n * per surface across the units (`ColumnSurfaceLines`) and a notes column of\n * labels beside them (`ColumnSurfaceLabels`), styled by `boundary_status` and\n * `boundary_type`, with hover and selection. The labels sit where the unit\n * labels would, so pass `showLabelColumn: false` to the `Column` while they\n * are shown.\n */\nimport hyper from \"@macrostrat/hyper\";\nimport classNames from \"classnames\";\nimport {\n type CSSProperties,\n type RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { NoteData } from \"@macrostrat/column-components\";\nimport {\n type IntervalShort,\n IntervalTag,\n TagSize,\n} from \"@macrostrat/data-components\";\nimport { useMacrostratDefs } from \"@macrostrat/data-provider\";\nimport { useCompositeScale, useMacrostratColumnData } from \"../data-provider\";\nimport { ColumnNotes } from \"../notes\";\nimport { AgeLabel } from \"../unit-details/age-range\";\nimport columnStyles from \"../column.module.sass\";\nimport styles from \"./surfaces.module.sass\";\nimport {\n type ColumnSurface,\n type SurfaceStatus,\n formatProportion,\n surfaceLabel,\n surfacePosition,\n surfaceStatusLabels,\n surfaceToken,\n TIE_POINT_STATUSES,\n} from \"./types\";\nimport { type UseColumnSurfacesOptions, useColumnSurfaces } from \"./data\";\n\nconst h = hyper.styled(styles);\n\n/** How far the surface lines extend: across the units column only, or the\n * full width of the column including its axes. */\nexport type SurfaceLinesExtent = \"units\" | \"column\";\n\nexport type SurfaceSelectionHandler = (surface: ColumnSurface | null) => void;\n\nexport interface SurfaceSelectionProps {\n /** The selected surface's id. Pass `null` for a controlled, empty\n * selection; leave undefined for the component to manage selection. */\n selectedSurface?: ColumnSurface[\"id\"] | null;\n onSelectSurface?: SurfaceSelectionHandler;\n}\n\nexport interface ColumnSurfacesProps\n extends UseColumnSurfacesOptions, SurfaceSelectionProps {\n showLines?: boolean;\n showLabels?: boolean;\n extent?: SurfaceLinesExtent;\n /** Width of the labels column, connector included (default 200) */\n labelWidth?: number;\n labelPaddingLeft?: number;\n /** Only show surfaces with these statuses */\n statuses?: SurfaceStatus[] | null;\n /** Which surfaces get a label. Defaults to the tie points — the statuses\n * at which the age model was constrained — so interpolated (`modeled`),\n * unspecified and unit-derived surfaces are drawn as lines only. Pass\n * `null` to label every surface shown. */\n labelStatuses?: SurfaceStatus[] | null;\n /** Labels closer than this (in pixels) are thinned out, since the column\n * has finite room; the selected surface's label is always kept. */\n minLabelSpacing?: number;\n className?: string;\n}\n\nexport function ColumnSurfaces(props: ColumnSurfacesProps) {\n const {\n showLines = true,\n showLabels = true,\n extent = \"units\",\n labelWidth,\n labelPaddingLeft,\n statuses,\n labelStatuses = TIE_POINT_STATUSES,\n minLabelSpacing,\n selectedSurface,\n onSelectSurface,\n className,\n ...dataOptions\n } = props;\n\n const { surfaces: allSurfaces } = useColumnSurfaces(dataOptions);\n const surfaces = useMemo(\n () => filterByStatus(allSurfaces, statuses),\n [allSurfaces, statuses],\n );\n\n const [selectedID, select] = useSurfaceSelection(\n selectedSurface,\n onSelectSurface,\n );\n\n return h([\n h.if(showLines)(ColumnSurfaceLines, {\n surfaces,\n extent,\n selectedSurface: selectedID,\n onSelectSurface: select,\n className,\n }),\n h.if(showLabels)(ColumnSurfaceLabels, {\n surfaces,\n labelStatuses,\n minLabelSpacing,\n width: labelWidth,\n paddingLeft: labelPaddingLeft,\n selectedSurface: selectedID,\n onSelectSurface: select,\n className,\n }),\n ]);\n}\n\nexport interface ColumnSurfaceLinesProps extends SurfaceSelectionProps {\n surfaces: ColumnSurface[];\n extent?: SurfaceLinesExtent;\n className?: string;\n}\n\n/** One horizontal line per surface, overlaid on the column at the surface's\n * age (or measured position, for height and depth columns). */\nexport function ColumnSurfaceLines(props: ColumnSurfaceLinesProps) {\n const {\n surfaces,\n extent = \"units\",\n selectedSurface,\n onSelectSurface,\n className,\n } = props;\n const scale = useCompositeScale();\n const { axisType, totalHeight } = useMacrostratColumnData();\n const intervalMap = useSurfaceIntervalDefs(surfaces);\n\n const ref = useRef<HTMLDivElement>(null);\n const unitsExtent = useUnitsColumnExtent(ref, extent === \"units\");\n\n let style: CSSProperties = { height: totalHeight };\n if (unitsExtent != null) {\n style = { ...style, left: unitsExtent.left, width: unitsExtent.width };\n }\n const measuring = extent === \"units\" && unitsExtent == null;\n\n return h(\n \"div.column-surface-lines\",\n { ref, style, className: classNames(className, { measuring }) },\n surfaces.map((surface) => {\n const position = surfacePosition(surface, axisType);\n if (position == null) return null;\n const y = scale(position);\n if (y == null) return null;\n return h(SurfaceLine, {\n key: surface.id,\n surface,\n y,\n color: surfaceIntervalColor(surface, intervalMap),\n selected: surface.id === selectedSurface,\n onSelect: onSelectSurface,\n });\n }),\n );\n}\n\nfunction SurfaceLine({\n surface,\n y,\n color,\n selected,\n onSelect,\n}: {\n surface: ColumnSurface;\n y: number;\n /** The interval color, when known; otherwise the status color is used */\n color?: string | null;\n selected: boolean;\n onSelect?: SurfaceSelectionHandler;\n}) {\n const onClick = useCallback(\n (evt: MouseEvent) => {\n // Don't let the column deselect its unit\n evt.stopPropagation();\n if (selected) {\n onSelect?.(null);\n } else {\n onSelect?.(surface);\n }\n },\n [surface, selected, onSelect],\n );\n\n let style: CSSProperties = { top: y };\n if (color != null) {\n style = { ...style, \"--surface-color\": color } as CSSProperties;\n }\n\n return h(\n \"div.surface-line\",\n {\n style,\n className: classNames(surfaceClasses(surface), {\n selected,\n interactive: onSelect != null,\n }),\n title: surfaceLabel(surface),\n onClick,\n },\n h(\"div.surface-line-inner\"),\n );\n}\n\nexport interface ColumnSurfaceLabelsProps extends SurfaceSelectionProps {\n surfaces: ColumnSurface[];\n /** Which surfaces get a label (see `ColumnSurfacesProps.labelStatuses`) */\n labelStatuses?: SurfaceStatus[] | null;\n /** Minimum pixel spacing between labels (see `ColumnSurfacesProps`) */\n minLabelSpacing?: number;\n /** Total width, connector included */\n width?: number;\n paddingLeft?: number;\n className?: string;\n}\n\ninterface SurfaceNote extends NoteData {\n /** The interval color, which the note's connector picks up */\n color?: string;\n surface: ColumnSurface;\n /** The calibration interval, with color and rank from the definitions */\n interval: IntervalShort | null;\n selected: boolean;\n}\n\n/** A notes column of surface labels, laid out beside the units with the\n * collision avoidance of `NotesColumn`. It draws over the unit labels, so the\n * `Column` should hide its label column (`showLabelColumn: false`). */\nexport function ColumnSurfaceLabels(props: ColumnSurfaceLabelsProps) {\n const {\n surfaces,\n labelStatuses = TIE_POINT_STATUSES,\n minLabelSpacing = 22,\n width = 200,\n paddingLeft = 24,\n selectedSurface,\n onSelectSurface,\n className,\n } = props;\n const { axisType } = useMacrostratColumnData();\n const scale = useCompositeScale();\n const intervalMap = useSurfaceIntervalDefs(surfaces);\n\n const labeled = useMemo(() => {\n const byStatus = filterByStatus(surfaces, labelStatuses);\n return thinByPixelSpacing(\n byStatus,\n (s) => scale(surfacePosition(s, axisType) ?? NaN),\n minLabelSpacing,\n selectedSurface,\n );\n }, [\n surfaces,\n labelStatuses,\n minLabelSpacing,\n selectedSurface,\n scale,\n axisType,\n ]);\n\n const notes: SurfaceNote[] = useMemo(() => {\n const _notes: SurfaceNote[] = [];\n for (const surface of labeled) {\n const position = surfacePosition(surface, axisType);\n if (position == null) continue;\n _notes.push({\n id: surface.id,\n height: position,\n note: surfaceLabel(surface),\n // The note's color reaches its connector, so a label's leader line\n // matches the surface line it points at\n color: surfaceIntervalColor(surface, intervalMap) ?? undefined,\n surface,\n interval: calibrationInterval(surface, intervalMap),\n selected: surface.id === selectedSurface,\n });\n }\n return _notes;\n }, [labeled, axisType, selectedSurface, intervalMap]);\n\n const onClickNote = useCallback(\n (note: NoteData) => {\n const { surface, selected } = note as SurfaceNote;\n if (selected) {\n onSelectSurface?.(null);\n } else {\n onSelectSurface?.(surface);\n }\n },\n [onSelectSurface],\n );\n\n return h(\n \"div.column-surface-labels\",\n { className },\n h(ColumnNotes, {\n notes,\n width,\n paddingLeft,\n noteComponent: SurfaceNoteLabel,\n onClickNote,\n forceOptions: LABEL_FORCE_OPTIONS,\n // The leader runs from the surface line in the column to the tag body,\n // continuing a little past both ends rather than stopping in the gap —\n // so it needs no endpoint marker of its own\n connectorOverhang: LABEL_CONNECTOR_OVERHANG,\n showPointMarker: false,\n }),\n );\n}\n\n/** Breathing room between stacked labels, in pixels */\nconst LABEL_FORCE_OPTIONS = { nodeSpacing: 2 };\n\n/** How far the label's leader line continues past each end, in pixels: left\n * into the column to meet the surface line, right under the tag body. */\nconst LABEL_CONNECTOR_OVERHANG: [number, number] = [8, 6];\n\n/** A surface's label: its calibration interval as the standard interval tag\n * (with the position within the interval as the tag's detail), and the\n * modeled age beneath. Surfaces without a calibration show their status. */\nfunction SurfaceNoteLabel({ note }: { note: SurfaceNote }) {\n const { surface, interval, selected } = note;\n\n let primary: any;\n if (interval != null) {\n primary = h(IntervalTag, {\n interval,\n size: TagSize.Small,\n proportion: surface.proportion,\n className: \"surface-interval-tag\",\n });\n } else {\n primary = h(\n \"span.surface-label-status\",\n `${surfaceStatusLabels[surface.status]} surface`,\n );\n }\n\n return h(\n \"div.surface-label\",\n { className: classNames(surfaceClasses(surface), { selected }) },\n h(\"div.surface-label-primary\", primary),\n );\n}\n\n/** The interval definitions for the surfaces' calibration intervals. The age\n * model carries interval ids and names but no colors, so they come from the\n * definitions store (which holds them all, and fetches once). */\nfunction useSurfaceIntervalDefs(\n surfaces: ColumnSurface[],\n): Map<number, any> | null {\n const intervalIDs = useMemo(() => {\n const ids = new Set<number>();\n for (const surface of surfaces) {\n if (surface.calibration != null) ids.add(surface.calibration.id);\n }\n return Array.from(ids);\n }, [surfaces]);\n return useMacrostratDefs(\"intervals\", intervalIDs, null);\n}\n\n/** The color a surface is drawn in: its calibration interval's, so the line\n * and its label's leader read as the interval the surface is tied to. `null`\n * for an uncalibrated surface, or before the definitions load — the status\n * color stands in. */\nfunction surfaceIntervalColor(\n surface: ColumnSurface,\n intervalMap: Map<number, any> | null,\n): string | null {\n const id = surface.calibration?.id;\n if (id == null) return null;\n return intervalMap?.get(id)?.color ?? null;\n}\n\n/** The calibration interval in the shape the interval tag takes, colored\n * from the definitions when they have loaded. */\nfunction calibrationInterval(\n surface: ColumnSurface,\n intervalMap: Map<number, any> | null,\n): IntervalShort | null {\n const { calibration } = surface;\n if (calibration == null) return null;\n const def = intervalMap?.get(calibration.id);\n return {\n id: calibration.id,\n name: calibration.name,\n b_age: calibration.b_age,\n t_age: calibration.t_age,\n color: def?.color,\n rank: def?.rank,\n };\n}\n\n/** Class names shared by the lines, labels, legend and tags, so a status or\n * type reads the same everywhere. */\nexport function surfaceClasses(surface: {\n status?: SurfaceStatus | null;\n type?: string | null;\n}): string {\n return classNames(\n `status-${surfaceToken(surface.status)}`,\n `type-${surfaceToken(surface.type)}`,\n );\n}\n\n/** Walk the surfaces down the column and drop any whose label would sit\n * within `minSpacing` pixels of the last one kept. The selected surface is\n * always kept (and displaces a neighbor if need be). */\nfunction thinByPixelSpacing(\n surfaces: ColumnSurface[],\n pixelPosition: (s: ColumnSurface) => number | null,\n minSpacing: number,\n selectedSurface: ColumnSurface[\"id\"] | null | undefined,\n): ColumnSurface[] {\n if (minSpacing <= 0) return surfaces;\n const positioned = surfaces\n .map((surface) => ({ surface, y: pixelPosition(surface) }))\n .filter((d) => d.y != null && !Number.isNaN(d.y))\n .sort((a, b) => a.y - b.y);\n\n const kept: { surface: ColumnSurface; y: number }[] = [];\n for (const item of positioned) {\n const selected = item.surface.id === selectedSurface;\n const last = kept[kept.length - 1];\n if (last == null || item.y - last.y >= minSpacing) {\n kept.push(item);\n } else if (selected) {\n // The selection wins its slot\n kept[kept.length - 1] = item;\n }\n }\n return kept.map((d) => d.surface);\n}\n\nfunction filterByStatus(\n surfaces: ColumnSurface[],\n statuses: SurfaceStatus[] | null | undefined,\n): ColumnSurface[] {\n if (statuses == null) return surfaces;\n const allowed = new Set(statuses);\n return surfaces.filter((d) => allowed.has(d.status));\n}\n\n/** Controlled-or-uncontrolled selection: when `selectedID` is passed (even as\n * `null`) the consumer owns it; otherwise it is kept internally. */\nfunction useSurfaceSelection(\n selectedID: ColumnSurface[\"id\"] | null | undefined,\n onSelect: SurfaceSelectionHandler | undefined,\n): [ColumnSurface[\"id\"] | null, SurfaceSelectionHandler] {\n const [internal, setInternal] = useState<ColumnSurface[\"id\"] | null>(null);\n const isControlled = selectedID !== undefined;\n\n const select: SurfaceSelectionHandler = useCallback(\n (surface) => {\n setInternal(surface?.id ?? null);\n onSelect?.(surface);\n },\n [onSelect],\n );\n\n let current = internal;\n if (isControlled) {\n current = selectedID;\n }\n return [current, select];\n}\n\ninterface HorizontalExtent {\n left: number;\n width: number;\n}\n\n/** `useLayoutEffect` in the browser, `useEffect` on the server — where it\n * would warn and has nothing to measure anyway. */\nconst useMeasureEffect =\n typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\n/** Measure where the units column sits within the `Column`, so an overlay\n * can cover exactly the units rather than the axes. `null` while unmeasured,\n * when disabled, or when the units column can't be found. */\nfunction useUnitsColumnExtent(\n ref: RefObject<HTMLDivElement | null>,\n enabled: boolean,\n): HorizontalExtent | null {\n const [extent, setExtent] = useState<HorizontalExtent | null>(null);\n\n const measure = useCallback(() => {\n if (!enabled) return;\n const parent = ref.current?.parentElement;\n const target = parent?.querySelector<HTMLElement>(\n `.${unitsContainerClass()}`,\n );\n if (parent == null || target == null) return;\n\n const p = parent.getBoundingClientRect();\n const t = target.getBoundingClientRect();\n const next = { left: t.left - p.left, width: t.width };\n setExtent((prev) => {\n if (prev?.left === next.left && prev?.width === next.width) {\n return prev;\n }\n return next;\n });\n }, [enabled]);\n\n // Re-measure on every render as a backstop: cheap, and it catches layout\n // changes that no observer reports.\n useMeasureEffect(measure);\n\n useMeasureEffect(() => {\n if (!enabled) {\n setExtent(null);\n return;\n }\n const parent = ref.current?.parentElement;\n if (parent == null) return;\n if (typeof ResizeObserver === \"undefined\") return;\n\n const observer = new ResizeObserver(measure);\n // The units column *moves* when a sibling changes width — the timescale\n // widening once its intervals load, or its level count changing — and\n // that is not a resize of the units column or of the column itself, so\n // the siblings have to be watched too.\n observer.observe(parent);\n for (const child of Array.from(parent.children)) {\n observer.observe(child);\n }\n return () => observer.disconnect();\n }, [enabled, measure]);\n\n return extent;\n}\n\n/** The (module-scoped) class of the units container rendered by\n * `SectionsColumn`. */\nfunction unitsContainerClass(): string {\n const s = columnStyles as any;\n return (\n s[\"section-units-container\"] ??\n s.sectionUnitsContainer ??\n \"section-units-container\"\n );\n}\n"],"names":["hyper","styles","columnStyles"],"mappings":";;;;;;;;;;;AA6CA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAoCtB,SAAS,eAAe,OAA4B;AACzD,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AAEJ,QAAM,EAAE,UAAU,gBAAgB,kBAAkB,WAAW;AAC/D,QAAM,WAAW;AAAA,IACf,MAAM,eAAe,aAAa,QAAQ;AAAA,IAC1C,CAAC,aAAa,QAAQ;AAAA,EAAA;AAGxB,QAAM,CAAC,YAAY,MAAM,IAAI;AAAA,IAC3B;AAAA,IACA;A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AI;AAElE,QAAM,UAAU,YAAY,MAAM;AAChC,QAAI,CAAC,QAAS;AACd,UAAM,SAAS,IAAI,SAAS;AAC5B,UAAM,SAAS,QAAQ;AAAA,MACrB,IAAI,qBAAqB;AAAA,IAAA;AAE3B,QAAI,UAAU,QAAQ,UAAU,KAAM;AAEtC,UAAM,IAAI,OAAO,sBAAA;AACjB,UAAM,IAAI,OAAO,sBAAA;AACjB,UAAM,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,EAAE,MAAA;AAC/C,cAAU,CAAC,SAAS;AAClB,UAAI,MAAM,SAAS,KAAK,QAAQ,MAAM,UAAU,KAAK,OAAO;AAC1D,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH,GAAG,CAAC,OAAO,CAAC;AAIZ,mBAAiB,OAAO;AAExB,mBAAiB,MAAM;AACrB,QAAI,CAAC,SAAS;AACZ,gBAAU,IAAI;AACd;AAAA,IACF;AACA,UAAM,SAAS,IAAI,SAAS;AAC5B,QAAI,UAAU,KAAM;AACpB,QAAI,OAAO,mBAAmB,YAAa;AAE3C,UAAM,WAAW,IAAI,eAAe,OAAO;AAK3C,aAAS,QAAQ,MAAM;AACvB,eAAW,SAAS,MAAM,KAAK,OAAO,QAAQ,GAAG;AAC/C,eAAS,QAAQ,KAAK;AAAA,IACxB;AACA,WAAO,MAAM,SAAS,WAAA;AAAA,EACxB,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,SAAO;AACT;AAIA,SAAS,sBAA8B;AACrC,QAAM,IAAIC;AACV,SACE,EAAE,yBAAyB,KAC3B,EAAE,yBACF;AAEJ;"}
|
package/dist/column.cjs
CHANGED
|
@@ -56,16 +56,6 @@ function Column(props) {
|
|
|
56
56
|
ageAxisComponent = ageAxis.ApproximateHeightAxis;
|
|
57
57
|
_axisType = columnComponents.ColumnAxisType.AGE;
|
|
58
58
|
}
|
|
59
|
-
let _sectionOptions = sectionOptions;
|
|
60
|
-
if (_sectionOptions == void 0) {
|
|
61
|
-
_sectionOptions = (ctx) => {
|
|
62
|
-
const n = ctx.units.length;
|
|
63
|
-
const expansionFactor = 8 / Math.min(Math.max(n, 1), 8);
|
|
64
|
-
return {
|
|
65
|
-
targetUnitHeight: targetUnitHeight * expansionFactor
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
59
|
const { sections, units, totalHeight } = index.usePreparedColumnUnits(rawUnits, {
|
|
70
60
|
axisType: _axisType,
|
|
71
61
|
t_age,
|
|
@@ -74,7 +64,7 @@ function Column(props) {
|
|
|
74
64
|
b_pos,
|
|
75
65
|
mergeSections,
|
|
76
66
|
targetUnitHeight,
|
|
77
|
-
sectionOptions
|
|
67
|
+
sectionOptions,
|
|
78
68
|
unconformityHeight,
|
|
79
69
|
pixelScale,
|
|
80
70
|
pixelsPerMyr,
|
|
@@ -146,10 +136,10 @@ function ColumnInner(props) {
|
|
|
146
136
|
onMouseOver,
|
|
147
137
|
onClickTimescaleInterval,
|
|
148
138
|
timescaleIntervalStyle,
|
|
149
|
-
ageAxisComponent = ageAxis.CompositeAgeAxis
|
|
139
|
+
ageAxisComponent = ageAxis.CompositeAgeAxis,
|
|
140
|
+
showAgeAxis = true
|
|
150
141
|
} = props;
|
|
151
142
|
const { axisType } = store.useMacrostratColumnData();
|
|
152
|
-
const labelColumnClaimed = store.useLabelColumnClaimed();
|
|
153
143
|
const columnRef = unitSelection.useColumnRef();
|
|
154
144
|
let _timescaleUnconformityLabels = false;
|
|
155
145
|
let _sectionUnconformityLabels = false;
|
|
@@ -164,14 +154,10 @@ function ColumnInner(props) {
|
|
|
164
154
|
columnWidth = width;
|
|
165
155
|
}
|
|
166
156
|
let showLabelColumn = _showLabelColumn;
|
|
167
|
-
if (columnWidth > width - 10
|
|
157
|
+
if (columnWidth > width - 10) {
|
|
168
158
|
showLabelColumn = false;
|
|
169
159
|
}
|
|
170
|
-
|
|
171
|
-
if (timescaleLevels != null || timescales != null) {
|
|
172
|
-
_showTimescale = true;
|
|
173
|
-
}
|
|
174
|
-
_showTimescale = axisType == columnComponents.ColumnAxisType.AGE && _showTimescale;
|
|
160
|
+
const _showTimescale = axisType == columnComponents.ColumnAxisType.AGE && (showTimescale ?? true);
|
|
175
161
|
return column_module.default(
|
|
176
162
|
ColumnContainer,
|
|
177
163
|
{
|
|
@@ -180,7 +166,7 @@ function ColumnInner(props) {
|
|
|
180
166
|
className
|
|
181
167
|
},
|
|
182
168
|
column_module.default("div.column", { ref: columnRef }, [
|
|
183
|
-
column_module.default(ageAxisComponent),
|
|
169
|
+
column_module.default.if(showAgeAxis)(ageAxisComponent),
|
|
184
170
|
column_module.default.if(_showTimescale)(section.CompositeTimescale, {
|
|
185
171
|
levels: timescaleLevels,
|
|
186
172
|
additionalTimescales,
|
package/dist/column.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column.cjs","sources":["../src/column.ts"],"sourcesContent":["import { ColumnAxisType } from \"@macrostrat/column-components\";\nimport {\n Box,\n extractPadding,\n Padding,\n useDarkMode,\n} from \"@macrostrat/ui-components\";\nimport classNames from \"classnames\";\nimport {\n HTMLAttributes,\n useCallback,\n CSSProperties,\n ComponentType,\n RefObject,\n} from \"react\";\nimport h from \"./column.module.sass\";\nimport { UnitComponent } from \"./units\";\nimport {\n ColumnRef,\n UnitKeyboardNavigation,\n useColumnRef,\n useUnitSelectionDispatch,\n} from \"./data-provider\";\n\nimport {\n Identifier,\n ReferencesField,\n UnitSelectionPopover,\n} from \"./unit-details\";\nimport {\n MacrostratColumnDataProvider,\n useCompositeScale,\n useLabelColumnClaimed,\n useMacrostratColumnData,\n} from \"./data-provider\";\nimport {\n SectionSharedProps,\n CompositeTimescale,\n type ColumnIntervalStyleBuilder,\n type ColumnTimescaleClickHandler,\n type ColumnTimescaleLike,\n SectionsColumn,\n} from \"./section\";\nimport { ApproximateHeightAxis, CompositeAgeAxis } from \"./age-axis\";\nimport {\n MergeSectionsMode,\n usePreparedColumnUnits,\n HybridScaleType,\n ColumnHeightScaleOptions,\n} from \"./prepare-units\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport { NonIdealState } from \"@blueprintjs/core\";\nimport { DataField } from \"@macrostrat/data-components\";\nimport { ScaleContinuousNumeric } from \"d3-scale\";\n\ninterface BaseColumnProps extends Omit<\n SectionSharedProps,\n \"unconformityLabels\"\n> {\n className?: string;\n showLabelColumn?: boolean;\n /** Suppress the label for a unit drawn thinner than this many pixels\n * (default 2) */\n labelSuppressHeight?: number;\n keyboardNavigation?: boolean;\n showLabels?: boolean;\n maxInternalColumns?: number;\n // Timescale properties\n showTimescale?: boolean;\n timescaleLevels?: number | [number, number];\n /** Regional or project timescales drawn as extra columns beside the\n * international one (see `CompositeTimescale`). Narrow `timescaleLevels` by\n * as many to swap the finest level for them rather than widen the column. */\n additionalTimescales?: number[];\n /** Every timescale to draw beside the column, in order: a Macrostrat\n * timescale ID, or a timescale with its own intervals (see\n * `CompositeTimescale`). Supersedes `timescaleLevels` and\n * `additionalTimescales`. */\n timescales?: ColumnTimescaleLike[];\n /** Draw each timescale's name above it */\n showTimescaleLabels?: boolean;\n /** Called when a timescale interval is clicked (e.g. to zoom the age range).\n * The data says which timescale it was clicked in. */\n onClickTimescaleInterval?: ColumnTimescaleClickHandler;\n /** Per-interval style for the timescale (e.g. to bold the selected\n * interval), by interval and the timescale it was drawn from. */\n timescaleIntervalStyle?: ColumnIntervalStyleBuilder;\n unconformityLabels?: boolean | UnconformityLabelPlacement;\n onMouseOver?: (\n unit: UnitLong | null,\n height: number | null,\n evt: MouseEvent,\n ) => void;\n}\n\nexport type UnconformityLabelPlacement = \"minimal\" | \"prominent\" | \"none\";\n\nexport interface ColumnProps\n extends Padding, BaseColumnProps, ColumnHeightScaleOptions {\n // Macrostrat units\n units: UnitLong[];\n t_age?: number;\n b_age?: number;\n t_pos?: number;\n b_pos?: number;\n mergeSections?: MergeSectionsMode;\n showUnitPopover?: boolean;\n allowUnitSelection?: boolean;\n selectedUnit?: number | null;\n onUnitSelected?: (unitID: number | null, unit: any) => void;\n // Unconformity height in pixels\n unconformityHeight?: number;\n scale?: ScaleContinuousNumeric<number, number>;\n /** True while the age window is animating (e.g. from `useAnimatedAgeWindow`),\n * so per-frame label/pattern recalculation can be skipped. */\n isTransitioning?: boolean;\n /** Hide unit labels while transitioning (perf escape hatch; default false —\n * labels stay visible through the animation). */\n hideLabelsWhileTransitioning?: boolean;\n ref?: RefObject<ColumnRef>;\n}\n\nexport function Column(props: ColumnProps) {\n const {\n showUnitPopover = false,\n keyboardNavigation = false,\n mergeSections,\n onUnitSelected,\n selectedUnit,\n children,\n units: rawUnits,\n t_age,\n b_age,\n t_pos,\n b_pos,\n unconformityHeight = 30,\n targetUnitHeight = 20,\n sectionOptions,\n pixelScale,\n pixelsPerMyr,\n pixelsPerMeter,\n minPixelScale = 0.2,\n minSectionHeight = 50,\n windowPadding = 0,\n collapseSmallUnconformities = true,\n allowUnitSelection = false,\n hybridScale,\n scale,\n axisType,\n isTransitioning,\n hideLabelsWhileTransitioning,\n ref,\n ...rest\n } = props;\n\n /* `pixelScale` and `targetUnitHeight` are alternatives: a density stated\n * outright takes over from the one a section's units imply, floors and all.\n * That is settled in `prepare-units/density`, so nothing is adjusted here. */\n\n // Handle special cases for hybrid scales (WIP, we need to regularize this)\n let _axisType = axisType ?? ColumnAxisType.AGE;\n let ageAxisComponent = CompositeAgeAxis;\n if (\n hybridScale?.type === HybridScaleType.ApproximateHeight &&\n _axisType != ColumnAxisType.AGE\n ) {\n // Use approximate height axis for non-age columns if a non-age axis type is requested\n ageAxisComponent = ApproximateHeightAxis;\n _axisType = ColumnAxisType.AGE;\n }\n\n let _sectionOptions = sectionOptions;\n if (_sectionOptions == undefined) {\n // Build our own section options function based on targetUnitHeight\n _sectionOptions = (ctx) => {\n /** Scale targetUnitHeight by the number of units, so that a section with just a few units\n * is drawn taller than a section with many units.\n */\n const n = ctx.units.length;\n const expansionFactor = 8 / Math.min(Math.max(n, 1), 8);\n\n return {\n targetUnitHeight: targetUnitHeight * expansionFactor,\n };\n };\n }\n\n const { sections, units, totalHeight } = usePreparedColumnUnits(rawUnits, {\n axisType: _axisType,\n t_age,\n b_age,\n t_pos,\n b_pos,\n mergeSections,\n targetUnitHeight,\n sectionOptions: _sectionOptions,\n unconformityHeight,\n pixelScale,\n pixelsPerMyr,\n pixelsPerMeter,\n minPixelScale,\n minSectionHeight,\n windowPadding,\n collapseSmallUnconformities,\n // TODO: consider unifying scale and hybridScale options\n scale,\n hybridScale,\n });\n\n if (sections.length === 0) {\n return h(\n \"div.column-container.empty\",\n h(NonIdealState, {\n title: \"Empty column\",\n description: \"No sections found in this column.\",\n icon: \"warning-sign\",\n }),\n );\n }\n\n return h(\n MacrostratColumnDataProvider,\n {\n units,\n sections,\n totalHeight,\n axisType: _axisType,\n allowUnitSelection: showUnitPopover || allowUnitSelection,\n onUnitSelected,\n selectedUnit,\n isTransitioning,\n hideLabelsWhileTransitioning,\n ref,\n },\n h(ColumnInner, { ageAxisComponent, ...rest }, [\n children,\n h.if(showUnitPopover)(UnitSelectionPopover),\n h.if(keyboardNavigation)(UnitKeyboardNavigation, { units }),\n ]),\n );\n}\n\ninterface ColumnInnerProps extends BaseColumnProps {\n ageAxisComponent?: ComponentType;\n}\n\nfunction ColumnInner(props: ColumnInnerProps) {\n const padding = extractPadding(props);\n\n // TODO: integrate padding vars more closely with the rest of the spacing (right now padding is a bit ad-hoc)\n const paddingVars: any = {\n \"--column-padding-top\": `${padding.paddingTop}px`,\n \"--column-padding-bottom\": `${padding.paddingBottom}px`,\n \"--column-padding-left\": `${padding.paddingLeft}px`,\n \"--column-padding-right\": `${padding.paddingRight}px`,\n };\n\n const {\n unitComponent = UnitComponent,\n unconformityLabels = \"minimal\",\n showLabels = true,\n width: _width = 300,\n columnWidth: _columnWidth = 150,\n showLabelColumn: _showLabelColumn = true,\n labelSuppressHeight,\n className,\n clipUnits = false,\n children,\n showTimescale,\n timescaleLevels,\n additionalTimescales,\n timescales,\n showTimescaleLabels,\n maxInternalColumns,\n onMouseOver,\n onClickTimescaleInterval,\n timescaleIntervalStyle,\n ageAxisComponent = CompositeAgeAxis,\n } = props;\n\n const { axisType } = useMacrostratColumnData();\n // A child layer drawing its own labels (the surfaces view) takes the label\n // column over from the unit labels\n const labelColumnClaimed = useLabelColumnClaimed();\n\n const columnRef = useColumnRef();\n\n // Coalesce unconformity label setting to a boolean\n let _timescaleUnconformityLabels = false;\n let _sectionUnconformityLabels = false;\n if (unconformityLabels === true || unconformityLabels === \"prominent\") {\n _sectionUnconformityLabels = true;\n } else if (unconformityLabels === \"minimal\") {\n _timescaleUnconformityLabels = true;\n }\n\n let width = _width;\n let columnWidth = _columnWidth;\n if (columnWidth > width) {\n columnWidth = width;\n }\n let showLabelColumn = _showLabelColumn;\n if (columnWidth > width - 10 || labelColumnClaimed) {\n showLabelColumn = false;\n }\n\n let _showTimescale = showTimescale ?? true;\n if (timescaleLevels != null || timescales != null) {\n _showTimescale = true;\n }\n _showTimescale = axisType == ColumnAxisType.AGE && _showTimescale;\n\n return h(\n ColumnContainer,\n {\n ...useMouseEventHandlers(onMouseOver),\n style: paddingVars,\n className,\n },\n h(\"div.column\", { ref: columnRef }, [\n h(ageAxisComponent),\n h.if(_showTimescale)(CompositeTimescale, {\n levels: timescaleLevels,\n additionalTimescales,\n timescales,\n showLabels: showTimescaleLabels,\n unconformityLabels: _timescaleUnconformityLabels,\n onClickInterval: onClickTimescaleInterval,\n intervalStyle: timescaleIntervalStyle,\n }),\n h(SectionsColumn, {\n unitComponent,\n showLabels,\n width,\n columnWidth,\n showLabelColumn,\n labelSuppressHeight,\n clipUnits,\n unconformityLabels: _sectionUnconformityLabels,\n maxInternalColumns,\n }),\n children,\n ]),\n );\n}\n\ntype ColumnMouseOverHandler = (\n unit: UnitLong | null,\n height: number | null,\n evt: MouseEvent,\n) => void;\n\nfunction useMouseEventHandlers(\n _onMouseOver: ColumnMouseOverHandler | null = null,\n) {\n /** Click event handler */\n\n // Click handler for unit selection\n const dispatch = useUnitSelectionDispatch();\n const onClick = useCallback(\n (evt) => {\n dispatch?.(null, null);\n },\n [dispatch],\n );\n\n /** Hover event handlers */\n const scale = useCompositeScale();\n\n const onMouseOver = useCallback(\n (evt) => {\n const height = scale.invert(\n evt.clientY - evt.currentTarget.getBoundingClientRect().top,\n );\n _onMouseOver?.(null, height, evt);\n },\n [scale, _onMouseOver],\n );\n\n const onMouseOut = useCallback(() => {\n _onMouseOver?.(null, null, null);\n }, [_onMouseOver]);\n\n if (_onMouseOver == null) {\n return {\n onClick,\n onMouseOver: undefined,\n onMouseMove: undefined,\n onMouseOut: undefined,\n };\n }\n\n return { onMouseOver, onMouseMove: onMouseOver, onMouseOut, onClick };\n}\n\nexport interface ColumnContainerProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n style?: CSSProperties;\n}\n\nexport function ColumnContainer(props: ColumnContainerProps) {\n const { className, ...rest } = props;\n const darkMode = useDarkMode();\n\n return h(Box, {\n className: classNames(\n className,\n {\n \"dark-mode\": darkMode?.isEnabled ?? false,\n },\n \"column-container\",\n ),\n ...rest,\n });\n}\n\nexport function ColumnBasicInfo({\n data,\n showColumnID = true,\n showReferences = true,\n}) {\n if (data == null) return null;\n return h(\"div.column-info\", [\n h(\"div.column-title-row\", [\n h(\"h2\", data.col_name),\n h.if(showColumnID)(\"h4\", h(Identifier, { id: data.col_id })),\n ]),\n h(DataField, { row: true, label: \"Group\", value: data.col_group }),\n h.if(showReferences)(ReferencesField, {\n refs: data.refs,\n inline: false,\n row: false,\n className: \"column-refs\",\n }),\n ]);\n}\n"],"names":["ColumnAxisType","CompositeAgeAxis","HybridScaleType","ApproximateHeightAxis","usePreparedColumnUnits","h","NonIdealState","MacrostratColumnDataProvider","UnitSelectionPopover","UnitKeyboardNavigation","extractPadding","UnitComponent","useMacrostratColumnData","useLabelColumnClaimed","useColumnRef","CompositeTimescale","SectionsColumn","useUnitSelectionDispatch","useCallback","useCompositeScale","useDarkMode","Box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E,wBAAwB;AAAA,MACxBA,sBAAE,MAAM,KAAK,QAAQ;AAAA,MACrBA,cAAAA,QAAE,GAAG,YAAY,EAAE,MAAMA,cAAAA,QAAEkB,eAAAA,YAAY,EAAE,IAAI,KAAK,QAAQ,CAAC;AAAA,IAAA,CAC5D;AAAA,IACDlB,sBAAEmB,eAAAA,WAAW,EAAE,KAAK,MAAM,OAAO,SAAS,OAAO,KAAK,WAAW;AAAA,IACjEnB,cAAAA,QAAE,GAAG,cAAc,EAAEoB,uBAAiB;AAAA,MACpC,MAAM,KAAK;AAAA,MACX,QAAQ;AAAA,MACR,KAAK;AAAA,MACL,WAAW;AAAA,IAAA,CACZ;AAAA,EAAA,CACF;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"column.cjs","sources":["../src/column.ts"],"sourcesContent":["import { ColumnAxisType } from \"@macrostrat/column-components\";\nimport {\n Box,\n extractPadding,\n Padding,\n useDarkMode,\n} from \"@macrostrat/ui-components\";\nimport classNames from \"classnames\";\nimport {\n HTMLAttributes,\n useCallback,\n CSSProperties,\n ComponentType,\n RefObject,\n} from \"react\";\nimport h from \"./column.module.sass\";\nimport { UnitComponent } from \"./units\";\nimport {\n ColumnRef,\n UnitKeyboardNavigation,\n useColumnRef,\n useUnitSelectionDispatch,\n} from \"./data-provider\";\n\nimport {\n Identifier,\n ReferencesField,\n UnitSelectionPopover,\n} from \"./unit-details\";\nimport {\n MacrostratColumnDataProvider,\n useCompositeScale,\n useMacrostratColumnData,\n} from \"./data-provider\";\nimport {\n SectionSharedProps,\n CompositeTimescale,\n type ColumnIntervalStyleBuilder,\n type ColumnTimescaleClickHandler,\n type ColumnTimescaleLike,\n SectionsColumn,\n} from \"./section\";\nimport { ApproximateHeightAxis, CompositeAgeAxis } from \"./age-axis\";\nimport {\n MergeSectionsMode,\n usePreparedColumnUnits,\n HybridScaleType,\n ColumnHeightScaleOptions,\n} from \"./prepare-units\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport { NonIdealState } from \"@blueprintjs/core\";\nimport { DataField } from \"@macrostrat/data-components\";\nimport { ScaleContinuousNumeric } from \"d3-scale\";\n\ninterface BaseColumnProps extends Omit<\n SectionSharedProps,\n \"unconformityLabels\"\n> {\n className?: string;\n showLabelColumn?: boolean;\n /** Suppress the label for a unit drawn thinner than this many pixels\n * (default 2) */\n labelSuppressHeight?: number;\n keyboardNavigation?: boolean;\n showLabels?: boolean;\n maxInternalColumns?: number;\n /** Draw the age (or height) axis beside the column (default). Off for a\n * column whose coordinates aren't a measure — one laid out by surface order\n * alone, say. */\n showAgeAxis?: boolean;\n // Timescale properties\n /** Draw the timescale. Defaults to on for an age column; an explicit value\n * wins over `timescaleLevels` / `timescales`, which otherwise turn it on. */\n showTimescale?: boolean;\n timescaleLevels?: number | [number, number];\n /** Regional or project timescales drawn as extra columns beside the\n * international one (see `CompositeTimescale`). Narrow `timescaleLevels` by\n * as many to swap the finest level for them rather than widen the column. */\n additionalTimescales?: number[];\n /** Every timescale to draw beside the column, in order: a Macrostrat\n * timescale ID, or a timescale with its own intervals (see\n * `CompositeTimescale`). Supersedes `timescaleLevels` and\n * `additionalTimescales`. */\n timescales?: ColumnTimescaleLike[];\n /** Draw each timescale's name above it */\n showTimescaleLabels?: boolean;\n /** Called when a timescale interval is clicked (e.g. to zoom the age range).\n * The data says which timescale it was clicked in. */\n onClickTimescaleInterval?: ColumnTimescaleClickHandler;\n /** Per-interval style for the timescale (e.g. to bold the selected\n * interval), by interval and the timescale it was drawn from. */\n timescaleIntervalStyle?: ColumnIntervalStyleBuilder;\n unconformityLabels?: boolean | UnconformityLabelPlacement;\n onMouseOver?: (\n unit: UnitLong | null,\n height: number | null,\n evt: MouseEvent,\n ) => void;\n}\n\nexport type UnconformityLabelPlacement = \"minimal\" | \"prominent\" | \"none\";\n\nexport interface ColumnProps\n extends Padding, BaseColumnProps, ColumnHeightScaleOptions {\n // Macrostrat units\n units: UnitLong[];\n t_age?: number;\n b_age?: number;\n t_pos?: number;\n b_pos?: number;\n mergeSections?: MergeSectionsMode;\n showUnitPopover?: boolean;\n allowUnitSelection?: boolean;\n selectedUnit?: number | null;\n onUnitSelected?: (unitID: number | null, unit: any) => void;\n // Unconformity height in pixels\n unconformityHeight?: number;\n scale?: ScaleContinuousNumeric<number, number>;\n /** True while the age window is animating (e.g. from `useAnimatedAgeWindow`),\n * so per-frame label/pattern recalculation can be skipped. */\n isTransitioning?: boolean;\n /** Hide unit labels while transitioning (perf escape hatch; default false —\n * labels stay visible through the animation). */\n hideLabelsWhileTransitioning?: boolean;\n ref?: RefObject<ColumnRef>;\n}\n\nexport function Column(props: ColumnProps) {\n const {\n showUnitPopover = false,\n keyboardNavigation = false,\n mergeSections,\n onUnitSelected,\n selectedUnit,\n children,\n units: rawUnits,\n t_age,\n b_age,\n t_pos,\n b_pos,\n unconformityHeight = 30,\n targetUnitHeight = 20,\n sectionOptions,\n pixelScale,\n pixelsPerMyr,\n pixelsPerMeter,\n minPixelScale = 0.2,\n minSectionHeight = 50,\n windowPadding = 0,\n collapseSmallUnconformities = true,\n allowUnitSelection = false,\n hybridScale,\n scale,\n axisType,\n isTransitioning,\n hideLabelsWhileTransitioning,\n ref,\n ...rest\n } = props;\n\n /* `pixelScale` and `targetUnitHeight` are alternatives: a density stated\n * outright takes over from the one a section's units imply, floors and all.\n * That is settled in `prepare-units/density`, so nothing is adjusted here. */\n\n // Handle special cases for hybrid scales (WIP, we need to regularize this)\n let _axisType = axisType ?? ColumnAxisType.AGE;\n let ageAxisComponent = CompositeAgeAxis;\n if (\n hybridScale?.type === HybridScaleType.ApproximateHeight &&\n _axisType != ColumnAxisType.AGE\n ) {\n // Use approximate height axis for non-age columns if a non-age axis type is requested\n ageAxisComponent = ApproximateHeightAxis;\n _axisType = ColumnAxisType.AGE;\n }\n\n const { sections, units, totalHeight } = usePreparedColumnUnits(rawUnits, {\n axisType: _axisType,\n t_age,\n b_age,\n t_pos,\n b_pos,\n mergeSections,\n targetUnitHeight,\n sectionOptions,\n unconformityHeight,\n pixelScale,\n pixelsPerMyr,\n pixelsPerMeter,\n minPixelScale,\n minSectionHeight,\n windowPadding,\n collapseSmallUnconformities,\n // TODO: consider unifying scale and hybridScale options\n scale,\n hybridScale,\n });\n\n if (sections.length === 0) {\n return h(\n \"div.column-container.empty\",\n h(NonIdealState, {\n title: \"Empty column\",\n description: \"No sections found in this column.\",\n icon: \"warning-sign\",\n }),\n );\n }\n\n return h(\n MacrostratColumnDataProvider,\n {\n units,\n sections,\n totalHeight,\n axisType: _axisType,\n allowUnitSelection: showUnitPopover || allowUnitSelection,\n onUnitSelected,\n selectedUnit,\n isTransitioning,\n hideLabelsWhileTransitioning,\n ref,\n },\n h(ColumnInner, { ageAxisComponent, ...rest }, [\n children,\n h.if(showUnitPopover)(UnitSelectionPopover),\n h.if(keyboardNavigation)(UnitKeyboardNavigation, { units }),\n ]),\n );\n}\n\ninterface ColumnInnerProps extends BaseColumnProps {\n ageAxisComponent?: ComponentType;\n}\n\nfunction ColumnInner(props: ColumnInnerProps) {\n const padding = extractPadding(props);\n\n // TODO: integrate padding vars more closely with the rest of the spacing (right now padding is a bit ad-hoc)\n const paddingVars: any = {\n \"--column-padding-top\": `${padding.paddingTop}px`,\n \"--column-padding-bottom\": `${padding.paddingBottom}px`,\n \"--column-padding-left\": `${padding.paddingLeft}px`,\n \"--column-padding-right\": `${padding.paddingRight}px`,\n };\n\n const {\n unitComponent = UnitComponent,\n unconformityLabels = \"minimal\",\n showLabels = true,\n width: _width = 300,\n columnWidth: _columnWidth = 150,\n showLabelColumn: _showLabelColumn = true,\n labelSuppressHeight,\n className,\n clipUnits = false,\n children,\n showTimescale,\n timescaleLevels,\n additionalTimescales,\n timescales,\n showTimescaleLabels,\n maxInternalColumns,\n onMouseOver,\n onClickTimescaleInterval,\n timescaleIntervalStyle,\n ageAxisComponent = CompositeAgeAxis,\n showAgeAxis = true,\n } = props;\n\n const { axisType } = useMacrostratColumnData();\n\n const columnRef = useColumnRef();\n\n // Coalesce unconformity label setting to a boolean\n let _timescaleUnconformityLabels = false;\n let _sectionUnconformityLabels = false;\n if (unconformityLabels === true || unconformityLabels === \"prominent\") {\n _sectionUnconformityLabels = true;\n } else if (unconformityLabels === \"minimal\") {\n _timescaleUnconformityLabels = true;\n }\n\n let width = _width;\n let columnWidth = _columnWidth;\n if (columnWidth > width) {\n columnWidth = width;\n }\n let showLabelColumn = _showLabelColumn;\n if (columnWidth > width - 10) {\n showLabelColumn = false;\n }\n\n // On unless turned off outright: passing levels or timescales no longer\n // overrides an explicit `false`\n const _showTimescale =\n axisType == ColumnAxisType.AGE && (showTimescale ?? true);\n\n return h(\n ColumnContainer,\n {\n ...useMouseEventHandlers(onMouseOver),\n style: paddingVars,\n className,\n },\n h(\"div.column\", { ref: columnRef }, [\n h.if(showAgeAxis)(ageAxisComponent),\n h.if(_showTimescale)(CompositeTimescale, {\n levels: timescaleLevels,\n additionalTimescales,\n timescales,\n showLabels: showTimescaleLabels,\n unconformityLabels: _timescaleUnconformityLabels,\n onClickInterval: onClickTimescaleInterval,\n intervalStyle: timescaleIntervalStyle,\n }),\n h(SectionsColumn, {\n unitComponent,\n showLabels,\n width,\n columnWidth,\n showLabelColumn,\n labelSuppressHeight,\n clipUnits,\n unconformityLabels: _sectionUnconformityLabels,\n maxInternalColumns,\n }),\n children,\n ]),\n );\n}\n\ntype ColumnMouseOverHandler = (\n unit: UnitLong | null,\n height: number | null,\n evt: MouseEvent,\n) => void;\n\nfunction useMouseEventHandlers(\n _onMouseOver: ColumnMouseOverHandler | null = null,\n) {\n /** Click event handler */\n\n // Click handler for unit selection\n const dispatch = useUnitSelectionDispatch();\n const onClick = useCallback(\n (evt) => {\n dispatch?.(null, null);\n },\n [dispatch],\n );\n\n /** Hover event handlers */\n const scale = useCompositeScale();\n\n const onMouseOver = useCallback(\n (evt) => {\n const height = scale.invert(\n evt.clientY - evt.currentTarget.getBoundingClientRect().top,\n );\n _onMouseOver?.(null, height, evt);\n },\n [scale, _onMouseOver],\n );\n\n const onMouseOut = useCallback(() => {\n _onMouseOver?.(null, null, null);\n }, [_onMouseOver]);\n\n if (_onMouseOver == null) {\n return {\n onClick,\n onMouseOver: undefined,\n onMouseMove: undefined,\n onMouseOut: undefined,\n };\n }\n\n return { onMouseOver, onMouseMove: onMouseOver, onMouseOut, onClick };\n}\n\nexport interface ColumnContainerProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n style?: CSSProperties;\n}\n\nexport function ColumnContainer(props: ColumnContainerProps) {\n const { className, ...rest } = props;\n const darkMode = useDarkMode();\n\n return h(Box, {\n className: classNames(\n className,\n {\n \"dark-mode\": darkMode?.isEnabled ?? false,\n },\n \"column-container\",\n ),\n ...rest,\n });\n}\n\nexport function ColumnBasicInfo({\n data,\n showColumnID = true,\n showReferences = true,\n}) {\n if (data == null) return null;\n return h(\"div.column-info\", [\n h(\"div.column-title-row\", [\n h(\"h2\", data.col_name),\n h.if(showColumnID)(\"h4\", h(Identifier, { id: data.col_id })),\n ]),\n h(DataField, { row: true, label: \"Group\", value: data.col_group }),\n h.if(showReferences)(ReferencesField, {\n refs: data.refs,\n inline: false,\n row: false,\n className: \"column-refs\",\n }),\n ]);\n}\n"],"names":["ColumnAxisType","CompositeAgeAxis","HybridScaleType","ApproximateHeightAxis","usePreparedColumnUnits","h","NonIdealState","MacrostratColumnDataProvider","UnitSelectionPopover","UnitKeyboardNavigation","extractPadding","UnitComponent","useMacrostratColumnData","useColumnRef","CompositeTimescale","SectionsColumn","useUnitSelectionDispatch","useCallback","useCompositeScale","useDarkMode","Box","classNames","Identifier","DataField","ReferencesField"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+HO,SAAS,OAAO,OAAoB;AACzC,QAAM;AAAA,IACJ,kBAAkB;AAAA,IAClB,qBAAqB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,IACrB,mBAAmB;AAAA,I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AAAA,MACb,aAAa;AAAA,MACb,YAAY;AAAA,IAAA;AAAA,EAEhB;AAEA,SAAO,EAAE,aAAa,aAAa,aAAa,YAAY,QAAA;AAC9D;AAOO,SAAS,gBAAgB,OAA6B;AAC3D,QAAM,EAAE,WAAW,GAAG,KAAA,IAAS;AAC/B,QAAM,WAAWE,aAAAA,YAAA;AAEjB,SAAOd,cAAAA,QAAEe,aAAAA,KAAK;AAAA,IACZ,WAAWC,oBAAAA;AAAAA,MACT;AAAA,MACA;AAAA,QACE,aAAa,UAAU,aAAa;AAAA,MAAA;AAAA,MAEtC;AAAA,IAAA;AAAA,IAEF,GAAG;AAAA,EAAA,CACJ;AACH;AAEO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA,eAAe;AAAA,EACf,iBAAiB;AACnB,GAAG;AACD,MAAI,QAAQ,KAAM,QAAO;AACzB,SAAOhB,cAAAA,QAAE,mBAAmB;AAAA,IAC1BA,cAAAA,QAAE,wBAAwB;AAAA,MACxBA,sBAAE,MAAM,KAAK,QAAQ;AAAA,MACrBA,cAAAA,QAAE,GAAG,YAAY,EAAE,MAAMA,cAAAA,QAAEiB,eAAAA,YAAY,EAAE,IAAI,KAAK,QAAQ,CAAC;AAAA,IAAA,CAC5D;AAAA,IACDjB,sBAAEkB,eAAAA,WAAW,EAAE,KAAK,MAAM,OAAO,SAAS,OAAO,KAAK,WAAW;AAAA,IACjElB,cAAAA,QAAE,GAAG,cAAc,EAAEmB,uBAAiB;AAAA,MACpC,MAAM,KAAK;AAAA,MACX,QAAQ;AAAA,MACR,KAAK;AAAA,MACL,WAAW;AAAA,IAAA,CACZ;AAAA,EAAA,CACF;AACH;;;;"}
|
package/dist/column.d.ts
CHANGED
|
@@ -14,6 +14,12 @@ interface BaseColumnProps extends Omit<SectionSharedProps, "unconformityLabels">
|
|
|
14
14
|
keyboardNavigation?: boolean;
|
|
15
15
|
showLabels?: boolean;
|
|
16
16
|
maxInternalColumns?: number;
|
|
17
|
+
/** Draw the age (or height) axis beside the column (default). Off for a
|
|
18
|
+
* column whose coordinates aren't a measure — one laid out by surface order
|
|
19
|
+
* alone, say. */
|
|
20
|
+
showAgeAxis?: boolean;
|
|
21
|
+
/** Draw the timescale. Defaults to on for an age column; an explicit value
|
|
22
|
+
* wins over `timescaleLevels` / `timescales`, which otherwise turn it on. */
|
|
17
23
|
showTimescale?: boolean;
|
|
18
24
|
timescaleLevels?: number | [number, number];
|
|
19
25
|
/** Regional or project timescales drawn as extra columns beside the
|
package/dist/column.js
CHANGED
|
@@ -10,7 +10,7 @@ import { usePreparedColumnUnits } from "./prepare-units/index.js";
|
|
|
10
10
|
import { NonIdealState } from "@blueprintjs/core";
|
|
11
11
|
import { Identifier, DataField } from "@macrostrat/data-components";
|
|
12
12
|
import { HybridScaleType } from "./prepare-units/types.js";
|
|
13
|
-
import { MacrostratColumnDataProvider, useMacrostratColumnData,
|
|
13
|
+
import { MacrostratColumnDataProvider, useMacrostratColumnData, useCompositeScale } from "./data-provider/store.js";
|
|
14
14
|
import { UnitSelectionPopover } from "./unit-details/popover.js";
|
|
15
15
|
import { UnitKeyboardNavigation, useColumnRef, useUnitSelectionDispatch } from "./data-provider/unit-selection.js";
|
|
16
16
|
import { ReferencesField } from "./unit-details/panel.js";
|
|
@@ -52,16 +52,6 @@ function Column(props) {
|
|
|
52
52
|
ageAxisComponent = ApproximateHeightAxis;
|
|
53
53
|
_axisType = ColumnAxisType.AGE;
|
|
54
54
|
}
|
|
55
|
-
let _sectionOptions = sectionOptions;
|
|
56
|
-
if (_sectionOptions == void 0) {
|
|
57
|
-
_sectionOptions = (ctx) => {
|
|
58
|
-
const n = ctx.units.length;
|
|
59
|
-
const expansionFactor = 8 / Math.min(Math.max(n, 1), 8);
|
|
60
|
-
return {
|
|
61
|
-
targetUnitHeight: targetUnitHeight * expansionFactor
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
55
|
const { sections, units, totalHeight } = usePreparedColumnUnits(rawUnits, {
|
|
66
56
|
axisType: _axisType,
|
|
67
57
|
t_age,
|
|
@@ -70,7 +60,7 @@ function Column(props) {
|
|
|
70
60
|
b_pos,
|
|
71
61
|
mergeSections,
|
|
72
62
|
targetUnitHeight,
|
|
73
|
-
sectionOptions
|
|
63
|
+
sectionOptions,
|
|
74
64
|
unconformityHeight,
|
|
75
65
|
pixelScale,
|
|
76
66
|
pixelsPerMyr,
|
|
@@ -142,10 +132,10 @@ function ColumnInner(props) {
|
|
|
142
132
|
onMouseOver,
|
|
143
133
|
onClickTimescaleInterval,
|
|
144
134
|
timescaleIntervalStyle,
|
|
145
|
-
ageAxisComponent = CompositeAgeAxis
|
|
135
|
+
ageAxisComponent = CompositeAgeAxis,
|
|
136
|
+
showAgeAxis = true
|
|
146
137
|
} = props;
|
|
147
138
|
const { axisType } = useMacrostratColumnData();
|
|
148
|
-
const labelColumnClaimed = useLabelColumnClaimed();
|
|
149
139
|
const columnRef = useColumnRef();
|
|
150
140
|
let _timescaleUnconformityLabels = false;
|
|
151
141
|
let _sectionUnconformityLabels = false;
|
|
@@ -160,14 +150,10 @@ function ColumnInner(props) {
|
|
|
160
150
|
columnWidth = width;
|
|
161
151
|
}
|
|
162
152
|
let showLabelColumn = _showLabelColumn;
|
|
163
|
-
if (columnWidth > width - 10
|
|
153
|
+
if (columnWidth > width - 10) {
|
|
164
154
|
showLabelColumn = false;
|
|
165
155
|
}
|
|
166
|
-
|
|
167
|
-
if (timescaleLevels != null || timescales != null) {
|
|
168
|
-
_showTimescale = true;
|
|
169
|
-
}
|
|
170
|
-
_showTimescale = axisType == ColumnAxisType.AGE && _showTimescale;
|
|
156
|
+
const _showTimescale = axisType == ColumnAxisType.AGE && (showTimescale ?? true);
|
|
171
157
|
return h(
|
|
172
158
|
ColumnContainer,
|
|
173
159
|
{
|
|
@@ -176,7 +162,7 @@ function ColumnInner(props) {
|
|
|
176
162
|
className
|
|
177
163
|
},
|
|
178
164
|
h("div.column", { ref: columnRef }, [
|
|
179
|
-
h(ageAxisComponent),
|
|
165
|
+
h.if(showAgeAxis)(ageAxisComponent),
|
|
180
166
|
h.if(_showTimescale)(CompositeTimescale, {
|
|
181
167
|
levels: timescaleLevels,
|
|
182
168
|
additionalTimescales,
|