@macrostrat/column-views 3.11.0 → 3.12.1

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.
Files changed (138) hide show
  1. package/CHANGELOG.md +184 -0
  2. package/dist/age-axis.cjs +1 -2
  3. package/dist/age-axis.cjs.map +1 -1
  4. package/dist/age-axis.js +1 -2
  5. package/dist/age-axis.js.map +1 -1
  6. package/dist/age-model/data.cjs +57 -0
  7. package/dist/age-model/data.cjs.map +1 -0
  8. package/dist/age-model/data.d.ts +29 -0
  9. package/dist/age-model/data.js +57 -0
  10. package/dist/age-model/data.js.map +1 -0
  11. package/dist/age-model/details.cjs +260 -0
  12. package/dist/age-model/details.cjs.map +1 -0
  13. package/dist/age-model/details.d.ts +39 -0
  14. package/dist/age-model/details.js +257 -0
  15. package/dist/age-model/details.js.map +1 -0
  16. package/dist/age-model/details.module.sass.cjs +42 -0
  17. package/dist/age-model/details.module.sass.cjs.map +1 -0
  18. package/dist/age-model/details.module.sass.js +40 -0
  19. package/dist/age-model/details.module.sass.js.map +1 -0
  20. package/dist/age-model/index.d.ts +5 -0
  21. package/dist/age-model/legacy.cjs +28 -0
  22. package/dist/age-model/legacy.cjs.map +1 -0
  23. package/dist/age-model/legacy.d.ts +6 -0
  24. package/dist/age-model/legacy.js +26 -0
  25. package/dist/age-model/legacy.js.map +1 -0
  26. package/dist/age-model/surfaces.cjs +354 -0
  27. package/dist/age-model/surfaces.cjs.map +1 -0
  28. package/dist/age-model/surfaces.d.ts +68 -0
  29. package/dist/age-model/surfaces.js +351 -0
  30. package/dist/age-model/surfaces.js.map +1 -0
  31. package/dist/age-model/surfaces.module.sass.cjs +45 -0
  32. package/dist/age-model/surfaces.module.sass.cjs.map +1 -0
  33. package/dist/age-model/surfaces.module.sass.js +43 -0
  34. package/dist/age-model/surfaces.module.sass.js.map +1 -0
  35. package/dist/age-model/types.cjs +229 -0
  36. package/dist/age-model/types.cjs.map +1 -0
  37. package/dist/age-model/types.d.ts +112 -0
  38. package/dist/age-model/types.js +229 -0
  39. package/dist/age-model/types.js.map +1 -0
  40. package/dist/column-views.css +406 -74
  41. package/dist/column.cjs +20 -13
  42. package/dist/column.cjs.map +1 -1
  43. package/dist/column.d.ts +21 -6
  44. package/dist/column.js +21 -14
  45. package/dist/column.js.map +1 -1
  46. package/dist/column.module.sass.cjs +19 -15
  47. package/dist/column.module.sass.cjs.map +1 -1
  48. package/dist/column.module.sass.js +19 -15
  49. package/dist/column.module.sass.js.map +1 -1
  50. package/dist/data-provider/store.cjs +34 -1
  51. package/dist/data-provider/store.cjs.map +1 -1
  52. package/dist/data-provider/store.d.ts +5 -0
  53. package/dist/data-provider/store.js +35 -2
  54. package/dist/data-provider/store.js.map +1 -1
  55. package/dist/index.cjs +78 -18
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.d.ts +3 -1
  58. package/dist/index.js +55 -4
  59. package/dist/index.js.map +1 -1
  60. package/dist/notes.cjs +11 -2
  61. package/dist/notes.cjs.map +1 -1
  62. package/dist/notes.d.ts +11 -1
  63. package/dist/notes.js +11 -2
  64. package/dist/notes.js.map +1 -1
  65. package/dist/prepare-units/composite-scale.cjs +18 -16
  66. package/dist/prepare-units/composite-scale.cjs.map +1 -1
  67. package/dist/prepare-units/composite-scale.js +18 -16
  68. package/dist/prepare-units/composite-scale.js.map +1 -1
  69. package/dist/prepare-units/density.cjs +83 -0
  70. package/dist/prepare-units/density.cjs.map +1 -0
  71. package/dist/prepare-units/density.d.ts +92 -0
  72. package/dist/prepare-units/density.js +83 -0
  73. package/dist/prepare-units/density.js.map +1 -0
  74. package/dist/prepare-units/index.cjs +15 -7
  75. package/dist/prepare-units/index.cjs.map +1 -1
  76. package/dist/prepare-units/index.d.ts +1 -0
  77. package/dist/prepare-units/index.js +15 -7
  78. package/dist/prepare-units/index.js.map +1 -1
  79. package/dist/prepare-units/types.cjs.map +1 -1
  80. package/dist/prepare-units/types.d.ts +34 -13
  81. package/dist/prepare-units/types.js.map +1 -1
  82. package/dist/section.cjs +108 -24
  83. package/dist/section.cjs.map +1 -1
  84. package/dist/section.d.ts +66 -6
  85. package/dist/section.js +109 -25
  86. package/dist/section.js.map +1 -1
  87. package/dist/timescale-zoom.cjs +191 -0
  88. package/dist/timescale-zoom.cjs.map +1 -0
  89. package/dist/timescale-zoom.d.ts +74 -0
  90. package/dist/timescale-zoom.js +191 -0
  91. package/dist/timescale-zoom.js.map +1 -0
  92. package/dist/unit-details/age-range.cjs +14 -43
  93. package/dist/unit-details/age-range.cjs.map +1 -1
  94. package/dist/unit-details/age-range.d.ts +1 -13
  95. package/dist/unit-details/age-range.js +6 -43
  96. package/dist/unit-details/age-range.js.map +1 -1
  97. package/dist/unit-details/utils.cjs +0 -5
  98. package/dist/unit-details/utils.cjs.map +1 -1
  99. package/dist/unit-details/utils.js +0 -5
  100. package/dist/unit-details/utils.js.map +1 -1
  101. package/dist/units/composite.cjs +4 -1
  102. package/dist/units/composite.cjs.map +1 -1
  103. package/dist/units/composite.d.ts +2 -0
  104. package/dist/units/composite.js +4 -1
  105. package/dist/units/composite.js.map +1 -1
  106. package/package.json +8 -8
  107. package/src/age-model/data.ts +98 -0
  108. package/src/age-model/details.module.sass +108 -0
  109. package/src/age-model/details.ts +333 -0
  110. package/src/age-model/index.ts +5 -0
  111. package/src/age-model/legacy.ts +30 -0
  112. package/src/age-model/surfaces.module.sass +168 -0
  113. package/src/age-model/surfaces.ts +568 -0
  114. package/src/age-model/types.ts +392 -0
  115. package/src/column.module.sass +59 -8
  116. package/src/column.ts +49 -23
  117. package/src/data-provider/store.ts +50 -1
  118. package/src/index.ts +5 -1
  119. package/src/notes.ts +20 -2
  120. package/src/prepare-units/composite-scale.ts +34 -31
  121. package/src/prepare-units/density.ts +197 -0
  122. package/src/prepare-units/index.ts +25 -6
  123. package/src/prepare-units/types.ts +34 -13
  124. package/src/section.ts +219 -33
  125. package/src/timescale-zoom.ts +341 -0
  126. package/src/unit-details/age-range.ts +12 -58
  127. package/src/units/composite.ts +11 -0
  128. package/dist/age-model-overlay.cjs +0 -50
  129. package/dist/age-model-overlay.cjs.map +0 -1
  130. package/dist/age-model-overlay.d.ts +0 -24
  131. package/dist/age-model-overlay.js +0 -48
  132. package/dist/age-model-overlay.js.map +0 -1
  133. package/dist/age-model-overlay.module.sass.cjs +0 -12
  134. package/dist/age-model-overlay.module.sass.cjs.map +0 -1
  135. package/dist/age-model-overlay.module.sass.js +0 -11
  136. package/dist/age-model-overlay.module.sass.js.map +0 -1
  137. package/src/age-model-overlay.module.sass +0 -11
  138. package/src/age-model-overlay.ts +0 -96
@@ -0,0 +1,40 @@
1
+ import h$1 from "@macrostrat/hyper";
2
+ const spacer = "_spacer_14xjd_16";
3
+ const placeholder = "_placeholder_14xjd_38";
4
+ const inferred = "_inferred_14xjd_55";
5
+ const styles = {
6
+ "surface-details-panel": "_surface-details-panel_14xjd_1",
7
+ "surface-details-header": "_surface-details-header_14xjd_7",
8
+ spacer,
9
+ "surface-details-title": "_surface-details-title_14xjd_20",
10
+ "surface-id": "_surface-id_14xjd_24",
11
+ "surface-details-tags": "_surface-details-tags_14xjd_29",
12
+ "surface-details-content": "_surface-details-content_14xjd_34",
13
+ "no-surface": "_no-surface_14xjd_38",
14
+ placeholder,
15
+ "surface-tag": "_surface-tag_14xjd_43",
16
+ "surface-type-tag": "_surface-type-tag_14xjd_52",
17
+ inferred,
18
+ "inferred-marker": "_inferred-marker_14xjd_59",
19
+ "calibration-interval": "_calibration-interval_14xjd_64",
20
+ "calibration-range": "_calibration-range_14xjd_71",
21
+ "calibration-proportion": "_calibration-proportion_14xjd_76",
22
+ "surface-units-list": "_surface-units-list_14xjd_80",
23
+ "no-units": "_no-units_14xjd_95",
24
+ "no-calibration": "_no-calibration_14xjd_95",
25
+ "surface-status-legend": "_surface-status-legend_14xjd_99",
26
+ "with-descriptions": "_with-descriptions_14xjd_108",
27
+ "legend-item": "_legend-item_14xjd_112",
28
+ "surface-label-marker": "_surface-label-marker_14xjd_118",
29
+ "legend-label": "_legend-label_14xjd_124",
30
+ "legend-description": "_legend-description_14xjd_128"
31
+ };
32
+ let h = h$1.styled(styles);
33
+ Object.assign(h, styles);
34
+ export {
35
+ h as default,
36
+ inferred,
37
+ placeholder,
38
+ spacer
39
+ };
40
+ //# sourceMappingURL=details.module.sass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"details.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,5 @@
1
+ export * from './types';
2
+ export * from './data';
3
+ export * from './surfaces';
4
+ export * from './details';
5
+ export * from './legacy';
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const h = require("@macrostrat/hyper");
4
+ const React = require("react");
5
+ const surfaces = require("./surfaces.cjs");
6
+ const types = require("./types.cjs");
7
+ const store = require("../data-provider/store.cjs");
8
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
9
+ const h__default = /* @__PURE__ */ _interopDefault(h);
10
+ function BoundaryAgeModelOverlay() {
11
+ return h__default.default(surfaces.ColumnSurfaces, {
12
+ showLabels: false,
13
+ extent: "column",
14
+ fallbackToUnits: false
15
+ });
16
+ }
17
+ function ComputedSurfacesOverlay() {
18
+ const units = store.useMacrostratUnits();
19
+ const { axisType } = store.useMacrostratColumnData();
20
+ const surfaces$1 = React.useMemo(
21
+ () => types.surfacesFromUnits(units, { axisType }),
22
+ [units, axisType]
23
+ );
24
+ return h__default.default(surfaces.ColumnSurfaces, { surfaces: surfaces$1, showLabels: false, extent: "column" });
25
+ }
26
+ exports.BoundaryAgeModelOverlay = BoundaryAgeModelOverlay;
27
+ exports.ComputedSurfacesOverlay = ComputedSurfacesOverlay;
28
+ //# sourceMappingURL=legacy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy.cjs","sources":["../../src/age-model/legacy.ts"],"sourcesContent":["/** Earlier, in-development overlays, kept so existing consumers keep working.\n * Both are now thin wrappers over `ColumnSurfaces`. */\nimport h from \"@macrostrat/hyper\";\nimport { useMemo } from \"react\";\nimport type { UnitLong } from \"@macrostrat/api-types\";\nimport { useMacrostratColumnData, useMacrostratUnits } from \"../data-provider\";\nimport { ColumnSurfaces } from \"./surfaces\";\nimport { surfacesFromUnits } from \"./types\";\n\n/** @deprecated Use `ColumnSurfaces`, which also labels the surfaces and\n * styles them by boundary status. */\nexport function BoundaryAgeModelOverlay() {\n return h(ColumnSurfaces, {\n showLabels: false,\n extent: \"column\",\n fallbackToUnits: false,\n });\n}\n\n/** @deprecated Use `ColumnSurfaces` with `surfaces: surfacesFromUnits(units)`,\n * or rely on its default fallback to unit-derived surfaces. */\nexport function ComputedSurfacesOverlay() {\n const units = useMacrostratUnits() as UnitLong[];\n const { axisType } = useMacrostratColumnData();\n const surfaces = useMemo(\n () => surfacesFromUnits(units, { axisType }),\n [units, axisType],\n );\n return h(ColumnSurfaces, { surfaces, showLabels: false, extent: \"column\" });\n}\n"],"names":["h","ColumnSurfaces","useMacrostratUnits","useMacrostratColumnData","surfaces","useMemo","surfacesFromUnits"],"mappings":";;;;;;;;;AAWO,SAAS,0BAA0B;AACxC,SAAOA,WAAAA,QAAEC,SAAAA,gBAAgB;AAAA,IACvB,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,iBAAiB;AAAA,EAAA,CAClB;AACH;AAIO,SAAS,0BAA0B;AACxC,QAAM,QAAQC,MAAAA,mBAAA;AACd,QAAM,EAAE,SAAA,IAAaC,8BAAA;AACrB,QAAMC,aAAWC,MAAAA;AAAAA,IACf,MAAMC,wBAAkB,OAAO,EAAE,UAAU;AAAA,IAC3C,CAAC,OAAO,QAAQ;AAAA,EAAA;AAElB,SAAON,WAAAA,QAAEC,SAAAA,gBAAgB,YAAEG,YAAU,YAAY,OAAO,QAAQ,UAAU;AAC5E;;;"}
@@ -0,0 +1,6 @@
1
+ /** @deprecated Use `ColumnSurfaces`, which also labels the surfaces and
2
+ * styles them by boundary status. */
3
+ export declare function BoundaryAgeModelOverlay(): import('react').FunctionComponentElement<import('./surfaces').ColumnSurfacesProps>;
4
+ /** @deprecated Use `ColumnSurfaces` with `surfaces: surfacesFromUnits(units)`,
5
+ * or rely on its default fallback to unit-derived surfaces. */
6
+ export declare function ComputedSurfacesOverlay(): import('react').FunctionComponentElement<import('./surfaces').ColumnSurfacesProps>;
@@ -0,0 +1,26 @@
1
+ import h from "@macrostrat/hyper";
2
+ import { useMemo } from "react";
3
+ import { ColumnSurfaces } from "./surfaces.js";
4
+ import { surfacesFromUnits } from "./types.js";
5
+ import { useMacrostratUnits, useMacrostratColumnData } from "../data-provider/store.js";
6
+ function BoundaryAgeModelOverlay() {
7
+ return h(ColumnSurfaces, {
8
+ showLabels: false,
9
+ extent: "column",
10
+ fallbackToUnits: false
11
+ });
12
+ }
13
+ function ComputedSurfacesOverlay() {
14
+ const units = useMacrostratUnits();
15
+ const { axisType } = useMacrostratColumnData();
16
+ const surfaces = useMemo(
17
+ () => surfacesFromUnits(units, { axisType }),
18
+ [units, axisType]
19
+ );
20
+ return h(ColumnSurfaces, { surfaces, showLabels: false, extent: "column" });
21
+ }
22
+ export {
23
+ BoundaryAgeModelOverlay,
24
+ ComputedSurfacesOverlay
25
+ };
26
+ //# sourceMappingURL=legacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy.js","sources":["../../src/age-model/legacy.ts"],"sourcesContent":["/** Earlier, in-development overlays, kept so existing consumers keep working.\n * Both are now thin wrappers over `ColumnSurfaces`. */\nimport h from \"@macrostrat/hyper\";\nimport { useMemo } from \"react\";\nimport type { UnitLong } from \"@macrostrat/api-types\";\nimport { useMacrostratColumnData, useMacrostratUnits } from \"../data-provider\";\nimport { ColumnSurfaces } from \"./surfaces\";\nimport { surfacesFromUnits } from \"./types\";\n\n/** @deprecated Use `ColumnSurfaces`, which also labels the surfaces and\n * styles them by boundary status. */\nexport function BoundaryAgeModelOverlay() {\n return h(ColumnSurfaces, {\n showLabels: false,\n extent: \"column\",\n fallbackToUnits: false,\n });\n}\n\n/** @deprecated Use `ColumnSurfaces` with `surfaces: surfacesFromUnits(units)`,\n * or rely on its default fallback to unit-derived surfaces. */\nexport function ComputedSurfacesOverlay() {\n const units = useMacrostratUnits() as UnitLong[];\n const { axisType } = useMacrostratColumnData();\n const surfaces = useMemo(\n () => surfacesFromUnits(units, { axisType }),\n [units, axisType],\n );\n return h(ColumnSurfaces, { surfaces, showLabels: false, extent: \"column\" });\n}\n"],"names":[],"mappings":";;;;;AAWO,SAAS,0BAA0B;AACxC,SAAO,EAAE,gBAAgB;AAAA,IACvB,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,iBAAiB;AAAA,EAAA,CAClB;AACH;AAIO,SAAS,0BAA0B;AACxC,QAAM,QAAQ,mBAAA;AACd,QAAM,EAAE,SAAA,IAAa,wBAAA;AACrB,QAAM,WAAW;AAAA,IACf,MAAM,kBAAkB,OAAO,EAAE,UAAU;AAAA,IAC3C,CAAC,OAAO,QAAQ;AAAA,EAAA;AAElB,SAAO,EAAE,gBAAgB,EAAE,UAAU,YAAY,OAAO,QAAQ,UAAU;AAC5E;"}
@@ -0,0 +1,354 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const h$1 = require("@macrostrat/hyper");
4
+ const classNames = require("classnames");
5
+ const React = require("react");
6
+ const dataComponents = require("@macrostrat/data-components");
7
+ const dataProvider = require("@macrostrat/data-provider");
8
+ const notes = require("../notes.cjs");
9
+ const column_module = require("../column.module.sass.cjs");
10
+ const surfaces_module = require("./surfaces.module.sass.cjs");
11
+ const types = require("./types.cjs");
12
+ const data = require("./data.cjs");
13
+ const store = require("../data-provider/store.cjs");
14
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
15
+ const h__default = /* @__PURE__ */ _interopDefault(h$1);
16
+ const classNames__default = /* @__PURE__ */ _interopDefault(classNames);
17
+ const h = h__default.default.styled(surfaces_module.default);
18
+ function ColumnSurfaces(props) {
19
+ const {
20
+ showLines = true,
21
+ showLabels = true,
22
+ extent = "units",
23
+ labelWidth,
24
+ labelPaddingLeft,
25
+ statuses,
26
+ labelStatuses = types.TIE_POINT_STATUSES,
27
+ minLabelSpacing,
28
+ selectedSurface,
29
+ onSelectSurface,
30
+ className,
31
+ ...dataOptions
32
+ } = props;
33
+ const { surfaces: allSurfaces } = data.useColumnSurfaces(dataOptions);
34
+ const surfaces = React.useMemo(
35
+ () => filterByStatus(allSurfaces, statuses),
36
+ [allSurfaces, statuses]
37
+ );
38
+ const [selectedID, select] = useSurfaceSelection(
39
+ selectedSurface,
40
+ onSelectSurface
41
+ );
42
+ return h([
43
+ h.if(showLines)(ColumnSurfaceLines, {
44
+ surfaces,
45
+ extent,
46
+ selectedSurface: selectedID,
47
+ onSelectSurface: select,
48
+ className
49
+ }),
50
+ h.if(showLabels)(ColumnSurfaceLabels, {
51
+ surfaces,
52
+ labelStatuses,
53
+ minLabelSpacing,
54
+ width: labelWidth,
55
+ paddingLeft: labelPaddingLeft,
56
+ selectedSurface: selectedID,
57
+ onSelectSurface: select,
58
+ className
59
+ })
60
+ ]);
61
+ }
62
+ function ColumnSurfaceLines(props) {
63
+ const {
64
+ surfaces,
65
+ extent = "units",
66
+ selectedSurface,
67
+ onSelectSurface,
68
+ className
69
+ } = props;
70
+ const scale = store.useCompositeScale();
71
+ const { axisType, totalHeight } = store.useMacrostratColumnData();
72
+ const intervalMap = useSurfaceIntervalDefs(surfaces);
73
+ const ref = React.useRef(null);
74
+ const unitsExtent = useUnitsColumnExtent(ref, extent === "units");
75
+ let style = { height: totalHeight };
76
+ if (unitsExtent != null) {
77
+ style = { ...style, left: unitsExtent.left, width: unitsExtent.width };
78
+ }
79
+ const measuring = extent === "units" && unitsExtent == null;
80
+ return h(
81
+ "div.column-surface-lines",
82
+ { ref, style, className: classNames__default.default(className, { measuring }) },
83
+ surfaces.map((surface) => {
84
+ const position = types.surfacePosition(surface, axisType);
85
+ if (position == null) return null;
86
+ const y = scale(position);
87
+ if (y == null) return null;
88
+ return h(SurfaceLine, {
89
+ key: surface.id,
90
+ surface,
91
+ y,
92
+ color: surfaceIntervalColor(surface, intervalMap),
93
+ selected: surface.id === selectedSurface,
94
+ onSelect: onSelectSurface
95
+ });
96
+ })
97
+ );
98
+ }
99
+ function SurfaceLine({
100
+ surface,
101
+ y,
102
+ color,
103
+ selected,
104
+ onSelect
105
+ }) {
106
+ const onClick = React.useCallback(
107
+ (evt) => {
108
+ evt.stopPropagation();
109
+ if (selected) {
110
+ onSelect?.(null);
111
+ } else {
112
+ onSelect?.(surface);
113
+ }
114
+ },
115
+ [surface, selected, onSelect]
116
+ );
117
+ let style = { top: y };
118
+ if (color != null) {
119
+ style = { ...style, "--surface-color": color };
120
+ }
121
+ return h(
122
+ "div.surface-line",
123
+ {
124
+ style,
125
+ className: classNames__default.default(surfaceClasses(surface), {
126
+ selected,
127
+ interactive: onSelect != null
128
+ }),
129
+ title: types.surfaceLabel(surface),
130
+ onClick
131
+ },
132
+ h("div.surface-line-inner")
133
+ );
134
+ }
135
+ function ColumnSurfaceLabels(props) {
136
+ const {
137
+ surfaces,
138
+ labelStatuses = types.TIE_POINT_STATUSES,
139
+ minLabelSpacing = 22,
140
+ width = 200,
141
+ paddingLeft = 24,
142
+ selectedSurface,
143
+ onSelectSurface,
144
+ className
145
+ } = props;
146
+ const { axisType } = store.useMacrostratColumnData();
147
+ const scale = store.useCompositeScale();
148
+ const intervalMap = useSurfaceIntervalDefs(surfaces);
149
+ store.useClaimLabelColumn();
150
+ const labeled = React.useMemo(() => {
151
+ const byStatus = filterByStatus(surfaces, labelStatuses);
152
+ return thinByPixelSpacing(
153
+ byStatus,
154
+ (s) => scale(types.surfacePosition(s, axisType) ?? NaN),
155
+ minLabelSpacing,
156
+ selectedSurface
157
+ );
158
+ }, [
159
+ surfaces,
160
+ labelStatuses,
161
+ minLabelSpacing,
162
+ selectedSurface,
163
+ scale,
164
+ axisType
165
+ ]);
166
+ const notes$1 = React.useMemo(() => {
167
+ const _notes = [];
168
+ for (const surface of labeled) {
169
+ const position = types.surfacePosition(surface, axisType);
170
+ if (position == null) continue;
171
+ _notes.push({
172
+ id: surface.id,
173
+ height: position,
174
+ note: types.surfaceLabel(surface),
175
+ // The note's color reaches its connector, so a label's leader line
176
+ // matches the surface line it points at
177
+ color: surfaceIntervalColor(surface, intervalMap) ?? void 0,
178
+ surface,
179
+ interval: calibrationInterval(surface, intervalMap),
180
+ selected: surface.id === selectedSurface
181
+ });
182
+ }
183
+ return _notes;
184
+ }, [labeled, axisType, selectedSurface, intervalMap]);
185
+ const onClickNote = React.useCallback(
186
+ (note) => {
187
+ const { surface, selected } = note;
188
+ if (selected) {
189
+ onSelectSurface?.(null);
190
+ } else {
191
+ onSelectSurface?.(surface);
192
+ }
193
+ },
194
+ [onSelectSurface]
195
+ );
196
+ return h(
197
+ "div.column-surface-labels",
198
+ { className },
199
+ h(notes.ColumnNotes, {
200
+ notes: notes$1,
201
+ width,
202
+ paddingLeft,
203
+ noteComponent: SurfaceNoteLabel,
204
+ onClickNote,
205
+ forceOptions: LABEL_FORCE_OPTIONS,
206
+ // The leader runs from the surface line in the column to the tag body,
207
+ // continuing a little past both ends rather than stopping in the gap —
208
+ // so it needs no endpoint marker of its own
209
+ connectorOverhang: LABEL_CONNECTOR_OVERHANG,
210
+ showPointMarker: false
211
+ })
212
+ );
213
+ }
214
+ const LABEL_FORCE_OPTIONS = { nodeSpacing: 2 };
215
+ const LABEL_CONNECTOR_OVERHANG = [8, 6];
216
+ function SurfaceNoteLabel({ note }) {
217
+ const { surface, interval, selected } = note;
218
+ let primary;
219
+ if (interval != null) {
220
+ primary = h(dataComponents.IntervalTag, {
221
+ interval,
222
+ size: dataComponents.TagSize.Small,
223
+ proportion: surface.proportion,
224
+ className: "surface-interval-tag"
225
+ });
226
+ } else {
227
+ primary = h(
228
+ "span.surface-label-status",
229
+ `${types.surfaceStatusLabels[surface.status]} surface`
230
+ );
231
+ }
232
+ return h(
233
+ "div.surface-label",
234
+ { className: classNames__default.default(surfaceClasses(surface), { selected }) },
235
+ h("div.surface-label-primary", primary)
236
+ );
237
+ }
238
+ function useSurfaceIntervalDefs(surfaces) {
239
+ const intervalIDs = React.useMemo(() => {
240
+ const ids = /* @__PURE__ */ new Set();
241
+ for (const surface of surfaces) {
242
+ if (surface.calibration != null) ids.add(surface.calibration.id);
243
+ }
244
+ return Array.from(ids);
245
+ }, [surfaces]);
246
+ return dataProvider.useMacrostratDefs("intervals", intervalIDs, null);
247
+ }
248
+ function surfaceIntervalColor(surface, intervalMap) {
249
+ const id = surface.calibration?.id;
250
+ if (id == null) return null;
251
+ return intervalMap?.get(id)?.color ?? null;
252
+ }
253
+ function calibrationInterval(surface, intervalMap) {
254
+ const { calibration } = surface;
255
+ if (calibration == null) return null;
256
+ const def = intervalMap?.get(calibration.id);
257
+ return {
258
+ id: calibration.id,
259
+ name: calibration.name,
260
+ b_age: calibration.b_age,
261
+ t_age: calibration.t_age,
262
+ color: def?.color,
263
+ rank: def?.rank
264
+ };
265
+ }
266
+ function surfaceClasses(surface) {
267
+ return classNames__default.default(
268
+ `status-${types.surfaceToken(surface.status)}`,
269
+ `type-${types.surfaceToken(surface.type)}`
270
+ );
271
+ }
272
+ function thinByPixelSpacing(surfaces, pixelPosition, minSpacing, selectedSurface) {
273
+ if (minSpacing <= 0) return surfaces;
274
+ const positioned = surfaces.map((surface) => ({ surface, y: pixelPosition(surface) })).filter((d) => d.y != null && !Number.isNaN(d.y)).sort((a, b) => a.y - b.y);
275
+ const kept = [];
276
+ for (const item of positioned) {
277
+ const selected = item.surface.id === selectedSurface;
278
+ const last = kept[kept.length - 1];
279
+ if (last == null || item.y - last.y >= minSpacing) {
280
+ kept.push(item);
281
+ } else if (selected) {
282
+ kept[kept.length - 1] = item;
283
+ }
284
+ }
285
+ return kept.map((d) => d.surface);
286
+ }
287
+ function filterByStatus(surfaces, statuses) {
288
+ if (statuses == null) return surfaces;
289
+ const allowed = new Set(statuses);
290
+ return surfaces.filter((d) => allowed.has(d.status));
291
+ }
292
+ function useSurfaceSelection(selectedID, onSelect) {
293
+ const [internal, setInternal] = React.useState(null);
294
+ const isControlled = selectedID !== void 0;
295
+ const select = React.useCallback(
296
+ (surface) => {
297
+ setInternal(surface?.id ?? null);
298
+ onSelect?.(surface);
299
+ },
300
+ [onSelect]
301
+ );
302
+ let current = internal;
303
+ if (isControlled) {
304
+ current = selectedID;
305
+ }
306
+ return [current, select];
307
+ }
308
+ const useMeasureEffect = typeof window === "undefined" ? React.useEffect : React.useLayoutEffect;
309
+ function useUnitsColumnExtent(ref, enabled) {
310
+ const [extent, setExtent] = React.useState(null);
311
+ const measure = React.useCallback(() => {
312
+ if (!enabled) return;
313
+ const parent = ref.current?.parentElement;
314
+ const target = parent?.querySelector(
315
+ `.${unitsContainerClass()}`
316
+ );
317
+ if (parent == null || target == null) return;
318
+ const p = parent.getBoundingClientRect();
319
+ const t = target.getBoundingClientRect();
320
+ const next = { left: t.left - p.left, width: t.width };
321
+ setExtent((prev) => {
322
+ if (prev?.left === next.left && prev?.width === next.width) {
323
+ return prev;
324
+ }
325
+ return next;
326
+ });
327
+ }, [enabled]);
328
+ useMeasureEffect(measure);
329
+ useMeasureEffect(() => {
330
+ if (!enabled) {
331
+ setExtent(null);
332
+ return;
333
+ }
334
+ const parent = ref.current?.parentElement;
335
+ if (parent == null) return;
336
+ if (typeof ResizeObserver === "undefined") return;
337
+ const observer = new ResizeObserver(measure);
338
+ observer.observe(parent);
339
+ for (const child of Array.from(parent.children)) {
340
+ observer.observe(child);
341
+ }
342
+ return () => observer.disconnect();
343
+ }, [enabled, measure]);
344
+ return extent;
345
+ }
346
+ function unitsContainerClass() {
347
+ const s = column_module.default;
348
+ return s["section-units-container"] ?? s.sectionUnitsContainer ?? "section-units-container";
349
+ }
350
+ exports.ColumnSurfaceLabels = ColumnSurfaceLabels;
351
+ exports.ColumnSurfaceLines = ColumnSurfaceLines;
352
+ exports.ColumnSurfaces = ColumnSurfaces;
353
+ exports.surfaceClasses = surfaceClasses;
354
+ //# sourceMappingURL=surfaces.cjs.map
@@ -0,0 +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,SAAS,EAAE,oBAAoB;AAAA,MAClC;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-0,0 +1,68 @@
1
+ import { CSSProperties, RefObject } from 'react';
2
+ import { ColumnSurface, SurfaceStatus } from './types';
3
+ import { UseColumnSurfacesOptions } from './data';
4
+ /** How far the surface lines extend: across the units column only, or the
5
+ * full width of the column including its axes. */
6
+ export type SurfaceLinesExtent = "units" | "column";
7
+ export type SurfaceSelectionHandler = (surface: ColumnSurface | null) => void;
8
+ export interface SurfaceSelectionProps {
9
+ /** The selected surface's id. Pass `null` for a controlled, empty
10
+ * selection; leave undefined for the component to manage selection. */
11
+ selectedSurface?: ColumnSurface["id"] | null;
12
+ onSelectSurface?: SurfaceSelectionHandler;
13
+ }
14
+ export interface ColumnSurfacesProps extends UseColumnSurfacesOptions, SurfaceSelectionProps {
15
+ showLines?: boolean;
16
+ showLabels?: boolean;
17
+ extent?: SurfaceLinesExtent;
18
+ /** Width of the labels column, connector included (default 200) */
19
+ labelWidth?: number;
20
+ labelPaddingLeft?: number;
21
+ /** Only show surfaces with these statuses */
22
+ statuses?: SurfaceStatus[] | null;
23
+ /** Which surfaces get a label. Defaults to the tie points — the statuses
24
+ * at which the age model was constrained — so interpolated (`modeled`),
25
+ * unspecified and unit-derived surfaces are drawn as lines only. Pass
26
+ * `null` to label every surface shown. */
27
+ labelStatuses?: SurfaceStatus[] | null;
28
+ /** Labels closer than this (in pixels) are thinned out, since the column
29
+ * has finite room; the selected surface's label is always kept. */
30
+ minLabelSpacing?: number;
31
+ className?: string;
32
+ }
33
+ export declare function ColumnSurfaces(props: ColumnSurfacesProps): import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>>;
34
+ export interface ColumnSurfaceLinesProps extends SurfaceSelectionProps {
35
+ surfaces: ColumnSurface[];
36
+ extent?: SurfaceLinesExtent;
37
+ className?: string;
38
+ }
39
+ /** One horizontal line per surface, overlaid on the column at the surface's
40
+ * age (or measured position, for height and depth columns). */
41
+ export declare function ColumnSurfaceLines(props: ColumnSurfaceLinesProps): import('react').ReactElement<{
42
+ ref: RefObject<HTMLDivElement | null>;
43
+ style: CSSProperties;
44
+ className: string;
45
+ }, string | import('react').JSXElementConstructor<any>>;
46
+ export interface ColumnSurfaceLabelsProps extends SurfaceSelectionProps {
47
+ surfaces: ColumnSurface[];
48
+ /** Which surfaces get a label (see `ColumnSurfacesProps.labelStatuses`) */
49
+ labelStatuses?: SurfaceStatus[] | null;
50
+ /** Minimum pixel spacing between labels (see `ColumnSurfacesProps`) */
51
+ minLabelSpacing?: number;
52
+ /** Total width, connector included */
53
+ width?: number;
54
+ paddingLeft?: number;
55
+ className?: string;
56
+ }
57
+ /** A notes column of surface labels, laid out beside the units with the
58
+ * collision avoidance of `NotesColumn`. It takes the label column over from
59
+ * the unit labels while mounted: labels are one or the other. */
60
+ export declare function ColumnSurfaceLabels(props: ColumnSurfaceLabelsProps): import('react').ReactElement<{
61
+ className: string | undefined;
62
+ }, string | import('react').JSXElementConstructor<any>>;
63
+ /** Class names shared by the lines, labels, legend and tags, so a status or
64
+ * type reads the same everywhere. */
65
+ export declare function surfaceClasses(surface: {
66
+ status?: SurfaceStatus | null;
67
+ type?: string | null;
68
+ }): string;