@macrostrat/column-views 1.0.3 → 2.0.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.
Files changed (242) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/esm/_shared.f7eec55a.js +9 -0
  3. package/dist/esm/_shared.f7eec55a.js.map +1 -0
  4. package/dist/esm/age-axis.4a8cf5e6.js +98 -0
  5. package/dist/esm/age-axis.4a8cf5e6.js.map +1 -0
  6. package/dist/esm/age-axis.module.03773a80.css +33 -0
  7. package/dist/esm/age-axis.module.03773a80.css.map +1 -0
  8. package/dist/esm/age-axis.module.3cc91335.js +22 -0
  9. package/dist/esm/age-axis.module.3cc91335.js.map +1 -0
  10. package/dist/esm/age-model-overlay.c7226855.js +57 -0
  11. package/dist/esm/age-model-overlay.c7226855.js.map +1 -0
  12. package/dist/esm/age-model-overlay.module.5d9e78fb.css +14 -0
  13. package/dist/esm/age-model-overlay.module.5d9e78fb.css.map +1 -0
  14. package/dist/esm/age-model-overlay.module.cd985dcb.js +16 -0
  15. package/dist/esm/age-model-overlay.module.cd985dcb.js.map +1 -0
  16. package/dist/esm/base.910b80b4.js +288 -0
  17. package/dist/esm/base.910b80b4.js.map +1 -0
  18. package/dist/esm/boxes.8292cff2.js +258 -0
  19. package/dist/esm/boxes.8292cff2.js.map +1 -0
  20. package/dist/esm/boxes.module.2b5fb18e.css +26 -0
  21. package/dist/esm/boxes.module.2b5fb18e.css.map +1 -0
  22. package/dist/esm/boxes.module.4ebc7796.js +19 -0
  23. package/dist/esm/boxes.module.4ebc7796.js.map +1 -0
  24. package/dist/esm/{carbon-isotopes.3b502a9e.js → carbon-isotopes.10db8285.js} +2 -2
  25. package/dist/esm/{carbon-isotopes.3b502a9e.js.map → carbon-isotopes.10db8285.js.map} +1 -1
  26. package/dist/esm/colors.395c6db5.js +40 -0
  27. package/dist/esm/colors.395c6db5.js.map +1 -0
  28. package/dist/esm/column-correlation.c8dcfe98.js +9 -0
  29. package/dist/esm/column-correlation.c8dcfe98.js.map +1 -0
  30. package/dist/esm/column-nav.5414677c.js +55 -0
  31. package/dist/esm/column-nav.5414677c.js.map +1 -0
  32. package/dist/esm/column-navigation.37cd3245.js +9 -0
  33. package/dist/esm/column-navigation.37cd3245.js.map +1 -0
  34. package/dist/esm/column.01d68dd8.js +127 -0
  35. package/dist/esm/column.01d68dd8.js.map +1 -0
  36. package/dist/esm/{column.db058031.js → column.a25f8ebd.js} +4 -4
  37. package/dist/esm/column.a25f8ebd.js.map +1 -0
  38. package/dist/esm/column.module.1b776e15.js +46 -0
  39. package/dist/esm/column.module.1b776e15.js.map +1 -0
  40. package/dist/esm/column.module.a67a6b4c.css +159 -0
  41. package/dist/esm/column.module.a67a6b4c.css.map +1 -0
  42. package/dist/esm/composite-scale.577bf64a.js +222 -0
  43. package/dist/esm/composite-scale.577bf64a.js.map +1 -0
  44. package/dist/esm/composite.039e4798.js +163 -0
  45. package/dist/esm/composite.039e4798.js.map +1 -0
  46. package/dist/esm/{core.4db8e452.js → core.843310d3.js} +11 -12
  47. package/dist/esm/core.843310d3.js.map +1 -0
  48. package/dist/esm/core.91ede078.js +206 -0
  49. package/dist/esm/core.91ede078.js.map +1 -0
  50. package/dist/esm/correlation-chart.abd8b346.js +9 -0
  51. package/dist/esm/correlation-chart.abd8b346.js.map +1 -0
  52. package/dist/esm/data-provider.1506eb64.js.map +1 -1
  53. package/dist/esm/data-provider.f10c6d0b.js +13 -0
  54. package/dist/esm/data-provider.f10c6d0b.js.map +1 -0
  55. package/dist/esm/fetch.99aec438.js +152 -0
  56. package/dist/esm/fetch.99aec438.js.map +1 -0
  57. package/dist/esm/hash-string.285b37fb.js +39 -0
  58. package/dist/esm/hash-string.285b37fb.js.map +1 -0
  59. package/dist/esm/helpers.2f0a0cb7.js +141 -0
  60. package/dist/esm/helpers.2f0a0cb7.js.map +1 -0
  61. package/dist/esm/index.d.ts +797 -130
  62. package/dist/esm/index.d.ts.map +1 -1
  63. package/dist/esm/index.js +13 -9
  64. package/dist/esm/index.js.map +1 -1
  65. package/dist/esm/inset-map.3c18106d.js +66 -0
  66. package/dist/esm/inset-map.3c18106d.js.map +1 -0
  67. package/dist/esm/keyboard-navigation.6713401b.js +48 -0
  68. package/dist/esm/keyboard-navigation.6713401b.js.map +1 -0
  69. package/dist/esm/keyboard-navigation.a9fc80dd.js +112 -0
  70. package/dist/esm/keyboard-navigation.a9fc80dd.js.map +1 -0
  71. package/dist/esm/layers.033d3fb0.js +170 -0
  72. package/dist/esm/layers.033d3fb0.js.map +1 -0
  73. package/dist/esm/main.2e0375a5.js +221 -0
  74. package/dist/esm/main.2e0375a5.js.map +1 -0
  75. package/dist/esm/main.module.3dd9500b.css +134 -0
  76. package/dist/esm/main.module.3dd9500b.css.map +1 -0
  77. package/dist/esm/main.module.c09154b1.js +70 -0
  78. package/dist/esm/main.module.c09154b1.js.map +1 -0
  79. package/dist/esm/mapbox.cac42eed.js +167 -0
  80. package/dist/esm/mapbox.cac42eed.js.map +1 -0
  81. package/dist/esm/maps.bcdea9c1.js +11 -0
  82. package/dist/esm/maps.bcdea9c1.js.map +1 -0
  83. package/dist/esm/{names.f6a4e9a4.js → names.a8f2b452.js} +5 -5
  84. package/dist/esm/names.a8f2b452.js.map +1 -0
  85. package/dist/esm/panel.598f76a5.js +420 -0
  86. package/dist/esm/panel.598f76a5.js.map +1 -0
  87. package/dist/esm/panel.module.386166cc.js +58 -0
  88. package/dist/esm/panel.module.386166cc.js.map +1 -0
  89. package/dist/esm/panel.module.3d2ea3c6.css +111 -0
  90. package/dist/esm/panel.module.3d2ea3c6.css.map +1 -0
  91. package/dist/esm/popover.a810b7bc.js +66 -0
  92. package/dist/esm/popover.a810b7bc.js.map +1 -0
  93. package/dist/esm/popover.module.c4ba4189.js +22 -0
  94. package/dist/esm/popover.module.c4ba4189.js.map +1 -0
  95. package/dist/esm/{selection-popover.module.0a701258.css → popover.module.c4d6bfb0.css} +11 -8
  96. package/dist/esm/popover.module.c4d6bfb0.css.map +1 -0
  97. package/dist/esm/prepare-data.d4284b4a.js +125 -0
  98. package/dist/esm/prepare-data.d4284b4a.js.map +1 -0
  99. package/dist/esm/prepare-units.6c890a96.js +104 -0
  100. package/dist/esm/prepare-units.6c890a96.js.map +1 -0
  101. package/dist/esm/{resolvers.b5c82b78.js → resolvers.36013b49.js} +13 -2
  102. package/dist/esm/resolvers.36013b49.js.map +1 -0
  103. package/dist/esm/section.a34d379a.js +215 -0
  104. package/dist/esm/section.a34d379a.js.map +1 -0
  105. package/dist/esm/selection.f5b0297e.js +143 -0
  106. package/dist/esm/selection.f5b0297e.js.map +1 -0
  107. package/dist/esm/state.178ef364.js +75 -0
  108. package/dist/esm/state.178ef364.js.map +1 -0
  109. package/dist/esm/state.2952cbca.js +118 -0
  110. package/dist/esm/state.2952cbca.js.map +1 -0
  111. package/dist/esm/store.c4d7a8a4.js +52 -0
  112. package/dist/esm/store.c4d7a8a4.js.map +1 -0
  113. package/dist/esm/styles.7bc776d1.js +95 -0
  114. package/dist/esm/styles.7bc776d1.js.map +1 -0
  115. package/dist/esm/svg.4b9a96c1.js +89 -0
  116. package/dist/esm/svg.4b9a96c1.js.map +1 -0
  117. package/dist/esm/types.0f0b57c9.js +3 -0
  118. package/dist/esm/types.0f0b57c9.js.map +1 -0
  119. package/dist/esm/unit-details.071cefed.js +9 -0
  120. package/dist/esm/unit-details.071cefed.js.map +1 -0
  121. package/dist/esm/units.5a4fc058.js +98 -0
  122. package/dist/esm/units.5a4fc058.js.map +1 -0
  123. package/dist/esm/utils.d7a43a2a.js +55 -0
  124. package/dist/esm/utils.d7a43a2a.js.map +1 -0
  125. package/dist/node/index.js.map +1 -1
  126. package/package.json +24 -7
  127. package/src/age-axis.module.sass +27 -0
  128. package/src/age-axis.ts +82 -19
  129. package/src/age-model-overlay.module.sass +11 -0
  130. package/src/age-model-overlay.ts +73 -0
  131. package/src/carbon-isotopes/column.ts +4 -2
  132. package/src/carbon-isotopes/core.ts +9 -6
  133. package/src/carbon-isotopes/data-provider.ts +3 -3
  134. package/src/column.module.sass +58 -49
  135. package/src/column.ts +149 -135
  136. package/src/correlation-chart/hash-string.ts +57 -0
  137. package/src/correlation-chart/index.ts +2 -0
  138. package/src/correlation-chart/main.module.sass +122 -0
  139. package/src/correlation-chart/main.ts +305 -0
  140. package/src/correlation-chart/prepare-data.ts +217 -0
  141. package/src/correlation-chart/stories/correlation-chart.stories.ts +192 -0
  142. package/src/correlation-chart/stories/stories.module.sass +18 -0
  143. package/src/correlation-chart/unconformity-line.module.sass +8 -0
  144. package/src/correlation-chart/unconformity-line.ts +25 -0
  145. package/src/data-provider/base.ts +388 -0
  146. package/src/data-provider/column-nav.ts +53 -0
  147. package/src/data-provider/fetch.ts +231 -0
  148. package/src/data-provider/index.ts +4 -0
  149. package/src/data-provider/store.ts +72 -0
  150. package/src/index.ts +5 -3
  151. package/src/maps/_shared/index.ts +2 -0
  152. package/src/maps/_shared/inset-map.stories.ts +20 -0
  153. package/src/maps/_shared/inset-map.ts +87 -0
  154. package/src/maps/_shared/styles.ts +57 -0
  155. package/src/maps/column-correlation/column-correlation-map.stories.ts +96 -0
  156. package/src/maps/column-correlation/core.ts +225 -0
  157. package/src/maps/column-correlation/index.ts +2 -0
  158. package/src/maps/column-correlation/state.ts +192 -0
  159. package/src/maps/column-navigation/index.ts +2 -0
  160. package/src/maps/column-navigation/mapbox/column-navigation-map.stories.ts +102 -0
  161. package/src/maps/column-navigation/mapbox/index.ts +219 -0
  162. package/src/maps/column-navigation/mapbox/keyboard-navigation.ts +119 -0
  163. package/src/maps/column-navigation/mapbox/state.ts +109 -0
  164. package/src/maps/column-navigation/svg/column-navigation-svg-map.stories.ts +46 -0
  165. package/src/{map → maps/column-navigation/svg}/index.ts +18 -6
  166. package/src/{map → maps/column-navigation/svg}/layers.ts +28 -109
  167. package/src/maps/column-navigation/utils/keyboard-navigation.ts +58 -0
  168. package/src/maps/index.ts +3 -0
  169. package/src/prepare-units/composite-scale.ts +353 -0
  170. package/src/prepare-units/helpers.ts +226 -0
  171. package/src/prepare-units/index.ts +177 -0
  172. package/src/prepare-units/utils.ts +98 -0
  173. package/src/section.ts +264 -84
  174. package/src/unit-details/index.ts +2 -215
  175. package/src/unit-details/{index.module.sass → panel.module.sass} +39 -8
  176. package/src/unit-details/panel.ts +523 -0
  177. package/src/{selection-popover.module.sass → unit-details/popover.module.sass} +4 -2
  178. package/src/unit-details/popover.ts +82 -0
  179. package/src/units/boxes.module.sass +16 -0
  180. package/src/units/boxes.ts +243 -90
  181. package/src/units/colors.ts +64 -0
  182. package/src/units/composite.ts +157 -152
  183. package/src/units/index.ts +76 -9
  184. package/src/units/names.ts +8 -4
  185. package/src/units/resolvers.ts +11 -0
  186. package/src/units/selection.ts +115 -101
  187. package/src/units/types.ts +5 -16
  188. package/dist/esm/age-axis.64c509ee.js +0 -41
  189. package/dist/esm/age-axis.64c509ee.js.map +0 -1
  190. package/dist/esm/boxes.13968b76.js +0 -164
  191. package/dist/esm/boxes.13968b76.js.map +0 -1
  192. package/dist/esm/boxes.module.28873d08.css +0 -4
  193. package/dist/esm/boxes.module.28873d08.css.map +0 -1
  194. package/dist/esm/boxes.module.605bdcd6.js +0 -13
  195. package/dist/esm/boxes.module.605bdcd6.js.map +0 -1
  196. package/dist/esm/column.8dd26e1a.js +0 -149
  197. package/dist/esm/column.8dd26e1a.js.map +0 -1
  198. package/dist/esm/column.db058031.js.map +0 -1
  199. package/dist/esm/column.module.039d872c.css +0 -151
  200. package/dist/esm/column.module.039d872c.css.map +0 -1
  201. package/dist/esm/column.module.e632868a.js +0 -19
  202. package/dist/esm/column.module.e632868a.js.map +0 -1
  203. package/dist/esm/composite.608a4ca2.js +0 -153
  204. package/dist/esm/composite.608a4ca2.js.map +0 -1
  205. package/dist/esm/core.4db8e452.js.map +0 -1
  206. package/dist/esm/helpers.8a03cfc7.js +0 -94
  207. package/dist/esm/helpers.8a03cfc7.js.map +0 -1
  208. package/dist/esm/index.module.0844afd8.css +0 -65
  209. package/dist/esm/index.module.0844afd8.css.map +0 -1
  210. package/dist/esm/index.module.24fe3a2e.js +0 -37
  211. package/dist/esm/index.module.24fe3a2e.js.map +0 -1
  212. package/dist/esm/layers.ad5fd25d.js +0 -231
  213. package/dist/esm/layers.ad5fd25d.js.map +0 -1
  214. package/dist/esm/map.7aa26f17.js +0 -82
  215. package/dist/esm/map.7aa26f17.js.map +0 -1
  216. package/dist/esm/names.f6a4e9a4.js.map +0 -1
  217. package/dist/esm/providers.cd1e652f.js +0 -25
  218. package/dist/esm/providers.cd1e652f.js.map +0 -1
  219. package/dist/esm/resolvers.b5c82b78.js.map +0 -1
  220. package/dist/esm/section.cc1b1100.js +0 -118
  221. package/dist/esm/section.cc1b1100.js.map +0 -1
  222. package/dist/esm/selection-popover.17d1bd55.js +0 -60
  223. package/dist/esm/selection-popover.17d1bd55.js.map +0 -1
  224. package/dist/esm/selection-popover.module.0a701258.css.map +0 -1
  225. package/dist/esm/selection-popover.module.e22f5183.js +0 -22
  226. package/dist/esm/selection-popover.module.e22f5183.js.map +0 -1
  227. package/dist/esm/selection.bbf26d0e.js +0 -117
  228. package/dist/esm/selection.bbf26d0e.js.map +0 -1
  229. package/dist/esm/store.25eaa168.js +0 -18
  230. package/dist/esm/store.25eaa168.js.map +0 -1
  231. package/dist/esm/types.f016e032.js +0 -18
  232. package/dist/esm/types.f016e032.js.map +0 -1
  233. package/dist/esm/unit-details.56ff8b70.js +0 -209
  234. package/dist/esm/unit-details.56ff8b70.js.map +0 -1
  235. package/dist/esm/units.361088d4.js +0 -42
  236. package/dist/esm/units.361088d4.js.map +0 -1
  237. package/src/helpers.ts +0 -133
  238. package/src/providers.ts +0 -34
  239. package/src/selection-popover.ts +0 -71
  240. package/src/store.ts +0 -12
  241. package/src/units/units.scss +0 -16
  242. /package/src/{map → maps/column-navigation/svg}/animated.ts +0 -0
package/src/column.ts CHANGED
@@ -1,185 +1,199 @@
1
- import {
2
- ColumnAxisType,
3
- ColumnLayoutContext,
4
- ColumnProvider,
5
- } from "@macrostrat/column-components";
1
+ import { ColumnAxisType } from "@macrostrat/column-components";
6
2
  import { hyperStyled } from "@macrostrat/hyper";
7
3
  import { useDarkMode } from "@macrostrat/ui-components";
8
4
  import classNames from "classnames";
9
- import { createRef, RefObject, useContext, useMemo, useState } from "react";
5
+ import { RefObject, useRef, HTMLAttributes } from "react";
10
6
  import styles from "./column.module.sass";
11
7
  import {
12
- TrackedLabeledUnit,
13
- UnitKeyboardNavigation,
14
8
  UnitSelectionProvider,
9
+ UnitComponent,
10
+ UnitKeyboardNavigation,
15
11
  useUnitSelectionDispatch,
16
12
  } from "./units";
17
- import { SectionInfo } from "./section";
18
- import { RectBounds } from "./units/boxes";
19
- import { UnitSelectionPopover } from "./selection-popover";
20
- import { MacrostratUnitsProvider } from "./store";
21
- import { IColumnProps, Section } from "./section";
13
+
14
+ import { ColumnHeightScaleOptions } from "./prepare-units/composite-scale";
15
+ import { UnitSelectionPopover } from "./unit-details";
22
16
  import {
23
- _mergeOverlappingSections,
24
- ensureArray,
25
- groupUnitsIntoSections,
26
- } from "./helpers";
17
+ MacrostratColumnDataProvider,
18
+ useMacrostratColumnData,
19
+ } from "./data-provider";
20
+ import {
21
+ SectionSharedProps,
22
+ CompositeTimescale,
23
+ SectionsColumn,
24
+ } from "./section";
25
+ import { CompositeAgeAxis } from "./age-axis";
26
+ import { MergeSectionsMode, usePreparedColumnUnits } from "./prepare-units";
27
+ import { UnitLong } from "@macrostrat/api-types";
28
+ import { NonIdealState } from "@blueprintjs/core";
27
29
 
28
30
  const h = hyperStyled(styles);
29
31
 
30
- export function UnitComponent({ division, nColumns = 2, ...rest }) {
31
- const { width } = useContext(ColumnLayoutContext);
32
-
33
- //const nCols = Math.min(nColumns, division.overlappingUnits.length+1)
34
- //console.log(division);
35
- return h(TrackedLabeledUnit, {
36
- division,
37
- ...rest,
38
- width: division.overlappingUnits.length > 0 ? width / nColumns : width,
39
- x: (division.column * width) / nColumns,
40
- });
41
- }
42
-
43
- function Unconformity({ upperUnits = [], lowerUnits = [], style }) {
44
- if (upperUnits.length == 0 || lowerUnits.length == 0) {
45
- return null;
46
- }
47
-
48
- const ageGap = lowerUnits[0].t_age - upperUnits[upperUnits.length - 1].b_age;
49
-
50
- return h("div.unconformity", { style }, [
51
- h("div.unconformity-text", `${ageGap.toFixed(1)} Ma`),
52
- ]);
53
- }
54
-
55
- function sectionClassName(section: SectionInfo) {
56
- return `section-${ensureArray(section.section_id).join("-")}`;
57
- }
58
-
59
- export interface ColumnProps extends IColumnProps {
60
- unconformityLabels?: boolean;
32
+ interface BaseColumnProps extends SectionSharedProps {
61
33
  className?: string;
62
- mergeOverlappingSections?: boolean;
63
34
  showLabelColumn?: boolean;
64
- columnRef?: RefObject<HTMLElement>;
65
35
  keyboardNavigation?: boolean;
66
- showUnitPopover?: boolean;
36
+ showLabels?: boolean;
37
+ maxInternalColumns?: number;
38
+ // Timescale properties
39
+ showTimescale?: boolean;
40
+ timescaleLevels?: number | [number, number];
41
+ }
42
+
43
+ export interface ColumnProps extends BaseColumnProps, ColumnHeightScaleOptions {
44
+ // Macrostrat units
45
+ units: UnitLong[];
67
46
  t_age?: number;
68
47
  b_age?: number;
48
+ mergeSections?: MergeSectionsMode;
49
+ showUnitPopover?: boolean;
50
+ selectedUnit?: number | null;
51
+ onUnitSelected?: (unitID: number | null, unit: any) => void;
52
+ // Unconformity height in pixels
53
+ unconformityHeight?: number;
69
54
  }
70
55
 
71
56
  export function Column(props: ColumnProps) {
72
- const { showUnitPopover = false, ...rest } = props;
73
- const ref = createRef<HTMLElement>();
57
+ const {
58
+ showUnitPopover = false,
59
+ keyboardNavigation = false,
60
+ mergeSections,
61
+ onUnitSelected,
62
+ selectedUnit,
63
+ children,
64
+ units: rawUnits,
65
+ axisType = ColumnAxisType.AGE,
66
+ t_age,
67
+ b_age,
68
+ unconformityHeight = 30,
69
+ targetUnitHeight = 20,
70
+ pixelScale,
71
+ minPixelScale = 0.2,
72
+ minSectionHeight = 50,
73
+ collapseSmallUnconformities = true,
74
+ ...rest
75
+ } = props;
76
+ const ref = useRef<HTMLElement>();
74
77
  // Selected item position
75
- const [position, setPosition] = useState<RectBounds | null>(null);
76
78
 
77
- if (!showUnitPopover) {
78
- return h(_Column, rest);
79
+ const { sections, units, totalHeight } = usePreparedColumnUnits(rawUnits, {
80
+ axisType,
81
+ t_age,
82
+ b_age,
83
+ mergeSections,
84
+ targetUnitHeight,
85
+ unconformityHeight,
86
+ pixelScale,
87
+ minPixelScale,
88
+ minSectionHeight,
89
+ collapseSmallUnconformities,
90
+ });
91
+
92
+ if (sections.length === 0) {
93
+ return h(
94
+ "div.column-container.empty",
95
+ h(NonIdealState, {
96
+ title: "Empty column",
97
+ description: "No sections found in this column.",
98
+ icon: "warning-sign",
99
+ })
100
+ );
79
101
  }
80
102
 
81
103
  return h(
82
- UnitSelectionProvider,
83
- {
84
- onUnitSelected: (unit, target: SVGElement | HTMLElement | null) => {
85
- if (!showUnitPopover) return;
86
-
87
- if (unit == null) {
88
- setPosition(null);
89
- return;
90
- }
91
- const el: HTMLElement = ref.current;
92
- if (el == null || target == null) return;
93
- const rect = el.getBoundingClientRect();
94
- const targetRect = target.getBoundingClientRect();
95
- setPosition({
96
- x: targetRect.left - rect.left,
97
- y: targetRect.top - rect.top,
98
- width: targetRect.width,
99
- height: targetRect.height,
100
- });
101
- },
102
- },
104
+ MacrostratColumnDataProvider,
105
+ { units, sections, totalHeight, axisType },
103
106
  h(
104
- _Column,
105
- { ...rest, columnRef: ref },
106
- h(UnitSelectionPopover, { position })
107
+ UnitSelectionProvider,
108
+ { columnRef: ref, onUnitSelected, selectedUnit, units },
109
+ h(ColumnInner, { columnRef: ref, ...rest }, [
110
+ children,
111
+ h.if(showUnitPopover)(UnitSelectionPopover),
112
+ h.if(keyboardNavigation)(UnitKeyboardNavigation, { units }),
113
+ ])
107
114
  )
108
115
  );
109
116
  }
110
117
 
111
- function _Column(props: Omit<ColumnProps, "showUnitPopover">) {
118
+ interface ColumnInnerProps extends BaseColumnProps {
119
+ columnRef: RefObject<HTMLElement>;
120
+ }
121
+
122
+ function ColumnInner(props: ColumnInnerProps) {
112
123
  const {
113
- data,
114
124
  unitComponent = UnitComponent,
115
125
  unconformityLabels = true,
116
126
  showLabels = true,
117
- width = 300,
118
- columnWidth = 150,
119
- className: baseClassName,
120
- showLabelColumn = true,
121
- mergeOverlappingSections = true,
122
- keyboardNavigation = false,
127
+ width: _width = 300,
128
+ columnWidth: _columnWidth = 150,
129
+ showLabelColumn: _showLabelColumn = true,
130
+ className,
123
131
  columnRef,
132
+ clipUnits = false,
124
133
  children,
125
- ...rest
134
+ showTimescale,
135
+ timescaleLevels,
136
+ maxInternalColumns,
126
137
  } = props;
127
138
 
128
- const darkMode = useDarkMode();
129
- const sectionGroups = useMemo(() => {
130
- let res = groupUnitsIntoSections(data);
131
- if (mergeOverlappingSections) {
132
- res = _mergeOverlappingSections(res);
133
- }
134
- return res;
135
- }, [data, mergeOverlappingSections]);
136
-
137
- const className = classNames(baseClassName, {
138
- "dark-mode": darkMode?.isEnabled ?? false,
139
- });
139
+ const { axisType } = useMacrostratColumnData();
140
140
 
141
- // Clear unit selection on click outside of units, if we have a dispatch function
142
141
  const dispatch = useUnitSelectionDispatch();
143
142
 
143
+ let width = _width;
144
+ let columnWidth = _columnWidth;
145
+ if (columnWidth > width) {
146
+ columnWidth = width;
147
+ }
148
+ let showLabelColumn = _showLabelColumn;
149
+ if (columnWidth > width - 10) {
150
+ showLabelColumn = false;
151
+ }
152
+
153
+ let _showTimescale = showTimescale;
154
+ if (timescaleLevels !== null) {
155
+ _showTimescale = true;
156
+ }
157
+ _showTimescale = axisType == ColumnAxisType.AGE && _showTimescale;
158
+
144
159
  return h(
145
- "div.column-container",
160
+ ColumnContainer,
146
161
  {
147
- className,
148
162
  onClick(evt) {
149
163
  dispatch?.(null, null, evt as any);
150
164
  },
165
+ className,
151
166
  },
152
- h(MacrostratUnitsProvider, { units: data }, [
153
- h("div.column", { ref: columnRef }, [
154
- h("div.age-axis-label", "Age (Ma)"),
155
- h(
156
- "div.main-column",
157
- sectionGroups.map((group, i) => {
158
- const { section_id: id, units: data } = group;
159
- const lastGroup = sectionGroups[i - 1];
160
- return h([
161
- h.if(unconformityLabels)(Unconformity, {
162
- upperUnits: lastGroup?.units,
163
- lowerUnits: data,
164
- style: { width: showLabels ? columnWidth : width },
165
- }),
166
- h(`div.section`, { className: sectionClassName(group) }, [
167
- h(Section, {
168
- data,
169
- unitComponent,
170
- showLabels,
171
- width,
172
- columnWidth,
173
- showLabelColumn,
174
- ...rest,
175
- }),
176
- ]),
177
- ]);
178
- })
179
- ),
180
- h.if(keyboardNavigation)(UnitKeyboardNavigation, { units: data }),
181
- children,
182
- ]),
167
+ h("div.column", { ref: columnRef }, [
168
+ h(CompositeAgeAxis),
169
+ h.if(_showTimescale)(CompositeTimescale, { levels: timescaleLevels }),
170
+ h(SectionsColumn, {
171
+ unitComponent,
172
+ showLabels,
173
+ width,
174
+ columnWidth,
175
+ showLabelColumn,
176
+ clipUnits,
177
+ unconformityLabels,
178
+ maxInternalColumns,
179
+ }),
180
+ children,
183
181
  ])
184
182
  );
185
183
  }
184
+
185
+ export interface ColumnContainerProps extends HTMLAttributes<HTMLDivElement> {
186
+ className?: string;
187
+ }
188
+
189
+ export function ColumnContainer(props: ColumnContainerProps) {
190
+ const { className, ...rest } = props;
191
+ const darkMode = useDarkMode();
192
+
193
+ return h("div.column-container", {
194
+ className: classNames(className, {
195
+ "dark-mode": darkMode?.isEnabled ?? false,
196
+ }),
197
+ ...rest,
198
+ });
199
+ }
@@ -0,0 +1,57 @@
1
+ import { LineString } from "geojson";
2
+
3
+ export function parseLineFromString(section: string): LineString | null {
4
+ /* Section should be specified as space-separated coordinates */
5
+ if (section == null || typeof section !== "string") {
6
+ return null;
7
+ }
8
+
9
+ try {
10
+ let coords = section.split(" ").map(parseCoordinates);
11
+ return {
12
+ type: "LineString",
13
+ coordinates: coords,
14
+ };
15
+ } catch (e) {
16
+ console.warn(e);
17
+ return null;
18
+ }
19
+ }
20
+
21
+ export function stringifyLine(line: LineString | null): string | null {
22
+ if (
23
+ line == null ||
24
+ line.type !== "LineString" ||
25
+ line.coordinates.length < 2
26
+ ) {
27
+ return null;
28
+ }
29
+ return line.coordinates
30
+ .map((coord) => coord.map(stringifyNumber).join(","))
31
+ .join(" ");
32
+ }
33
+
34
+ function parseCoordinates(s: string): [number, number] {
35
+ let [x, y] = s.split(",").map(parseNumber);
36
+ if (x == null || y == null || isNaN(x) || isNaN(y)) {
37
+ throw new Error("Invalid coordinate string");
38
+ }
39
+ if (x > 180 || x < -180 || y > 90 || y < -90) {
40
+ throw new Error("Invalid coordinate value");
41
+ }
42
+ return [x, y];
43
+ }
44
+
45
+ function parseNumber(s: string): number {
46
+ let s1 = s;
47
+ // For some reason, we sometimes get en-dashes in the hash string
48
+ if (s1[0] == "−") {
49
+ s1 = "-" + s1.slice(1);
50
+ }
51
+ return Number(s1);
52
+ }
53
+
54
+ const stringifyNumber = (d) =>
55
+ d.toLocaleString("en-US", {
56
+ maximumFractionDigits: 2,
57
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./main";
2
+ export * from "./hash-string";
@@ -0,0 +1,122 @@
1
+ $map-size: 40em
2
+ $map-size-inset: 12em
3
+
4
+ .page-header
5
+ display: flex
6
+ flex-direction: row
7
+ justify-content: space-between
8
+ margin-bottom: 1em
9
+
10
+ .diagram-container
11
+ flex: 1
12
+ position: relative
13
+ min-height: 0
14
+ display: flex
15
+
16
+ &.map-inset
17
+ .column-selection-map
18
+ position: absolute
19
+ top: 1em
20
+ right: 1em
21
+ height: $map-size-inset
22
+ width: $map-size-inset
23
+ z-index: 1000
24
+
25
+ &.map-expanded
26
+ flex-direction: row
27
+ gap: 1em
28
+
29
+ .assistant
30
+ width: 40em
31
+ position: relative
32
+
33
+ .column-selection-map, .unit-details-panel, .main-area
34
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3)
35
+ border-radius: 6px
36
+
37
+ .column-selection-map
38
+ overflow: hidden
39
+
40
+ .correlation-map
41
+ height: 100%
42
+ position: relative
43
+
44
+ flex: 1
45
+ min-height: $map-size-inset
46
+ max-height: $map-size
47
+ width: $map-size
48
+ position: relative
49
+ top: 0
50
+ right: 0
51
+
52
+ .unit-details-panel
53
+ overflow: scroll
54
+ background: var(--panel-secondary-background-color)
55
+ flex: 2
56
+ padding: 1em
57
+ max-width: 100%
58
+
59
+ .main-area
60
+ position: relative
61
+ flex: 1
62
+ min-height: 0
63
+ min-width: 0
64
+ overflow: scroll
65
+ background-color: var(--panel-secondary-background-color)
66
+
67
+
68
+ .correlation-diagram
69
+ padding: 1em
70
+ padding-left: 0
71
+ background-color: var(--panel-secondary-background-color)
72
+ //box-shadow: 0 0 0.3em 0 var(--card-shadow-color)
73
+ --column-background-color: var(--background-color)
74
+ --column-stroke-color: var(--text-color)
75
+
76
+
77
+ .package
78
+ position: relative
79
+
80
+ .package-overlay
81
+ position: absolute
82
+ top: 9px
83
+ left: 0
84
+ border: 2px solid red
85
+
86
+ .laterally-extensive-unit .strat-col-span
87
+ position: absolute
88
+ border: 2px solid red
89
+
90
+ .column-container
91
+ display: flex
92
+ flex-direction: row
93
+
94
+ .map-expanded-button
95
+ position: absolute
96
+ top: 0.5em
97
+ right: 0.5em
98
+ z-index: 100
99
+
100
+ .main-panel
101
+ position: relative
102
+ height: 100%
103
+ display: flex
104
+ flex-direction: column
105
+
106
+ .main-chart
107
+ position: relative
108
+
109
+ .correlation-chart-inner
110
+ display: flex
111
+ flex-direction: row
112
+ position: relative
113
+
114
+ .age-axis-container
115
+ display: flex
116
+ flex-direction: row
117
+ position: sticky
118
+ left: 0
119
+ z-index: 100
120
+ padding-left: 1em
121
+ padding-right: 2px
122
+ background-color: var(--panel-secondary-background-color)