@macrostrat/column-views 3.3.3 → 3.3.4

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 (55) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/age-axis.d.ts +5 -5
  3. package/dist/age-model-overlay.d.ts +1 -1
  4. package/dist/column.d.ts +7 -7
  5. package/dist/correlation-chart/main.cjs +2 -2
  6. package/dist/correlation-chart/main.cjs.map +1 -1
  7. package/dist/correlation-chart/main.d.ts +2 -2
  8. package/dist/correlation-chart/main.js +2 -2
  9. package/dist/correlation-chart/main.js.map +1 -1
  10. package/dist/correlation-chart/prepare-data.d.ts +1 -1
  11. package/dist/correlation-chart/stories/utils.d.ts +1 -1
  12. package/dist/data-provider/column-nav.d.ts +1 -1
  13. package/dist/data-provider/unit-selection.cjs +1 -1
  14. package/dist/data-provider/unit-selection.cjs.map +1 -1
  15. package/dist/data-provider/unit-selection.d.ts +6 -6
  16. package/dist/data-provider/unit-selection.js +1 -1
  17. package/dist/data-provider/unit-selection.js.map +1 -1
  18. package/dist/facets/carbon-isotopes/data-area.d.ts +3 -3
  19. package/dist/facets/carbon-isotopes/data-provider.d.ts +3 -3
  20. package/dist/facets/detrital-zircon/index.d.ts +1 -1
  21. package/dist/facets/detrital-zircon/provider.d.ts +1 -1
  22. package/dist/facets/fossils/index.d.ts +1 -1
  23. package/dist/facets/fossils/taxon-ranges.d.ts +1 -1
  24. package/dist/facets/measurements/base.d.ts +5 -5
  25. package/dist/facets/measurements/sgp.d.ts +1 -1
  26. package/dist/maps/column-correlation/state.d.ts +2 -2
  27. package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +1 -1
  28. package/dist/maps/column-navigation/mapbox/state.d.ts +2 -2
  29. package/dist/maps/column-navigation/svg/data-fetcher.d.ts +1 -1
  30. package/dist/maps/column-navigation/svg/index.d.ts +1 -1
  31. package/dist/maps/column-navigation/svg/layers.d.ts +6 -6
  32. package/dist/maps/column-navigation/utils/keyboard-navigation.d.ts +1 -1
  33. package/dist/maps/inset-map/index.d.ts +3 -3
  34. package/dist/maps/layers/columns.d.ts +3 -3
  35. package/dist/maps/layers/units.d.ts +1 -1
  36. package/dist/prepare-units/composite-scale.d.ts +1 -1
  37. package/dist/prepare-units/dynamic-scales.d.ts +1 -1
  38. package/dist/prepare-units/helpers.d.ts +2 -2
  39. package/dist/prepare-units/index.d.ts +1 -1
  40. package/dist/prepare-units/types.d.ts +2 -2
  41. package/dist/prepare-units/utils.d.ts +2 -2
  42. package/dist/section.d.ts +2 -2
  43. package/dist/unit-details/age-range.d.ts +4 -4
  44. package/dist/unit-details/modal-panel.d.ts +1 -1
  45. package/dist/unit-details/popover.d.ts +5 -1
  46. package/dist/unit-details/utils.d.ts +2 -2
  47. package/dist/units/boxes.d.ts +6 -6
  48. package/dist/units/colors.d.ts +1 -1
  49. package/dist/units/composite.d.ts +6 -6
  50. package/dist/units/index.d.ts +7 -7
  51. package/dist/units/names.d.ts +3 -2
  52. package/dist/units/resolvers.d.ts +1 -1
  53. package/package.json +6 -6
  54. package/src/correlation-chart/main.ts +2 -2
  55. package/src/data-provider/unit-selection.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.3.4] - 2026-05-11 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/column-views-v3.3.3...@macrostrat/column-views-v3.3.4)
4
+
5
+ ### Patch Changes
6
+
7
+ - Simplify handling of nested scoped stores
8
+ - Updated dependencies
9
+ - @macrostrat/data-components@1.1.8
10
+
3
11
  ## [3.3.3] - 2026-04-05 [_changes_](https://github.com/UW-Macrostrat/web-components/compare/@macrostrat/column-views-v3.3.2...@macrostrat/column-views-v3.3.3)
4
12
 
5
13
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import { ColumnAxisType } from '@macrostrat/column-components';
1
+ import { ColumnAxisType } from '../../column-components/src/index.ts';
2
2
  import { PackageScaleLayoutData } from './prepare-units';
3
3
  export declare function VerticalAxisLabel(props: any): import('react').ReactElement<{
4
4
  className: any;
@@ -10,8 +10,8 @@ interface CompositeAgeAxisProps {
10
10
  className?: string;
11
11
  style?: React.CSSProperties;
12
12
  }
13
- export declare function CompositeAgeAxis(rest: CompositeAgeAxisProps): import('react').FunctionComponentElement<CompositeStratigraphicScaleInfo>;
14
- export declare function ApproximateHeightAxis(rest: CompositeAgeAxisProps): import('react').FunctionComponentElement<CompositeStratigraphicScaleInfo>;
13
+ export declare function CompositeAgeAxis(rest: CompositeAgeAxisProps): import('react').DetailedReactHTMLElement<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
14
+ export declare function ApproximateHeightAxis(rest: CompositeAgeAxisProps): import('react').DetailedReactHTMLElement<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
15
15
  export interface CompositeStratigraphicScaleInfo extends CompositeAgeAxisProps {
16
16
  axisType: ColumnAxisType;
17
17
  axisLabel?: string;
@@ -22,12 +22,12 @@ export interface CompositeStratigraphicScaleInfo extends CompositeAgeAxisProps {
22
22
  export declare function CompositeAgeAxisCore(props: CompositeStratigraphicScaleInfo): import('react').ReactElement<{
23
23
  className?: string;
24
24
  style?: React.CSSProperties;
25
- }, string | import('react').JSXElementConstructor<any>>;
25
+ }, string | import('react').JSXElementConstructor<any>> | null;
26
26
  export declare function AgeCursor({ age }: {
27
27
  age: any;
28
28
  }): import('react').ReactElement<{
29
29
  style: {
30
30
  top: number;
31
31
  };
32
- }, string | import('react').JSXElementConstructor<any>>;
32
+ }, string | import('react').JSXElementConstructor<any>> | null;
33
33
  export {};
@@ -20,5 +20,5 @@
20
20
  * },
21
21
  *
22
22
  * */
23
- export declare function BoundaryAgeModelOverlay(): import('react').DOMElement<any, Element>;
23
+ export declare function BoundaryAgeModelOverlay(): import('react').DOMElement<any, Element> | null;
24
24
  export declare function ComputedSurfacesOverlay(): import('react').DOMElement<import('react').DOMAttributes<Element>, Element>;
package/dist/column.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Padding } from '@macrostrat/ui-components';
1
+ import { Padding } from '../../ui-components/src/index.ts';
2
2
  import { HTMLAttributes, CSSProperties } from 'react';
3
3
  import { SectionSharedProps } from './section';
4
4
  import { MergeSectionsMode, ColumnHeightScaleOptions } from './prepare-units';
5
- import { UnitLong } from '@macrostrat/api-types';
5
+ import { UnitLong } from '../../api-types/src/index.ts';
6
6
  import { ScaleContinuousNumeric } from 'd3-scale';
7
7
  interface BaseColumnProps extends Omit<SectionSharedProps, "unconformityLabels"> {
8
8
  className?: string;
@@ -30,15 +30,15 @@ export interface ColumnProps extends Padding, BaseColumnProps, ColumnHeightScale
30
30
  unconformityHeight?: number;
31
31
  scale?: ScaleContinuousNumeric<number, number>;
32
32
  }
33
- export declare function Column(props: ColumnProps): import('react').DOMElement<import('react').DOMAttributes<Element>, Element> | import('react').FunctionComponentElement<import('./data-provider').ColumnDataProviderProps<import('@macrostrat/api-types').BaseUnit>>;
33
+ export declare function Column(props: ColumnProps): import('react').DetailedReactHTMLElement<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> | import('react').ReactElement<import('react').FunctionComponentElement<import('@blueprintjs/core').NonIdealStateProps>, string | import('react').JSXElementConstructor<any>>;
34
34
  export interface ColumnContainerProps extends HTMLAttributes<HTMLDivElement> {
35
35
  className?: string;
36
36
  style?: CSSProperties;
37
37
  }
38
- export declare function ColumnContainer(props: ColumnContainerProps): import('react').DetailedReactHTMLElement<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
38
+ export declare function ColumnContainer(props: ColumnContainerProps): import('react').FunctionComponentElement<import('ui-box').BoxProps<import('react').ElementType<any, keyof import("react").JSX.IntrinsicElements>>>;
39
39
  export declare function ColumnBasicInfo({ data, showColumnID, showReferences, }: {
40
40
  data: any;
41
- showColumnID?: boolean;
42
- showReferences?: boolean;
43
- }): import('react').DOMElement<import('react').DOMAttributes<Element>, Element>;
41
+ showColumnID?: boolean | undefined;
42
+ showReferences?: boolean | undefined;
43
+ }): import('react').DOMElement<import('react').DOMAttributes<Element>, Element> | null;
44
44
  export {};
@@ -124,7 +124,7 @@ function Package({
124
124
  }) {
125
125
  return h("g.package", { transform: `translate(0 ${offset})` }, [
126
126
  // Disable the SVG overlay for now
127
- //h(PackageSVGOverlay, { data, columnSpacing }),
127
+ //h(PackageSVGOverlay, { columnData, columnSpacing }),
128
128
  h("g.column-units", [
129
129
  columnData.map((data, i) => {
130
130
  return h(Column, {
@@ -176,7 +176,7 @@ function Column(props) {
176
176
  unitComponentProps: {
177
177
  nColumns: 2,
178
178
  width: columnWidth,
179
- showLabel: false
179
+ showLabel: true
180
180
  }
181
181
  })
182
182
  )
@@ -1 +1 @@
1
- {"version":3,"file":"main.cjs","sources":["../../src/correlation-chart/main.ts"],"sourcesContent":["/** Correlation chart */\nimport {\n UnitSelectionProvider,\n UnitKeyboardNavigation,\n useUnitSelectionDispatch,\n useColumnRef,\n} from \"../data-provider\";\nimport { UnitDetailsFeature, UnitSelectionPopover } from \"../unit-details\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { useMemo } from \"react\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { CompositeTimescaleCore } from \"../section\";\nimport classNames from \"classnames\";\nimport {\n findLaterallyExtensiveUnits,\n splitStratIntoBoxes,\n UnitGroupBox,\n CorrelationChartSettings,\n buildCorrelationChartData,\n} from \"./prepare-data\";\nimport {\n CompositeAgeAxisCore,\n CompositeStratigraphicScaleInfo,\n} from \"../age-axis\";\nimport {\n ColumnAxisType,\n ColumnProvider,\n SVG,\n} from \"@macrostrat/column-components\";\nimport { ColoredUnitComponent } from \"../units\";\nimport { UnitBoxes } from \"../units/boxes\";\nimport { ColumnContainer } from \"../column\";\nimport { ColumnData } from \"../data-provider\";\nimport { BaseUnit } from \"@macrostrat/api-types\";\nimport { ScaleContinuousNumeric } from \"d3-scale\";\nimport { ExtUnit } from \"../prepare-units/types\";\n\nconst h = hyper.styled(styles);\n\nexport interface CorrelationChartProps extends CorrelationChartSettings {\n data: ColumnData[];\n columnWidth?: number;\n columnSpacing?: number;\n targetUnitHeight?: number;\n unconformityLabels?: boolean;\n selectedUnit?: number | null;\n showUnitPopover?: boolean;\n unitComponent?: any;\n onUnitSelected?: (unitID: number | null, unit: BaseUnit | null) => void;\n}\n\nfunction MainChartArea({ children }) {\n const columnRef = useColumnRef();\n return h(\"div.main-chart\", { ref: columnRef }, children);\n}\n\nconst unitPopoverFeatures = new Set([\n UnitDetailsFeature.AdjacentUnits,\n UnitDetailsFeature.OutcropType,\n UnitDetailsFeature.DepthRange,\n UnitDetailsFeature.ColumnName,\n]);\n\nexport function CorrelationChart({\n data,\n columnSpacing = 0,\n columnWidth = 130,\n unconformityLabels = true,\n showUnitPopover = true,\n selectedUnit,\n onUnitSelected,\n unitComponent,\n ...scaleProps\n}: CorrelationChartProps) {\n const defaultScaleProps = {\n targetUnitHeight: 10,\n unconformityHeight: 60,\n minSectionHeight: 60,\n collapseSmallUnconformities: true,\n };\n\n const chartData = useMemo(() => {\n if (!data) return null;\n return buildCorrelationChartData(data, {\n ...defaultScaleProps,\n ...scaleProps,\n });\n }, [data, ...Object.values(scaleProps)]);\n\n // A flattened units array is used to support keyboard navigation\n const units = useMemo(() => {\n return data?.map((d0) => d0.units).flat() ?? [];\n }, [data]);\n\n const inDarkMode = useInDarkMode();\n\n const className = classNames({\n \"dark-mode\": inDarkMode,\n });\n\n if (chartData == null) {\n return null;\n }\n\n const { packages, scaleInfo, nColumns } = chartData;\n\n const mainWidth = (columnWidth + columnSpacing) * nColumns;\n\n return h(\n ColumnContainer,\n { className: \"correlation-diagram\" },\n h(\n UnitSelectionProvider,\n { selectedUnit, onUnitSelected, units },\n h(ChartArea, [\n h(TimescaleColumn, {\n key: \"timescale\",\n scaleInfo,\n unconformityLabels,\n }),\n h(MainChartArea, [\n h(\n SVG,\n {\n className,\n innerWidth: mainWidth,\n height: scaleInfo.totalHeight,\n paddingH: 4,\n },\n packages.map((pkg, i) => {\n const { offset, domain, pixelScale, scale, key } =\n scaleInfo.packages[i];\n return h(Package, {\n columnData: pkg.columnData,\n key,\n columnWidth,\n columnSpacing,\n offset,\n domain,\n pixelScale,\n scale,\n unitComponent,\n });\n }),\n ),\n h.if(showUnitPopover)(UnitSelectionPopover, {\n features: unitPopoverFeatures,\n }),\n // Navigation only works within a column for now...\n h(UnitKeyboardNavigation, { columnData: data }),\n ]),\n ]),\n ),\n );\n}\n\nfunction Package({\n columnData,\n columnSpacing,\n columnWidth,\n unitComponent,\n offset,\n domain,\n pixelScale,\n scale,\n}) {\n return h(\"g.package\", { transform: `translate(0 ${offset})` }, [\n // Disable the SVG overlay for now\n //h(PackageSVGOverlay, { data, columnSpacing }),\n h(\"g.column-units\", [\n columnData.map((data, i) => {\n return h(Column, {\n units: data.units,\n unitComponent,\n width: columnWidth,\n key: i,\n domain,\n pixelScale,\n scale,\n offsetLeft: i * (columnWidth + columnSpacing),\n });\n }),\n ]),\n ]);\n}\n\ninterface ColumnProps {\n units: ExtUnit[];\n unitComponent?: React.FunctionComponent<any>;\n unitComponentProps?: any;\n showLabels?: boolean;\n width?: number;\n columnWidth?: number;\n columnSpacing?: number;\n targetUnitHeight?: number;\n offsetLeft?: number;\n domain: [number, number];\n pixelScale: number;\n scale?: ScaleContinuousNumeric<number, number>;\n}\n\nfunction Column(props: ColumnProps) {\n const {\n units,\n width = 150,\n offsetLeft,\n domain,\n pixelScale,\n scale,\n unitComponent = ColoredUnitComponent,\n } = props;\n\n const columnWidth = width;\n\n if (units.length == 0) {\n return null;\n }\n\n return h(\n \"g.section\",\n {\n transform: `translate(${offsetLeft} 0)`,\n },\n h(\n ColumnProvider,\n {\n // Need to tighten up types here...\n divisions: units as any[],\n range: domain,\n scale,\n pixelsPerMeter: pixelScale, // Actually pixels per myr\n axisType: ColumnAxisType.AGE,\n },\n h(UnitBoxes, {\n unitComponent,\n unitComponentProps: {\n nColumns: 2,\n width: columnWidth,\n showLabel: false,\n },\n }),\n ),\n );\n}\n\nfunction PackageSVGOverlay({ data, columnWidth = 100, columnSpacing = 0 }) {\n const { b_age, t_age, bestPixelScale, columnData } = data;\n\n const width = (columnWidth + columnSpacing) * columnData.length;\n const height = Math.ceil((b_age - t_age) * bestPixelScale) + 2;\n\n const extensiveUnits = findLaterallyExtensiveUnits(data);\n\n const scale = (val: number) => {\n return (val - t_age) * bestPixelScale;\n };\n\n return h(\n \"div.package-overlay\",\n { style: { width, height } },\n extensiveUnits.map((d) => {\n return h(LaterallyExtensiveUnit, {\n data: d,\n scale,\n pixelScale: bestPixelScale,\n columnSpacing,\n });\n }),\n );\n}\n\nfunction LaterallyExtensiveUnit({ data, scale, pixelScale, columnSpacing }) {\n const { b_age, t_age, strat_name_long, units } = data;\n // Build boxes by column groups\n const boxes: UnitGroupBox[] = splitStratIntoBoxes(data);\n\n return h(\n \"div.laterally-extensive-unit\",\n boxes.map((d, i) => {\n return h(StratColSpan, {\n scale,\n data: d,\n pixelScale,\n key: i,\n columnSpacing,\n });\n }),\n );\n}\n\nfunction StratColSpan({\n data,\n scale,\n columnWidth = 100,\n columnSpacing = 0,\n pixelScale = 1,\n}) {\n const { startCol, endCol, strat_name_long, t_age, b_age } = data;\n const top = scale(t_age);\n const left = startCol * (columnWidth + columnSpacing);\n const width = (endCol - startCol + 1) * (columnWidth + columnSpacing);\n const height = (b_age - t_age) * pixelScale;\n return h(\n \"div.strat-col-span\",\n { style: { top, height, width, left } },\n strat_name_long,\n );\n}\n\nfunction ChartArea({ children }) {\n const setSelectedUnit = useUnitSelectionDispatch();\n\n return h(\n \"div.correlation-chart-inner\",\n {\n onClick() {\n setSelectedUnit(null, null);\n },\n },\n children,\n );\n}\n\ninterface TimescaleColumnProps {\n scaleInfo: CompositeStratigraphicScaleInfo;\n showLabels?: boolean;\n unconformityLabels?: boolean;\n}\n\nfunction TimescaleColumn(props: TimescaleColumnProps) {\n const { scaleInfo, unconformityLabels = true } = props;\n return h(\"div.column-container.age-axis-container\", [\n h(CompositeAgeAxisCore, { ...scaleInfo }),\n h(CompositeTimescaleCore, { ...scaleInfo, unconformityLabels }),\n ]);\n}\n"],"names":["hyper","styles","useColumnRef","UnitDetailsFeature","useMemo","buildCorrelationChartData","useInDarkMode","classNames","ColumnContainer","UnitSelectionProvider","SVG","UnitSelectionPopover","UnitKeyboardNavigation","ColoredUnitComponent","ColumnProvider","ColumnAxisType","UnitBoxes","useUnitSelectionDispatch","CompositeAgeAxisCore","CompositeTimescaleCore"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,IAAIA,WAAAA,QAAM,OAAOC,mBAAM;AAc7B,SAAS,cAAc,EAAE,YAAY;AACnC,QAAM,YAAYC,cAAAA,aAAA;AAClB,SAAO,EAAE,kBAAkB,EAAE,KAAK,UAAA,GAAa,QAAQ;AACzD;AAEA,MAAM,0CAA0B,IAAI;AAAA,EAClCC,MAAAA,mBAAmB;AAAA,EACnBA,MAAAA,mBAAmB;AAAA,EACnBA,MAAAA,mBAAmB;AAAA,EACnBA,yBAAmB;AACrB,CAAC;AAEM,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA0B;AACxB,QAAM,oBAAoB;AAAA,IACxB,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB,kBAAkB;AAAA,IAClB,6BAA6B;AAAA,EAAA;AAG/B,QAAM,YAAYC,MAAAA,QAAQ,MAAM;AAC9B,QAAI,CAAC,KAAM,QAAO;AAClB,WAAOC,YAAAA,0BAA0B,MAAM;AAAA,MACrC,GAAG;AAAA,MACH,GAAG;AAAA,IAAA,CACJ;AAAA,EACH,GAAG,CAAC,MAAM,GAAG,OAAO,OAAO,UAAU,CAAC,CAAC;AAGvC,QAAM,QAAQD,MAAAA,QAAQ,MA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ACA;AAAA,MACE,UAAU;AACR,wBAAgB,MAAM,IAAI;AAAA,MAC5B;AAAA,IAAA;AAAA,IAEF;AAAA,EAAA;AAEJ;AAQA,SAAS,gBAAgB,OAA6B;AACpD,QAAM,EAAE,WAAW,qBAAqB,KAAA,IAAS;AACjD,SAAO,EAAE,2CAA2C;AAAA,IAClD,EAAEC,QAAAA,sBAAsB,EAAE,GAAG,WAAW;AAAA,IACxC,EAAEC,QAAAA,wBAAwB,EAAE,GAAG,WAAW,oBAAoB;AAAA,EAAA,CAC/D;AACH;;"}
1
+ {"version":3,"file":"main.cjs","sources":["../../src/correlation-chart/main.ts"],"sourcesContent":["/** Correlation chart */\nimport {\n UnitSelectionProvider,\n UnitKeyboardNavigation,\n useUnitSelectionDispatch,\n useColumnRef,\n} from \"../data-provider\";\nimport { UnitDetailsFeature, UnitSelectionPopover } from \"../unit-details\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { useMemo } from \"react\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { CompositeTimescaleCore } from \"../section\";\nimport classNames from \"classnames\";\nimport {\n findLaterallyExtensiveUnits,\n splitStratIntoBoxes,\n UnitGroupBox,\n CorrelationChartSettings,\n buildCorrelationChartData,\n} from \"./prepare-data\";\nimport {\n CompositeAgeAxisCore,\n CompositeStratigraphicScaleInfo,\n} from \"../age-axis\";\nimport {\n ColumnAxisType,\n ColumnProvider,\n SVG,\n} from \"@macrostrat/column-components\";\nimport { ColoredUnitComponent } from \"../units\";\nimport { UnitBoxes } from \"../units/boxes\";\nimport { ColumnContainer } from \"../column\";\nimport { ColumnData } from \"../data-provider\";\nimport { BaseUnit } from \"@macrostrat/api-types\";\nimport { ScaleContinuousNumeric } from \"d3-scale\";\nimport { ExtUnit } from \"../prepare-units/types\";\n\nconst h = hyper.styled(styles);\n\nexport interface CorrelationChartProps extends CorrelationChartSettings {\n data: ColumnData[];\n columnWidth?: number;\n columnSpacing?: number;\n targetUnitHeight?: number;\n unconformityLabels?: boolean;\n selectedUnit?: number | null;\n showUnitPopover?: boolean;\n unitComponent?: any;\n onUnitSelected?: (unitID: number | null, unit: BaseUnit | null) => void;\n}\n\nfunction MainChartArea({ children }) {\n const columnRef = useColumnRef();\n return h(\"div.main-chart\", { ref: columnRef }, children);\n}\n\nconst unitPopoverFeatures = new Set([\n UnitDetailsFeature.AdjacentUnits,\n UnitDetailsFeature.OutcropType,\n UnitDetailsFeature.DepthRange,\n UnitDetailsFeature.ColumnName,\n]);\n\nexport function CorrelationChart({\n data,\n columnSpacing = 0,\n columnWidth = 130,\n unconformityLabels = true,\n showUnitPopover = true,\n selectedUnit,\n onUnitSelected,\n unitComponent,\n ...scaleProps\n}: CorrelationChartProps) {\n const defaultScaleProps = {\n targetUnitHeight: 10,\n unconformityHeight: 60,\n minSectionHeight: 60,\n collapseSmallUnconformities: true,\n };\n\n const chartData = useMemo(() => {\n if (!data) return null;\n return buildCorrelationChartData(data, {\n ...defaultScaleProps,\n ...scaleProps,\n });\n }, [data, ...Object.values(scaleProps)]);\n\n // A flattened units array is used to support keyboard navigation\n const units = useMemo(() => {\n return data?.map((d0) => d0.units).flat() ?? [];\n }, [data]);\n\n const inDarkMode = useInDarkMode();\n\n const className = classNames({\n \"dark-mode\": inDarkMode,\n });\n\n if (chartData == null) {\n return null;\n }\n\n const { packages, scaleInfo, nColumns } = chartData;\n\n const mainWidth = (columnWidth + columnSpacing) * nColumns;\n\n return h(\n ColumnContainer,\n { className: \"correlation-diagram\" },\n h(\n UnitSelectionProvider,\n { selectedUnit, onUnitSelected, units },\n h(ChartArea, [\n h(TimescaleColumn, {\n key: \"timescale\",\n scaleInfo,\n unconformityLabels,\n }),\n h(MainChartArea, [\n h(\n SVG,\n {\n className,\n innerWidth: mainWidth,\n height: scaleInfo.totalHeight,\n paddingH: 4,\n },\n packages.map((pkg, i) => {\n const { offset, domain, pixelScale, scale, key } =\n scaleInfo.packages[i];\n return h(Package, {\n columnData: pkg.columnData,\n key,\n columnWidth,\n columnSpacing,\n offset,\n domain,\n pixelScale,\n scale,\n unitComponent,\n });\n }),\n ),\n h.if(showUnitPopover)(UnitSelectionPopover, {\n features: unitPopoverFeatures,\n }),\n // Navigation only works within a column for now...\n h(UnitKeyboardNavigation, { columnData: data }),\n ]),\n ]),\n ),\n );\n}\n\nfunction Package({\n columnData,\n columnSpacing,\n columnWidth,\n unitComponent,\n offset,\n domain,\n pixelScale,\n scale,\n}) {\n return h(\"g.package\", { transform: `translate(0 ${offset})` }, [\n // Disable the SVG overlay for now\n //h(PackageSVGOverlay, { columnData, columnSpacing }),\n h(\"g.column-units\", [\n columnData.map((data, i) => {\n return h(Column, {\n units: data.units,\n unitComponent,\n width: columnWidth,\n key: i,\n domain,\n pixelScale,\n scale,\n offsetLeft: i * (columnWidth + columnSpacing),\n });\n }),\n ]),\n ]);\n}\n\ninterface ColumnProps {\n units: ExtUnit[];\n unitComponent?: React.FunctionComponent<any>;\n unitComponentProps?: any;\n showLabels?: boolean;\n width?: number;\n columnWidth?: number;\n columnSpacing?: number;\n targetUnitHeight?: number;\n offsetLeft?: number;\n domain: [number, number];\n pixelScale: number;\n scale?: ScaleContinuousNumeric<number, number>;\n}\n\nfunction Column(props: ColumnProps) {\n const {\n units,\n width = 150,\n offsetLeft,\n domain,\n pixelScale,\n scale,\n unitComponent = ColoredUnitComponent,\n } = props;\n\n const columnWidth = width;\n\n if (units.length == 0) {\n return null;\n }\n\n return h(\n \"g.section\",\n {\n transform: `translate(${offsetLeft} 0)`,\n },\n h(\n ColumnProvider,\n {\n // Need to tighten up types here...\n divisions: units as any[],\n range: domain,\n scale,\n pixelsPerMeter: pixelScale, // Actually pixels per myr\n axisType: ColumnAxisType.AGE,\n },\n h(UnitBoxes, {\n unitComponent,\n unitComponentProps: {\n nColumns: 2,\n width: columnWidth,\n showLabel: true,\n },\n }),\n ),\n );\n}\n\nfunction PackageSVGOverlay({ data, columnWidth = 100, columnSpacing = 0 }) {\n const { b_age, t_age, bestPixelScale, columnData } = data;\n\n const width = (columnWidth + columnSpacing) * columnData.length;\n const height = Math.ceil((b_age - t_age) * bestPixelScale) + 2;\n\n const extensiveUnits = findLaterallyExtensiveUnits(data);\n\n const scale = (val: number) => {\n return (val - t_age) * bestPixelScale;\n };\n\n return h(\n \"div.package-overlay\",\n { style: { width, height } },\n extensiveUnits.map((d) => {\n return h(LaterallyExtensiveUnit, {\n data: d,\n scale,\n pixelScale: bestPixelScale,\n columnSpacing,\n });\n }),\n );\n}\n\nfunction LaterallyExtensiveUnit({ data, scale, pixelScale, columnSpacing }) {\n const { b_age, t_age, strat_name_long, units } = data;\n // Build boxes by column groups\n const boxes: UnitGroupBox[] = splitStratIntoBoxes(data);\n\n return h(\n \"div.laterally-extensive-unit\",\n boxes.map((d, i) => {\n return h(StratColSpan, {\n scale,\n data: d,\n pixelScale,\n key: i,\n columnSpacing,\n });\n }),\n );\n}\n\nfunction StratColSpan({\n data,\n scale,\n columnWidth = 100,\n columnSpacing = 0,\n pixelScale = 1,\n}) {\n const { startCol, endCol, strat_name_long, t_age, b_age } = data;\n const top = scale(t_age);\n const left = startCol * (columnWidth + columnSpacing);\n const width = (endCol - startCol + 1) * (columnWidth + columnSpacing);\n const height = (b_age - t_age) * pixelScale;\n return h(\n \"div.strat-col-span\",\n { style: { top, height, width, left } },\n strat_name_long,\n );\n}\n\nfunction ChartArea({ children }) {\n const setSelectedUnit = useUnitSelectionDispatch();\n\n return h(\n \"div.correlation-chart-inner\",\n {\n onClick() {\n setSelectedUnit(null, null);\n },\n },\n children,\n );\n}\n\ninterface TimescaleColumnProps {\n scaleInfo: CompositeStratigraphicScaleInfo;\n showLabels?: boolean;\n unconformityLabels?: boolean;\n}\n\nfunction TimescaleColumn(props: TimescaleColumnProps) {\n const { scaleInfo, unconformityLabels = true } = props;\n return h(\"div.column-container.age-axis-container\", [\n h(CompositeAgeAxisCore, { ...scaleInfo }),\n h(CompositeTimescaleCore, { ...scaleInfo, unconformityLabels }),\n ]);\n}\n"],"names":["hyper","styles","useColumnRef","UnitDetailsFeature","useMemo","buildCorrelationChartData","useInDarkMode","classNames","ColumnContainer","UnitSelectionProvider","SVG","UnitSelectionPopover","UnitKeyboardNavigation","ColoredUnitComponent","ColumnProvider","ColumnAxisType","UnitBoxes","useUnitSelectionDispatch","CompositeAgeAxisCore","CompositeTimescaleCore"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,IAAIA,WAAAA,QAAM,OAAOC,mBAAM;AAc7B,SAAS,cAAc,EAAE,YAAY;AACnC,QAAM,YAAYC,cAAAA,aAAA;AAClB,SAAO,EAAE,kBAAkB,EAAE,KAAK,UAAA,GAAa,QAAQ;AACzD;AAEA,MAAM,0CAA0B,IAAI;AAAA,EAClCC,MAAAA,mBAAmB;AAAA,EACnBA,MAAAA,mBAAmB;AAAA,EACnBA,MAAAA,mBAAmB;AAAA,EACnBA,yBAAmB;AACrB,CAAC;AAEM,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA0B;AACxB,QAAM,oBAAoB;AAAA,IACxB,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB,kBAAkB;AAAA,IAClB,6BAA6B;AAAA,EAAA;AAG/B,QAAM,YAAYC,MAAAA,QAAQ,MAAM;AAC9B,QAAI,CAAC,KAAM,QAAO;AAClB,WAAOC,YAAAA,0BAA0B,MAAM;AAAA,MACrC,GAAG;AAAA,MACH,GAAG;AAAA,IAAA,CACJ;AAAA,EACH,GAAG,CAAC,MAAM,GAAG,OAAO,OAAO,UAAU,CAAC,CAAC;AAGvC,QAAM,QAAQD,MAAAA,QAAQ,MAAM;AAC1B,WAAO,MAAM,IAAI,CAAC,OAAO,GAAG,KAAK,EAAE,KAAA,KAAU,CAAA;AAAA,EAC/C,GAAG,CAAC,IAAI,C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AAS,gBAAgB,OAA6B;AACpD,QAAM,EAAE,WAAW,qBAAqB,KAAA,IAAS;AACjD,SAAO,EAAE,2CAA2C;AAAA,IAClD,EAAEC,QAAAA,sBAAsB,EAAE,GAAG,WAAW;AAAA,IACxC,EAAEC,QAAAA,wBAAwB,EAAE,GAAG,WAAW,oBAAoB;AAAA,EAAA,CAC/D;AACH;;"}
@@ -1,6 +1,6 @@
1
1
  import { CorrelationChartSettings } from './prepare-data';
2
2
  import { ColumnData } from '../data-provider';
3
- import { BaseUnit } from '@macrostrat/api-types';
3
+ import { BaseUnit } from '../../../api-types/src/index.ts';
4
4
  export interface CorrelationChartProps extends CorrelationChartSettings {
5
5
  data: ColumnData[];
6
6
  columnWidth?: number;
@@ -12,4 +12,4 @@ export interface CorrelationChartProps extends CorrelationChartSettings {
12
12
  unitComponent?: any;
13
13
  onUnitSelected?: (unitID: number | null, unit: BaseUnit | null) => void;
14
14
  }
15
- export declare function CorrelationChart({ data, columnSpacing, columnWidth, unconformityLabels, showUnitPopover, selectedUnit, onUnitSelected, unitComponent, ...scaleProps }: CorrelationChartProps): import('react').FunctionComponentElement<import('..').ColumnContainerProps>;
15
+ export declare function CorrelationChart({ data, columnSpacing, columnWidth, unconformityLabels, showUnitPopover, selectedUnit, onUnitSelected, unitComponent, ...scaleProps }: CorrelationChartProps): import('react').FunctionComponentElement<import('..').ColumnContainerProps> | null;
@@ -119,7 +119,7 @@ function Package({
119
119
  }) {
120
120
  return h("g.package", { transform: `translate(0 ${offset})` }, [
121
121
  // Disable the SVG overlay for now
122
- //h(PackageSVGOverlay, { data, columnSpacing }),
122
+ //h(PackageSVGOverlay, { columnData, columnSpacing }),
123
123
  h("g.column-units", [
124
124
  columnData.map((data, i) => {
125
125
  return h(Column, {
@@ -171,7 +171,7 @@ function Column(props) {
171
171
  unitComponentProps: {
172
172
  nColumns: 2,
173
173
  width: columnWidth,
174
- showLabel: false
174
+ showLabel: true
175
175
  }
176
176
  })
177
177
  )
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sources":["../../src/correlation-chart/main.ts"],"sourcesContent":["/** Correlation chart */\nimport {\n UnitSelectionProvider,\n UnitKeyboardNavigation,\n useUnitSelectionDispatch,\n useColumnRef,\n} from \"../data-provider\";\nimport { UnitDetailsFeature, UnitSelectionPopover } from \"../unit-details\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { useMemo } from \"react\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { CompositeTimescaleCore } from \"../section\";\nimport classNames from \"classnames\";\nimport {\n findLaterallyExtensiveUnits,\n splitStratIntoBoxes,\n UnitGroupBox,\n CorrelationChartSettings,\n buildCorrelationChartData,\n} from \"./prepare-data\";\nimport {\n CompositeAgeAxisCore,\n CompositeStratigraphicScaleInfo,\n} from \"../age-axis\";\nimport {\n ColumnAxisType,\n ColumnProvider,\n SVG,\n} from \"@macrostrat/column-components\";\nimport { ColoredUnitComponent } from \"../units\";\nimport { UnitBoxes } from \"../units/boxes\";\nimport { ColumnContainer } from \"../column\";\nimport { ColumnData } from \"../data-provider\";\nimport { BaseUnit } from \"@macrostrat/api-types\";\nimport { ScaleContinuousNumeric } from \"d3-scale\";\nimport { ExtUnit } from \"../prepare-units/types\";\n\nconst h = hyper.styled(styles);\n\nexport interface CorrelationChartProps extends CorrelationChartSettings {\n data: ColumnData[];\n columnWidth?: number;\n columnSpacing?: number;\n targetUnitHeight?: number;\n unconformityLabels?: boolean;\n selectedUnit?: number | null;\n showUnitPopover?: boolean;\n unitComponent?: any;\n onUnitSelected?: (unitID: number | null, unit: BaseUnit | null) => void;\n}\n\nfunction MainChartArea({ children }) {\n const columnRef = useColumnRef();\n return h(\"div.main-chart\", { ref: columnRef }, children);\n}\n\nconst unitPopoverFeatures = new Set([\n UnitDetailsFeature.AdjacentUnits,\n UnitDetailsFeature.OutcropType,\n UnitDetailsFeature.DepthRange,\n UnitDetailsFeature.ColumnName,\n]);\n\nexport function CorrelationChart({\n data,\n columnSpacing = 0,\n columnWidth = 130,\n unconformityLabels = true,\n showUnitPopover = true,\n selectedUnit,\n onUnitSelected,\n unitComponent,\n ...scaleProps\n}: CorrelationChartProps) {\n const defaultScaleProps = {\n targetUnitHeight: 10,\n unconformityHeight: 60,\n minSectionHeight: 60,\n collapseSmallUnconformities: true,\n };\n\n const chartData = useMemo(() => {\n if (!data) return null;\n return buildCorrelationChartData(data, {\n ...defaultScaleProps,\n ...scaleProps,\n });\n }, [data, ...Object.values(scaleProps)]);\n\n // A flattened units array is used to support keyboard navigation\n const units = useMemo(() => {\n return data?.map((d0) => d0.units).flat() ?? [];\n }, [data]);\n\n const inDarkMode = useInDarkMode();\n\n const className = classNames({\n \"dark-mode\": inDarkMode,\n });\n\n if (chartData == null) {\n return null;\n }\n\n const { packages, scaleInfo, nColumns } = chartData;\n\n const mainWidth = (columnWidth + columnSpacing) * nColumns;\n\n return h(\n ColumnContainer,\n { className: \"correlation-diagram\" },\n h(\n UnitSelectionProvider,\n { selectedUnit, onUnitSelected, units },\n h(ChartArea, [\n h(TimescaleColumn, {\n key: \"timescale\",\n scaleInfo,\n unconformityLabels,\n }),\n h(MainChartArea, [\n h(\n SVG,\n {\n className,\n innerWidth: mainWidth,\n height: scaleInfo.totalHeight,\n paddingH: 4,\n },\n packages.map((pkg, i) => {\n const { offset, domain, pixelScale, scale, key } =\n scaleInfo.packages[i];\n return h(Package, {\n columnData: pkg.columnData,\n key,\n columnWidth,\n columnSpacing,\n offset,\n domain,\n pixelScale,\n scale,\n unitComponent,\n });\n }),\n ),\n h.if(showUnitPopover)(UnitSelectionPopover, {\n features: unitPopoverFeatures,\n }),\n // Navigation only works within a column for now...\n h(UnitKeyboardNavigation, { columnData: data }),\n ]),\n ]),\n ),\n );\n}\n\nfunction Package({\n columnData,\n columnSpacing,\n columnWidth,\n unitComponent,\n offset,\n domain,\n pixelScale,\n scale,\n}) {\n return h(\"g.package\", { transform: `translate(0 ${offset})` }, [\n // Disable the SVG overlay for now\n //h(PackageSVGOverlay, { data, columnSpacing }),\n h(\"g.column-units\", [\n columnData.map((data, i) => {\n return h(Column, {\n units: data.units,\n unitComponent,\n width: columnWidth,\n key: i,\n domain,\n pixelScale,\n scale,\n offsetLeft: i * (columnWidth + columnSpacing),\n });\n }),\n ]),\n ]);\n}\n\ninterface ColumnProps {\n units: ExtUnit[];\n unitComponent?: React.FunctionComponent<any>;\n unitComponentProps?: any;\n showLabels?: boolean;\n width?: number;\n columnWidth?: number;\n columnSpacing?: number;\n targetUnitHeight?: number;\n offsetLeft?: number;\n domain: [number, number];\n pixelScale: number;\n scale?: ScaleContinuousNumeric<number, number>;\n}\n\nfunction Column(props: ColumnProps) {\n const {\n units,\n width = 150,\n offsetLeft,\n domain,\n pixelScale,\n scale,\n unitComponent = ColoredUnitComponent,\n } = props;\n\n const columnWidth = width;\n\n if (units.length == 0) {\n return null;\n }\n\n return h(\n \"g.section\",\n {\n transform: `translate(${offsetLeft} 0)`,\n },\n h(\n ColumnProvider,\n {\n // Need to tighten up types here...\n divisions: units as any[],\n range: domain,\n scale,\n pixelsPerMeter: pixelScale, // Actually pixels per myr\n axisType: ColumnAxisType.AGE,\n },\n h(UnitBoxes, {\n unitComponent,\n unitComponentProps: {\n nColumns: 2,\n width: columnWidth,\n showLabel: false,\n },\n }),\n ),\n );\n}\n\nfunction PackageSVGOverlay({ data, columnWidth = 100, columnSpacing = 0 }) {\n const { b_age, t_age, bestPixelScale, columnData } = data;\n\n const width = (columnWidth + columnSpacing) * columnData.length;\n const height = Math.ceil((b_age - t_age) * bestPixelScale) + 2;\n\n const extensiveUnits = findLaterallyExtensiveUnits(data);\n\n const scale = (val: number) => {\n return (val - t_age) * bestPixelScale;\n };\n\n return h(\n \"div.package-overlay\",\n { style: { width, height } },\n extensiveUnits.map((d) => {\n return h(LaterallyExtensiveUnit, {\n data: d,\n scale,\n pixelScale: bestPixelScale,\n columnSpacing,\n });\n }),\n );\n}\n\nfunction LaterallyExtensiveUnit({ data, scale, pixelScale, columnSpacing }) {\n const { b_age, t_age, strat_name_long, units } = data;\n // Build boxes by column groups\n const boxes: UnitGroupBox[] = splitStratIntoBoxes(data);\n\n return h(\n \"div.laterally-extensive-unit\",\n boxes.map((d, i) => {\n return h(StratColSpan, {\n scale,\n data: d,\n pixelScale,\n key: i,\n columnSpacing,\n });\n }),\n );\n}\n\nfunction StratColSpan({\n data,\n scale,\n columnWidth = 100,\n columnSpacing = 0,\n pixelScale = 1,\n}) {\n const { startCol, endCol, strat_name_long, t_age, b_age } = data;\n const top = scale(t_age);\n const left = startCol * (columnWidth + columnSpacing);\n const width = (endCol - startCol + 1) * (columnWidth + columnSpacing);\n const height = (b_age - t_age) * pixelScale;\n return h(\n \"div.strat-col-span\",\n { style: { top, height, width, left } },\n strat_name_long,\n );\n}\n\nfunction ChartArea({ children }) {\n const setSelectedUnit = useUnitSelectionDispatch();\n\n return h(\n \"div.correlation-chart-inner\",\n {\n onClick() {\n setSelectedUnit(null, null);\n },\n },\n children,\n );\n}\n\ninterface TimescaleColumnProps {\n scaleInfo: CompositeStratigraphicScaleInfo;\n showLabels?: boolean;\n unconformityLabels?: boolean;\n}\n\nfunction TimescaleColumn(props: TimescaleColumnProps) {\n const { scaleInfo, unconformityLabels = true } = props;\n return h(\"div.column-container.age-axis-container\", [\n h(CompositeAgeAxisCore, { ...scaleInfo }),\n h(CompositeTimescaleCore, { ...scaleInfo, unconformityLabels }),\n ]);\n}\n"],"names":["hyper","styles"],"mappings":";;;;;;;;;;;;;;;;AAsCA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAc7B,SAAS,cAAc,EAAE,YAAY;AACnC,QAAM,YAAY,aAAA;AAClB,SAAO,EAAE,kBAAkB,EAAE,KAAK,UAAA,GAAa,QAAQ;AACzD;AAEA,MAAM,0CAA0B,IAAI;AAAA,EAClC,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AACrB,CAAC;AAEM,SAAS,iBAAiB;AAAA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AEpC;AAAA,MACE;AAAA,MACA;AAAA;AAAA,QAEE,WAAW;AAAA,QACX,OAAO;AAAA,QACP;AAAA,QACA,gBAAgB;AAAA;AAAA,QAChB,UAAU,eAAe;AAAA,MAAA;AAAA,MAE3B,EAAE,WAAW;AAAA,QACX;AAAA,QACA,oBAAoB;AAAA,UAClB,UAAU;AAAA,UACV,OAAO;AAAA,UACP,WAAW;AAAA,QAAA;AAAA,MACb,CACD;AAAA,IAAA;AAAA,EACH;AAEJ;AAkEA,SAAS,UAAU,EAAE,YAAY;AAC/B,QAAM,kBAAkB,yBAAA;AAExB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,UAAU;AACR,wBAAgB,MAAM,IAAI;AAAA,MAC5B;AAAA,IAAA;AAAA,IAEF;AAAA,EAAA;AAEJ;AAQA,SAAS,gBAAgB,OAA6B;AACpD,QAAM,EAAE,WAAW,qBAAqB,KAAA,IAAS;AACjD,SAAO,EAAE,2CAA2C;AAAA,IAClD,EAAE,sBAAsB,EAAE,GAAG,WAAW;AAAA,IACxC,EAAE,wBAAwB,EAAE,GAAG,WAAW,oBAAoB;AAAA,EAAA,CAC/D;AACH;"}
1
+ {"version":3,"file":"main.js","sources":["../../src/correlation-chart/main.ts"],"sourcesContent":["/** Correlation chart */\nimport {\n UnitSelectionProvider,\n UnitKeyboardNavigation,\n useUnitSelectionDispatch,\n useColumnRef,\n} from \"../data-provider\";\nimport { UnitDetailsFeature, UnitSelectionPopover } from \"../unit-details\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport { useMemo } from \"react\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { CompositeTimescaleCore } from \"../section\";\nimport classNames from \"classnames\";\nimport {\n findLaterallyExtensiveUnits,\n splitStratIntoBoxes,\n UnitGroupBox,\n CorrelationChartSettings,\n buildCorrelationChartData,\n} from \"./prepare-data\";\nimport {\n CompositeAgeAxisCore,\n CompositeStratigraphicScaleInfo,\n} from \"../age-axis\";\nimport {\n ColumnAxisType,\n ColumnProvider,\n SVG,\n} from \"@macrostrat/column-components\";\nimport { ColoredUnitComponent } from \"../units\";\nimport { UnitBoxes } from \"../units/boxes\";\nimport { ColumnContainer } from \"../column\";\nimport { ColumnData } from \"../data-provider\";\nimport { BaseUnit } from \"@macrostrat/api-types\";\nimport { ScaleContinuousNumeric } from \"d3-scale\";\nimport { ExtUnit } from \"../prepare-units/types\";\n\nconst h = hyper.styled(styles);\n\nexport interface CorrelationChartProps extends CorrelationChartSettings {\n data: ColumnData[];\n columnWidth?: number;\n columnSpacing?: number;\n targetUnitHeight?: number;\n unconformityLabels?: boolean;\n selectedUnit?: number | null;\n showUnitPopover?: boolean;\n unitComponent?: any;\n onUnitSelected?: (unitID: number | null, unit: BaseUnit | null) => void;\n}\n\nfunction MainChartArea({ children }) {\n const columnRef = useColumnRef();\n return h(\"div.main-chart\", { ref: columnRef }, children);\n}\n\nconst unitPopoverFeatures = new Set([\n UnitDetailsFeature.AdjacentUnits,\n UnitDetailsFeature.OutcropType,\n UnitDetailsFeature.DepthRange,\n UnitDetailsFeature.ColumnName,\n]);\n\nexport function CorrelationChart({\n data,\n columnSpacing = 0,\n columnWidth = 130,\n unconformityLabels = true,\n showUnitPopover = true,\n selectedUnit,\n onUnitSelected,\n unitComponent,\n ...scaleProps\n}: CorrelationChartProps) {\n const defaultScaleProps = {\n targetUnitHeight: 10,\n unconformityHeight: 60,\n minSectionHeight: 60,\n collapseSmallUnconformities: true,\n };\n\n const chartData = useMemo(() => {\n if (!data) return null;\n return buildCorrelationChartData(data, {\n ...defaultScaleProps,\n ...scaleProps,\n });\n }, [data, ...Object.values(scaleProps)]);\n\n // A flattened units array is used to support keyboard navigation\n const units = useMemo(() => {\n return data?.map((d0) => d0.units).flat() ?? [];\n }, [data]);\n\n const inDarkMode = useInDarkMode();\n\n const className = classNames({\n \"dark-mode\": inDarkMode,\n });\n\n if (chartData == null) {\n return null;\n }\n\n const { packages, scaleInfo, nColumns } = chartData;\n\n const mainWidth = (columnWidth + columnSpacing) * nColumns;\n\n return h(\n ColumnContainer,\n { className: \"correlation-diagram\" },\n h(\n UnitSelectionProvider,\n { selectedUnit, onUnitSelected, units },\n h(ChartArea, [\n h(TimescaleColumn, {\n key: \"timescale\",\n scaleInfo,\n unconformityLabels,\n }),\n h(MainChartArea, [\n h(\n SVG,\n {\n className,\n innerWidth: mainWidth,\n height: scaleInfo.totalHeight,\n paddingH: 4,\n },\n packages.map((pkg, i) => {\n const { offset, domain, pixelScale, scale, key } =\n scaleInfo.packages[i];\n return h(Package, {\n columnData: pkg.columnData,\n key,\n columnWidth,\n columnSpacing,\n offset,\n domain,\n pixelScale,\n scale,\n unitComponent,\n });\n }),\n ),\n h.if(showUnitPopover)(UnitSelectionPopover, {\n features: unitPopoverFeatures,\n }),\n // Navigation only works within a column for now...\n h(UnitKeyboardNavigation, { columnData: data }),\n ]),\n ]),\n ),\n );\n}\n\nfunction Package({\n columnData,\n columnSpacing,\n columnWidth,\n unitComponent,\n offset,\n domain,\n pixelScale,\n scale,\n}) {\n return h(\"g.package\", { transform: `translate(0 ${offset})` }, [\n // Disable the SVG overlay for now\n //h(PackageSVGOverlay, { columnData, columnSpacing }),\n h(\"g.column-units\", [\n columnData.map((data, i) => {\n return h(Column, {\n units: data.units,\n unitComponent,\n width: columnWidth,\n key: i,\n domain,\n pixelScale,\n scale,\n offsetLeft: i * (columnWidth + columnSpacing),\n });\n }),\n ]),\n ]);\n}\n\ninterface ColumnProps {\n units: ExtUnit[];\n unitComponent?: React.FunctionComponent<any>;\n unitComponentProps?: any;\n showLabels?: boolean;\n width?: number;\n columnWidth?: number;\n columnSpacing?: number;\n targetUnitHeight?: number;\n offsetLeft?: number;\n domain: [number, number];\n pixelScale: number;\n scale?: ScaleContinuousNumeric<number, number>;\n}\n\nfunction Column(props: ColumnProps) {\n const {\n units,\n width = 150,\n offsetLeft,\n domain,\n pixelScale,\n scale,\n unitComponent = ColoredUnitComponent,\n } = props;\n\n const columnWidth = width;\n\n if (units.length == 0) {\n return null;\n }\n\n return h(\n \"g.section\",\n {\n transform: `translate(${offsetLeft} 0)`,\n },\n h(\n ColumnProvider,\n {\n // Need to tighten up types here...\n divisions: units as any[],\n range: domain,\n scale,\n pixelsPerMeter: pixelScale, // Actually pixels per myr\n axisType: ColumnAxisType.AGE,\n },\n h(UnitBoxes, {\n unitComponent,\n unitComponentProps: {\n nColumns: 2,\n width: columnWidth,\n showLabel: true,\n },\n }),\n ),\n );\n}\n\nfunction PackageSVGOverlay({ data, columnWidth = 100, columnSpacing = 0 }) {\n const { b_age, t_age, bestPixelScale, columnData } = data;\n\n const width = (columnWidth + columnSpacing) * columnData.length;\n const height = Math.ceil((b_age - t_age) * bestPixelScale) + 2;\n\n const extensiveUnits = findLaterallyExtensiveUnits(data);\n\n const scale = (val: number) => {\n return (val - t_age) * bestPixelScale;\n };\n\n return h(\n \"div.package-overlay\",\n { style: { width, height } },\n extensiveUnits.map((d) => {\n return h(LaterallyExtensiveUnit, {\n data: d,\n scale,\n pixelScale: bestPixelScale,\n columnSpacing,\n });\n }),\n );\n}\n\nfunction LaterallyExtensiveUnit({ data, scale, pixelScale, columnSpacing }) {\n const { b_age, t_age, strat_name_long, units } = data;\n // Build boxes by column groups\n const boxes: UnitGroupBox[] = splitStratIntoBoxes(data);\n\n return h(\n \"div.laterally-extensive-unit\",\n boxes.map((d, i) => {\n return h(StratColSpan, {\n scale,\n data: d,\n pixelScale,\n key: i,\n columnSpacing,\n });\n }),\n );\n}\n\nfunction StratColSpan({\n data,\n scale,\n columnWidth = 100,\n columnSpacing = 0,\n pixelScale = 1,\n}) {\n const { startCol, endCol, strat_name_long, t_age, b_age } = data;\n const top = scale(t_age);\n const left = startCol * (columnWidth + columnSpacing);\n const width = (endCol - startCol + 1) * (columnWidth + columnSpacing);\n const height = (b_age - t_age) * pixelScale;\n return h(\n \"div.strat-col-span\",\n { style: { top, height, width, left } },\n strat_name_long,\n );\n}\n\nfunction ChartArea({ children }) {\n const setSelectedUnit = useUnitSelectionDispatch();\n\n return h(\n \"div.correlation-chart-inner\",\n {\n onClick() {\n setSelectedUnit(null, null);\n },\n },\n children,\n );\n}\n\ninterface TimescaleColumnProps {\n scaleInfo: CompositeStratigraphicScaleInfo;\n showLabels?: boolean;\n unconformityLabels?: boolean;\n}\n\nfunction TimescaleColumn(props: TimescaleColumnProps) {\n const { scaleInfo, unconformityLabels = true } = props;\n return h(\"div.column-container.age-axis-container\", [\n h(CompositeAgeAxisCore, { ...scaleInfo }),\n h(CompositeTimescaleCore, { ...scaleInfo, unconformityLabels }),\n ]);\n}\n"],"names":["hyper","styles"],"mappings":";;;;;;;;;;;;;;;;AAsCA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAc7B,SAAS,cAAc,EAAE,YAAY;AACnC,QAAM,YAAY,aAAA;AAClB,SAAO,EAAE,kBAAkB,EAAE,KAAK,UAAA,GAAa,QAAQ;AACzD;AAEA,MAAM,0CAA0B,IAAI;AAAA,EAClC,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AACrB,CAAC;AAEM,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA0B;AACxB,QAAM,oBAAoB;AAAA,IACxB,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB,kBAAkB;AAAA,IAClB,6BAA6B;AAAA,EAAA;AAG/B,QAAM,YAAY,QAAQ,MAAM;AAC9B,QAAI,CAAC,KAAM,QAAO;AAClB,WAAO,0BAA0B,MAAM;AAAA,MACrC,GAAG;AAAA,MACH,GAAG;AAAA,IAAA,CACJ;AAAA,EACH,GAAG,CAAC,MAAM,GAAG,OAAO,OAAO,UAAU,CAAC,CAAC;AAGvC,QAAM,QAAQ,QAAQ,MAAM;AAC1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,gBAAgB,OAA6B;AACpD,QAAM,EAAE,WAAW,qBAAqB,KAAA,IAAS;AACjD,SAAO,EAAE,2CAA2C;AAAA,IAClD,EAAE,sBAAsB,EAAE,GAAG,WAAW;AAAA,IACxC,EAAE,wBAAwB,EAAE,GAAG,WAAW,oBAAoB;AAAA,EAAA,CAC/D;AACH;"}
@@ -1,5 +1,5 @@
1
1
  import { CompositeStratigraphicScaleInfo } from '../age-axis';
2
- import { ColumnGeoJSONRecord, UnitLong } from '@macrostrat/api-types';
2
+ import { ColumnGeoJSONRecord, UnitLong } from '../../../api-types/src/index.ts';
3
3
  import { PrepareColumnOptions } from '../prepare-units';
4
4
  export interface ColumnIdentifier {
5
5
  col_id: number;
@@ -1,5 +1,5 @@
1
1
  export declare function useCorrelationLine(): {
2
- focusedLine: import('geojson').LineString;
2
+ focusedLine: import('geojson').LineString | null;
3
3
  setFocusedLine: (line: any) => void;
4
4
  selectedUnit: any;
5
5
  setSelectedUnit: (selectedUnit: any) => void;
@@ -9,5 +9,5 @@ export declare function useColumnNav(defaultArgs?: ColumnArgs): ColumnManagerDat
9
9
  export declare function ColumnNavProvider({ children, ...defaultArgs }: {
10
10
  [x: string]: any;
11
11
  children: any;
12
- }): import('react').FunctionComponentElement<import('react').ProviderProps<ColumnManagerData>>;
12
+ }): import('react').FunctionComponentElement<import('react').ProviderProps<ColumnManagerData | null>>;
13
13
  export {};
@@ -30,7 +30,7 @@ const selectedUnitAtom = jotai.atom(
30
30
  if (!get(allowUnitSelectionAtom)) {
31
31
  console.error("Unit selection is disabled.");
32
32
  }
33
- let unitID;
33
+ let unitID = null;
34
34
  let unit = null;
35
35
  if (selectedUnit == null) {
36
36
  unitID = null;
@@ -1 +1 @@
1
- {"version":3,"file":"unit-selection.cjs","sources":["../../src/data-provider/unit-selection.ts"],"sourcesContent":["import type { BaseUnit, UnitLong } from \"@macrostrat/api-types\";\nimport { useKeyHandler } from \"@macrostrat/ui-components\";\nimport { useEffect, useRef, useCallback, useMemo } from \"react\";\nimport type { RectBounds, IUnit } from \"../units/types\";\nimport { atom } from \"jotai\";\nimport { scope, columnUnitsMapAtom } from \"./store\";\nimport {\n AgeRangeQuantifiedDifference,\n ageRangeQuantifiedDifference,\n AgeRangeRelationship,\n} from \"@macrostrat/stratigraphy-utils\";\nimport type { ColumnData } from \"@macrostrat/data-provider\";\n\ntype UnitSelectDispatch = (\n unit: number | BaseUnit | null,\n target: HTMLElement | null,\n) => void;\n\nexport function useUnitSelectionDispatch(): UnitSelectDispatch {\n return scope.useSetAtom(selectedUnitAtom);\n}\n\nexport function useSelectedUnit() {\n return scope.useAtomValue(selectedUnitAtom);\n}\n\nexport interface ColumnClickData {\n unitID: number | null;\n unit: BaseUnit | null;\n target: HTMLElement | null;\n height: number;\n // Room for boundary IDs eventually\n}\n\nexport interface UnitSelectionCallbacks {\n // It's sort of unfortunate that we need to pass in the column ref here\n onClickedColumn?: (columnClickData: ColumnClickData, event: Event) => void;\n onUnitSelected?: <T extends BaseUnit>(\n unitID: number | null,\n unit: T | null,\n ) => void;\n}\n\nexport const allowUnitSelectionAtom = atom<boolean>(true);\n\nexport const selectedUnitIDAtom = atom<number | null>();\n\nconst overlayPositionAtom = atom<RectBounds | null>();\n\nconst columnRefAtom = atom<{ current: HTMLElement | null }>({ current: null });\n\nexport function useColumnRef() {\n return scope.useAtomValue(columnRefAtom);\n}\n\nconst selectedUnitAtom = atom(\n (get) => {\n if (!get(allowUnitSelectionAtom)) return null;\n\n const unitID = get(selectedUnitIDAtom);\n if (unitID == null) return null;\n const unitsMap = get(columnUnitsMapAtom);\n return unitsMap?.get(unitID) || null;\n },\n (\n get,\n set,\n selectedUnit: number | BaseUnit | null,\n target: HTMLElement | null = null,\n ): BaseUnit | null => {\n if (!get(allowUnitSelectionAtom)) {\n console.error(\"Unit selection is disabled.\");\n }\n\n let unitID: number | null;\n let unit: BaseUnit | null = null;\n if (selectedUnit == null) {\n unitID = null;\n } else if (typeof selectedUnit === \"number\") {\n unitID = selectedUnit;\n } else if (\"unit_id\" in selectedUnit) {\n unitID = selectedUnit.unit_id;\n }\n\n if (unitID != null) {\n // Verify that the unit exists in the current colum, else throw\n const unitsMap = get(columnUnitsMapAtom);\n if (!unitsMap?.has(unitID)) {\n throw new Error(\n `Unit with ID ${unitID} not found in current column units.`,\n );\n }\n unit = unitsMap.get(unitID) ?? null;\n }\n\n let overlayPosition: RectBounds | null = null;\n\n const columnEl = get(columnRefAtom)?.current;\n\n if (unit != null && columnEl != null && target != null) {\n const rect = columnEl.getBoundingClientRect();\n const targetRect = target.getBoundingClientRect();\n overlayPosition = {\n x: targetRect.left - rect.left,\n y: targetRect.top - rect.top,\n width: targetRect.width,\n height: targetRect.height,\n };\n }\n\n set(selectedUnitIDAtom, unitID);\n set(overlayPositionAtom, overlayPosition);\n\n return unit;\n },\n);\n\nexport function useAtomOverlayPosition() {\n return scope.useAtomValue(overlayPositionAtom);\n}\n\nexport function UnitSelectionCallbackManager({\n onUnitSelected,\n}: UnitSelectionCallbacks) {\n const selectedUnit = scope.useAtomValue(selectedUnitAtom);\n useEffect(() => {\n onUnitSelected?.(selectedUnit?.unit_id ?? null, selectedUnit ?? null);\n }, [selectedUnit?.unit_id]);\n return null;\n}\n\n/** TODO: figure out if onClickedColumn is still needed\n /** This is not the natural place to get positions within the column,\n * but it will work for now.\nif (props.onClickedColumn) {\n // Infer height from top and bottom height of unit (because that's passed back with the call)\n //const py = event.y;\n //const [bottom, top] = getUnitHeightRange(unit, axisType);\n //const height = Math.abs(bottom - top);\n\n const columnClickData: ColumnClickData = {\n unitID: unit?.unit_id,\n unit,\n target,\n height: el?.getBoundingClientRect().height || 0,\n };\n props.onClickedColumn(columnClickData, event);\n}*/\n\nexport function useUnitSelectionTarget(\n unit: IUnit,\n): [React.RefObject<HTMLElement>, boolean, (evt: Event) => void] {\n const ref = useRef<HTMLElement>();\n const selectedUnit = useSelectedUnit();\n const selectUnit = useUnitSelectionDispatch();\n const selected = selectedUnit?.unit_id == unit.unit_id;\n\n const onClick = useCallback(\n (evt: Event) => {\n selectUnit?.(unit, ref.current);\n evt.stopPropagation();\n },\n [unit, selectUnit],\n );\n\n useEffect(() => {\n if (!selected || selectUnit == null) return;\n // In case we haven't set the position of the unit (if we don't have a target), set the selected unit\n selectUnit(unit, ref.current);\n\n // Scroll the unit into view\n ref.current?.scrollIntoView({\n behavior: \"smooth\",\n block: \"center\",\n inline: \"nearest\",\n });\n }, [selected, selectUnit]);\n\n return [ref, selected, onClick];\n}\n\nexport function UnitKeyboardNavigation({\n columnData,\n units,\n allowHorizontalNavigation,\n}: {\n columnData?: ColumnData[];\n units?: UnitLong[];\n allowHorizontalNavigation?: boolean;\n}) {\n if (units == null && columnData == null) {\n throw new Error(\"Either units or columnData must be provided.\");\n }\n\n let _columnData: ColumnData[] = useMemo(() => {\n if (columnData != null) return columnData;\n // Build column data from units\n const colMap = new Map<number, UnitLong[]>();\n for (const unit of units!) {\n if (!colMap.has(unit.col_id)) {\n colMap.set(unit.col_id, []);\n }\n colMap.get(unit.col_id)!.push(unit);\n }\n const cols: ColumnData[] = [];\n for (const [colID, units] of colMap) {\n cols.push({ columnID: colID, units });\n }\n // Sort columns by columnID\n cols.sort((a, b) => a.columnID - b.columnID);\n return cols;\n }, [columnData, units]);\n\n // Default to allowing horizontal navigation only if columnData is provided\n const _allowHorizontalNavigation =\n allowHorizontalNavigation ?? columnData != null;\n\n const selectedUnit = useSelectedUnit() as UnitLong | null;\n const selectUnit = useUnitSelectionDispatch();\n\n const keyMap: Record<number, Direction> = {\n 38: \"up\",\n 40: \"down\",\n };\n if (_allowHorizontalNavigation) {\n keyMap[37] = \"left\";\n keyMap[39] = \"right\";\n }\n\n useKeyHandler(\n (event) => {\n const direction = keyMap[event.keyCode];\n if (direction == null) return;\n const nextUnit = getBestUnit(_columnData, selectedUnit, direction);\n if (nextUnit == null) return;\n selectUnit(nextUnit, null);\n event.stopPropagation();\n },\n [_columnData, selectedUnit],\n );\n return null;\n}\n\ntype Direction = \"up\" | \"down\" | \"left\" | \"right\";\n\nfunction getBestUnit(\n columnData: ColumnData[],\n targetUnit: UnitLong,\n direction: Direction,\n): UnitLong | null {\n const thisColIndex = columnData.findIndex(\n (col) => col.columnID === targetUnit.col_id,\n );\n if (thisColIndex === -1) return null;\n\n // If up or down, stay in the same column\n if (direction === \"up\" || direction === \"down\") {\n const units = columnData[thisColIndex].units;\n const ix = units.findIndex((unit) => unit.unit_id === targetUnit.unit_id);\n if (ix === -1) return null;\n if (direction === \"up\") {\n return units[ix - 1] || null;\n } else {\n return units[ix + 1] || null;\n }\n }\n\n // If left or right, move to adjacent column\n let adjacentColIndex: number;\n if (direction === \"left\") {\n adjacentColIndex =\n (thisColIndex - 1 + columnData.length) % columnData.length;\n } else {\n adjacentColIndex = (thisColIndex + 1) % columnData.length;\n }\n\n const adjacentColUnits = columnData[adjacentColIndex].units;\n return getMostOverlappingUnit(targetUnit, adjacentColUnits);\n}\n\ntype UnitAgeRangeRelationship = AgeRangeQuantifiedDifference & {\n unit: UnitLong;\n};\n\nfunction getMostOverlappingUnit(\n targetUnit: UnitLong,\n candidateUnits: UnitLong[],\n): UnitLong | null {\n const targetAgeRange = [targetUnit.b_age, targetUnit.t_age];\n\n const overlaps: UnitAgeRangeRelationship[] = [];\n for (const candidate of candidateUnits) {\n const candidateAgeRange = [candidate.b_age, candidate.t_age];\n\n const rel = ageRangeQuantifiedDifference(targetAgeRange, candidateAgeRange);\n if (rel.type === AgeRangeRelationship.Identical) {\n return candidate;\n }\n overlaps.push({ ...rel, unit: candidate });\n }\n\n let bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.Containing,\n );\n bestOverlaps.sort((a, b) => b.overlap - a.overlap);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n\n bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.Contained,\n );\n bestOverlaps.sort((a, b) => b.overlap - a.overlap);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n\n bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.PartialOverlap,\n );\n bestOverlaps.sort((a, b) => b.overlap - a.overlap);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n\n bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.Disjoint,\n );\n bestOverlaps.sort((a, b) => a.distance - b.distance);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n return null;\n}\n"],"names":["scope","atom","columnUnitsMapAtom","useEffect","useRef","useCallback","useMemo","units","useKeyHandler","ageRangeQuantifiedDifference","AgeRangeRelationship"],"mappings":";;;;;;;AAkBO,SAAS,2BAA+C;AAC7D,SAAOA,MAAAA,MAAM,WAAW,gBAAgB;AAC1C;AAEO,SAAS,kBAAkB;AAChC,SAAOA,MAAAA,MAAM,aAAa,gBAAgB;AAC5C;AAmBO,MAAM,yBAAyBC,MAAAA,KAAc,IAAI;AAEjD,MAAM,qBAAqBA,MAAAA,KAAA;AAElC,MAAM,sBAAsBA,MAAAA,KAAA;AAE5B,MAAM,gBAAgBA,MAAAA,KAAsC,EAAE,SAAS,MAAM;AAEtE,SAAS,eAAe;AAC7B,SAAOD,MAAAA,MAAM,aAAa,aAAa;AACzC;AAEA,MAAM,mBAAmBC,MAAAA;AAAAA,EACvB,CAAC,QAAQ;AACP,QAAI,CAAC,IAAI,sBAAsB,EAAG,QAAO;AAEzC,UAAM,SAAS,IAAI,kBAAkB;AACrC,QAAI,UAAU,KAAM,QAAO;AAC3B,UAAM,WAAW,IAAIC,wBAAkB;AACvC,WAAO,UAAU,IAAI,MAAM,KAAK;AAAA,EAClC;AAAA,EACA,CACE,KACA,KACA,cACA,SAA6B,SACT;AACpB,QAAI,CAAC,IAAI,sBAAsB,GAAG;AAChC,cAAQ,MAAM,6BAA6B;AAAA,IAC7C;AAEA,QAAI;AACJ,QAAI,OAAwB;AAC5B,QAAI,gBAAgB,MAAM;AACxB,eAAS;AAAA,IACX,WAAW,O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AAgB,iBAAiB;AAC1E,QAAI,IAAI,SAASC,kBAAAA,qBAAqB,WAAW;AAC/C,aAAO;AAAA,IACT;AACA,aAAS,KAAK,EAAE,GAAG,KAAK,MAAM,WAAW;AAAA,EAC3C;AAEA,MAAI,eAAe,SAAS;AAAA,IAC1B,CAAC,MAAM,EAAE,SAASA,uCAAqB;AAAA,EAAA;AAEzC,eAAa,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,OAAO;AACjD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO,aAAa,CAAC,EAAE;AAAA,EACzB;AAEA,iBAAe,SAAS;AAAA,IACtB,CAAC,MAAM,EAAE,SAASA,uCAAqB;AAAA,EAAA;AAEzC,eAAa,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,OAAO;AACjD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO,aAAa,CAAC,EAAE;AAAA,EACzB;AAEA,iBAAe,SAAS;AAAA,IACtB,CAAC,MAAM,EAAE,SAASA,uCAAqB;AAAA,EAAA;AAEzC,eAAa,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,OAAO;AACjD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO,aAAa,CAAC,EAAE;AAAA,EACzB;AAEA,iBAAe,SAAS;AAAA,IACtB,CAAC,MAAM,EAAE,SAASA,uCAAqB;AAAA,EAAA;AAEzC,eAAa,KAAK,CAAC,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;AACnD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO,aAAa,CAAC,EAAE;AAAA,EACzB;AACA,SAAO;AACT;;;;;;;;;;"}
1
+ {"version":3,"file":"unit-selection.cjs","sources":["../../src/data-provider/unit-selection.ts"],"sourcesContent":["import type { BaseUnit, UnitLong } from \"@macrostrat/api-types\";\nimport { useKeyHandler } from \"@macrostrat/ui-components\";\nimport { useEffect, useRef, useCallback, useMemo } from \"react\";\nimport type { RectBounds, IUnit } from \"../units/types\";\nimport { atom } from \"jotai\";\nimport { scope, columnUnitsMapAtom } from \"./store\";\nimport {\n AgeRangeQuantifiedDifference,\n ageRangeQuantifiedDifference,\n AgeRangeRelationship,\n} from \"@macrostrat/stratigraphy-utils\";\nimport type { ColumnData } from \"@macrostrat/data-provider\";\n\ntype UnitSelectDispatch = (\n unit: number | BaseUnit | null,\n target: HTMLElement | null,\n) => void;\n\nexport function useUnitSelectionDispatch(): UnitSelectDispatch {\n return scope.useSetAtom(selectedUnitAtom);\n}\n\nexport function useSelectedUnit() {\n return scope.useAtomValue(selectedUnitAtom);\n}\n\nexport interface ColumnClickData {\n unitID: number | null;\n unit: BaseUnit | null;\n target: HTMLElement | null;\n height: number;\n // Room for boundary IDs eventually\n}\n\nexport interface UnitSelectionCallbacks {\n // It's sort of unfortunate that we need to pass in the column ref here\n onClickedColumn?: (columnClickData: ColumnClickData, event: Event) => void;\n onUnitSelected?: <T extends BaseUnit>(\n unitID: number | null,\n unit: T | null,\n ) => void;\n}\n\nexport const allowUnitSelectionAtom = atom<boolean>(true);\n\nexport const selectedUnitIDAtom = atom<number | null>();\n\nconst overlayPositionAtom = atom<RectBounds | null>();\n\nconst columnRefAtom = atom<{ current: HTMLElement | null }>({ current: null });\n\nexport function useColumnRef() {\n return scope.useAtomValue(columnRefAtom);\n}\n\nconst selectedUnitAtom = atom(\n (get) => {\n if (!get(allowUnitSelectionAtom)) return null;\n\n const unitID = get(selectedUnitIDAtom);\n if (unitID == null) return null;\n const unitsMap = get(columnUnitsMapAtom);\n return unitsMap?.get(unitID) || null;\n },\n (\n get,\n set,\n selectedUnit: number | BaseUnit | null,\n target: HTMLElement | null = null,\n ): BaseUnit | null => {\n if (!get(allowUnitSelectionAtom)) {\n console.error(\"Unit selection is disabled.\");\n }\n\n let unitID: number | null = null;\n let unit: BaseUnit | null = null;\n if (selectedUnit == null) {\n unitID = null;\n } else if (typeof selectedUnit === \"number\") {\n unitID = selectedUnit;\n } else if (\"unit_id\" in selectedUnit) {\n unitID = selectedUnit.unit_id;\n }\n\n if (unitID != null) {\n // Verify that the unit exists in the current colum, else throw\n const unitsMap = get(columnUnitsMapAtom);\n if (!unitsMap?.has(unitID)) {\n throw new Error(\n `Unit with ID ${unitID} not found in current column units.`,\n );\n }\n unit = unitsMap.get(unitID) ?? null;\n }\n\n let overlayPosition: RectBounds | null = null;\n\n const columnEl = get(columnRefAtom)?.current;\n\n if (unit != null && columnEl != null && target != null) {\n const rect = columnEl.getBoundingClientRect();\n const targetRect = target.getBoundingClientRect();\n overlayPosition = {\n x: targetRect.left - rect.left,\n y: targetRect.top - rect.top,\n width: targetRect.width,\n height: targetRect.height,\n };\n }\n\n set(selectedUnitIDAtom, unitID);\n set(overlayPositionAtom, overlayPosition);\n\n return unit;\n },\n);\n\nexport function useAtomOverlayPosition() {\n return scope.useAtomValue(overlayPositionAtom);\n}\n\nexport function UnitSelectionCallbackManager({\n onUnitSelected,\n}: UnitSelectionCallbacks) {\n const selectedUnit = scope.useAtomValue(selectedUnitAtom);\n useEffect(() => {\n onUnitSelected?.(selectedUnit?.unit_id ?? null, selectedUnit ?? null);\n }, [selectedUnit?.unit_id]);\n return null;\n}\n\n/** TODO: figure out if onClickedColumn is still needed\n /** This is not the natural place to get positions within the column,\n * but it will work for now.\nif (props.onClickedColumn) {\n // Infer height from top and bottom height of unit (because that's passed back with the call)\n //const py = event.y;\n //const [bottom, top] = getUnitHeightRange(unit, axisType);\n //const height = Math.abs(bottom - top);\n\n const columnClickData: ColumnClickData = {\n unitID: unit?.unit_id,\n unit,\n target,\n height: el?.getBoundingClientRect().height || 0,\n };\n props.onClickedColumn(columnClickData, event);\n}*/\n\nexport function useUnitSelectionTarget(\n unit: IUnit,\n): [React.RefObject<HTMLElement>, boolean, (evt: Event) => void] {\n const ref = useRef<HTMLElement>();\n const selectedUnit = useSelectedUnit();\n const selectUnit = useUnitSelectionDispatch();\n const selected = selectedUnit?.unit_id == unit.unit_id;\n\n const onClick = useCallback(\n (evt: Event) => {\n selectUnit?.(unit, ref.current);\n evt.stopPropagation();\n },\n [unit, selectUnit],\n );\n\n useEffect(() => {\n if (!selected || selectUnit == null) return;\n // In case we haven't set the position of the unit (if we don't have a target), set the selected unit\n selectUnit(unit, ref.current);\n\n // Scroll the unit into view\n ref.current?.scrollIntoView({\n behavior: \"smooth\",\n block: \"center\",\n inline: \"nearest\",\n });\n }, [selected, selectUnit]);\n\n return [ref, selected, onClick];\n}\n\nexport function UnitKeyboardNavigation({\n columnData,\n units,\n allowHorizontalNavigation,\n}: {\n columnData?: ColumnData[];\n units?: UnitLong[];\n allowHorizontalNavigation?: boolean;\n}) {\n if (units == null && columnData == null) {\n throw new Error(\"Either units or columnData must be provided.\");\n }\n\n let _columnData: ColumnData[] = useMemo(() => {\n if (columnData != null) return columnData;\n // Build column data from units\n const colMap = new Map<number, UnitLong[]>();\n for (const unit of units!) {\n if (!colMap.has(unit.col_id)) {\n colMap.set(unit.col_id, []);\n }\n colMap.get(unit.col_id)!.push(unit);\n }\n const cols: ColumnData[] = [];\n for (const [colID, units] of colMap) {\n cols.push({ columnID: colID, units });\n }\n // Sort columns by columnID\n cols.sort((a, b) => a.columnID - b.columnID);\n return cols;\n }, [columnData, units]);\n\n // Default to allowing horizontal navigation only if columnData is provided\n const _allowHorizontalNavigation =\n allowHorizontalNavigation ?? columnData != null;\n\n const selectedUnit = useSelectedUnit() as UnitLong | null;\n const selectUnit = useUnitSelectionDispatch();\n\n const keyMap: Record<number, Direction> = {\n 38: \"up\",\n 40: \"down\",\n };\n if (_allowHorizontalNavigation) {\n keyMap[37] = \"left\";\n keyMap[39] = \"right\";\n }\n\n useKeyHandler(\n (event) => {\n const direction = keyMap[event.keyCode];\n if (direction == null) return;\n const nextUnit = getBestUnit(_columnData, selectedUnit, direction);\n if (nextUnit == null) return;\n selectUnit(nextUnit, null);\n event.stopPropagation();\n },\n [_columnData, selectedUnit],\n );\n return null;\n}\n\ntype Direction = \"up\" | \"down\" | \"left\" | \"right\";\n\nfunction getBestUnit(\n columnData: ColumnData[],\n targetUnit: UnitLong,\n direction: Direction,\n): UnitLong | null {\n const thisColIndex = columnData.findIndex(\n (col) => col.columnID === targetUnit.col_id,\n );\n if (thisColIndex === -1) return null;\n\n // If up or down, stay in the same column\n if (direction === \"up\" || direction === \"down\") {\n const units = columnData[thisColIndex].units;\n const ix = units.findIndex((unit) => unit.unit_id === targetUnit.unit_id);\n if (ix === -1) return null;\n if (direction === \"up\") {\n return units[ix - 1] || null;\n } else {\n return units[ix + 1] || null;\n }\n }\n\n // If left or right, move to adjacent column\n let adjacentColIndex: number;\n if (direction === \"left\") {\n adjacentColIndex =\n (thisColIndex - 1 + columnData.length) % columnData.length;\n } else {\n adjacentColIndex = (thisColIndex + 1) % columnData.length;\n }\n\n const adjacentColUnits = columnData[adjacentColIndex].units;\n return getMostOverlappingUnit(targetUnit, adjacentColUnits);\n}\n\ntype UnitAgeRangeRelationship = AgeRangeQuantifiedDifference & {\n unit: UnitLong;\n};\n\nfunction getMostOverlappingUnit(\n targetUnit: UnitLong,\n candidateUnits: UnitLong[],\n): UnitLong | null {\n const targetAgeRange = [targetUnit.b_age, targetUnit.t_age];\n\n const overlaps: UnitAgeRangeRelationship[] = [];\n for (const candidate of candidateUnits) {\n const candidateAgeRange = [candidate.b_age, candidate.t_age];\n\n const rel = ageRangeQuantifiedDifference(targetAgeRange, candidateAgeRange);\n if (rel.type === AgeRangeRelationship.Identical) {\n return candidate;\n }\n overlaps.push({ ...rel, unit: candidate });\n }\n\n let bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.Containing,\n );\n bestOverlaps.sort((a, b) => b.overlap - a.overlap);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n\n bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.Contained,\n );\n bestOverlaps.sort((a, b) => b.overlap - a.overlap);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n\n bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.PartialOverlap,\n );\n bestOverlaps.sort((a, b) => b.overlap - a.overlap);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n\n bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.Disjoint,\n );\n bestOverlaps.sort((a, b) => a.distance - b.distance);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n return null;\n}\n"],"names":["scope","atom","columnUnitsMapAtom","useEffect","useRef","useCallback","useMemo","units","useKeyHandler","ageRangeQuantifiedDifference","AgeRangeRelationship"],"mappings":";;;;;;;AAkBO,SAAS,2BAA+C;AAC7D,SAAOA,MAAAA,MAAM,WAAW,gBAAgB;AAC1C;AAEO,SAAS,kBAAkB;AAChC,SAAOA,MAAAA,MAAM,aAAa,gBAAgB;AAC5C;AAmBO,MAAM,yBAAyBC,MAAAA,KAAc,IAAI;AAEjD,MAAM,qBAAqBA,MAAAA,KAAA;AAElC,MAAM,sBAAsBA,MAAAA,KAAA;AAE5B,MAAM,gBAAgBA,MAAAA,KAAsC,EAAE,SAAS,MAAM;AAEtE,SAAS,eAAe;AAC7B,SAAOD,MAAAA,MAAM,aAAa,aAAa;AACzC;AAEA,MAAM,mBAAmBC,MAAAA;AAAAA,EACvB,CAAC,QAAQ;AACP,QAAI,CAAC,IAAI,sBAAsB,EAAG,QAAO;AAEzC,UAAM,SAAS,IAAI,kBAAkB;AACrC,QAAI,UAAU,KAAM,QAAO;AAC3B,UAAM,WAAW,IAAIC,wBAAkB;AACvC,WAAO,UAAU,IAAI,MAAM,KAAK;AAAA,EAClC;AAAA,EACA,CACE,KACA,KACA,cACA,SAA6B,SACT;AACpB,QAAI,CAAC,IAAI,sBAAsB,GAAG;AAChC,cAAQ,MAAM,6BAA6B;AAAA,IAC7C;AAEA,QAAI,SAAwB;AAC5B,QAAI,OAAwB;AAC5B,QAAI,gBAAgB,MAAM;AACxB,eAAS;AAAA,IACX,WAAW,OAAO,iBAAiB,UAAU;AAC3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AI,IAAI,SAASC,kBAAAA,qBAAqB,WAAW;AAC/C,aAAO;AAAA,IACT;AACA,aAAS,KAAK,EAAE,GAAG,KAAK,MAAM,WAAW;AAAA,EAC3C;AAEA,MAAI,eAAe,SAAS;AAAA,IAC1B,CAAC,MAAM,EAAE,SAASA,uCAAqB;AAAA,EAAA;AAEzC,eAAa,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,OAAO;AACjD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO,aAAa,CAAC,EAAE;AAAA,EACzB;AAEA,iBAAe,SAAS;AAAA,IACtB,CAAC,MAAM,EAAE,SAASA,uCAAqB;AAAA,EAAA;AAEzC,eAAa,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,OAAO;AACjD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO,aAAa,CAAC,EAAE;AAAA,EACzB;AAEA,iBAAe,SAAS;AAAA,IACtB,CAAC,MAAM,EAAE,SAASA,uCAAqB;AAAA,EAAA;AAEzC,eAAa,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,OAAO;AACjD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO,aAAa,CAAC,EAAE;AAAA,EACzB;AAEA,iBAAe,SAAS;AAAA,IACtB,CAAC,MAAM,EAAE,SAASA,uCAAqB;AAAA,EAAA;AAEzC,eAAa,KAAK,CAAC,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;AACnD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO,aAAa,CAAC,EAAE;AAAA,EACzB;AACA,SAAO;AACT;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
- import { BaseUnit, UnitLong } from '@macrostrat/api-types';
1
+ import { BaseUnit, UnitLong } from '../../../api-types/src/index.ts';
2
2
  import { IUnit } from '../units/types';
3
- import { ColumnData } from '@macrostrat/data-provider';
3
+ import { ColumnData } from '../../../data-provider/src/index.ts';
4
4
  type UnitSelectDispatch = (unit: number | BaseUnit | null, target: HTMLElement | null) => void;
5
5
  export declare function useUnitSelectionDispatch(): UnitSelectDispatch;
6
6
  export declare function useSelectedUnit(): any;
@@ -17,12 +17,12 @@ export interface UnitSelectionCallbacks {
17
17
  export declare const allowUnitSelectionAtom: import('jotai').PrimitiveAtom<boolean> & {
18
18
  init: boolean;
19
19
  };
20
- export declare const selectedUnitIDAtom: import('jotai').PrimitiveAtom<number> & {
21
- init: number;
20
+ export declare const selectedUnitIDAtom: import('jotai').PrimitiveAtom<number | null | undefined> & {
21
+ init: number | null | undefined;
22
22
  };
23
23
  export declare function useColumnRef(): any;
24
24
  export declare function useAtomOverlayPosition(): any;
25
- export declare function UnitSelectionCallbackManager({ onUnitSelected, }: UnitSelectionCallbacks): any;
25
+ export declare function UnitSelectionCallbackManager({ onUnitSelected, }: UnitSelectionCallbacks): null;
26
26
  /** TODO: figure out if onClickedColumn is still needed
27
27
  /** This is not the natural place to get positions within the column,
28
28
  * but it will work for now.
@@ -45,5 +45,5 @@ export declare function UnitKeyboardNavigation({ columnData, units, allowHorizon
45
45
  columnData?: ColumnData[];
46
46
  units?: UnitLong[];
47
47
  allowHorizontalNavigation?: boolean;
48
- }): any;
48
+ }): null;
49
49
  export {};
@@ -28,7 +28,7 @@ const selectedUnitAtom = atom(
28
28
  if (!get(allowUnitSelectionAtom)) {
29
29
  console.error("Unit selection is disabled.");
30
30
  }
31
- let unitID;
31
+ let unitID = null;
32
32
  let unit = null;
33
33
  if (selectedUnit == null) {
34
34
  unitID = null;
@@ -1 +1 @@
1
- {"version":3,"file":"unit-selection.js","sources":["../../src/data-provider/unit-selection.ts"],"sourcesContent":["import type { BaseUnit, UnitLong } from \"@macrostrat/api-types\";\nimport { useKeyHandler } from \"@macrostrat/ui-components\";\nimport { useEffect, useRef, useCallback, useMemo } from \"react\";\nimport type { RectBounds, IUnit } from \"../units/types\";\nimport { atom } from \"jotai\";\nimport { scope, columnUnitsMapAtom } from \"./store\";\nimport {\n AgeRangeQuantifiedDifference,\n ageRangeQuantifiedDifference,\n AgeRangeRelationship,\n} from \"@macrostrat/stratigraphy-utils\";\nimport type { ColumnData } from \"@macrostrat/data-provider\";\n\ntype UnitSelectDispatch = (\n unit: number | BaseUnit | null,\n target: HTMLElement | null,\n) => void;\n\nexport function useUnitSelectionDispatch(): UnitSelectDispatch {\n return scope.useSetAtom(selectedUnitAtom);\n}\n\nexport function useSelectedUnit() {\n return scope.useAtomValue(selectedUnitAtom);\n}\n\nexport interface ColumnClickData {\n unitID: number | null;\n unit: BaseUnit | null;\n target: HTMLElement | null;\n height: number;\n // Room for boundary IDs eventually\n}\n\nexport interface UnitSelectionCallbacks {\n // It's sort of unfortunate that we need to pass in the column ref here\n onClickedColumn?: (columnClickData: ColumnClickData, event: Event) => void;\n onUnitSelected?: <T extends BaseUnit>(\n unitID: number | null,\n unit: T | null,\n ) => void;\n}\n\nexport const allowUnitSelectionAtom = atom<boolean>(true);\n\nexport const selectedUnitIDAtom = atom<number | null>();\n\nconst overlayPositionAtom = atom<RectBounds | null>();\n\nconst columnRefAtom = atom<{ current: HTMLElement | null }>({ current: null });\n\nexport function useColumnRef() {\n return scope.useAtomValue(columnRefAtom);\n}\n\nconst selectedUnitAtom = atom(\n (get) => {\n if (!get(allowUnitSelectionAtom)) return null;\n\n const unitID = get(selectedUnitIDAtom);\n if (unitID == null) return null;\n const unitsMap = get(columnUnitsMapAtom);\n return unitsMap?.get(unitID) || null;\n },\n (\n get,\n set,\n selectedUnit: number | BaseUnit | null,\n target: HTMLElement | null = null,\n ): BaseUnit | null => {\n if (!get(allowUnitSelectionAtom)) {\n console.error(\"Unit selection is disabled.\");\n }\n\n let unitID: number | null;\n let unit: BaseUnit | null = null;\n if (selectedUnit == null) {\n unitID = null;\n } else if (typeof selectedUnit === \"number\") {\n unitID = selectedUnit;\n } else if (\"unit_id\" in selectedUnit) {\n unitID = selectedUnit.unit_id;\n }\n\n if (unitID != null) {\n // Verify that the unit exists in the current colum, else throw\n const unitsMap = get(columnUnitsMapAtom);\n if (!unitsMap?.has(unitID)) {\n throw new Error(\n `Unit with ID ${unitID} not found in current column units.`,\n );\n }\n unit = unitsMap.get(unitID) ?? null;\n }\n\n let overlayPosition: RectBounds | null = null;\n\n const columnEl = get(columnRefAtom)?.current;\n\n if (unit != null && columnEl != null && target != null) {\n const rect = columnEl.getBoundingClientRect();\n const targetRect = target.getBoundingClientRect();\n overlayPosition = {\n x: targetRect.left - rect.left,\n y: targetRect.top - rect.top,\n width: targetRect.width,\n height: targetRect.height,\n };\n }\n\n set(selectedUnitIDAtom, unitID);\n set(overlayPositionAtom, overlayPosition);\n\n return unit;\n },\n);\n\nexport function useAtomOverlayPosition() {\n return scope.useAtomValue(overlayPositionAtom);\n}\n\nexport function UnitSelectionCallbackManager({\n onUnitSelected,\n}: UnitSelectionCallbacks) {\n const selectedUnit = scope.useAtomValue(selectedUnitAtom);\n useEffect(() => {\n onUnitSelected?.(selectedUnit?.unit_id ?? null, selectedUnit ?? null);\n }, [selectedUnit?.unit_id]);\n return null;\n}\n\n/** TODO: figure out if onClickedColumn is still needed\n /** This is not the natural place to get positions within the column,\n * but it will work for now.\nif (props.onClickedColumn) {\n // Infer height from top and bottom height of unit (because that's passed back with the call)\n //const py = event.y;\n //const [bottom, top] = getUnitHeightRange(unit, axisType);\n //const height = Math.abs(bottom - top);\n\n const columnClickData: ColumnClickData = {\n unitID: unit?.unit_id,\n unit,\n target,\n height: el?.getBoundingClientRect().height || 0,\n };\n props.onClickedColumn(columnClickData, event);\n}*/\n\nexport function useUnitSelectionTarget(\n unit: IUnit,\n): [React.RefObject<HTMLElement>, boolean, (evt: Event) => void] {\n const ref = useRef<HTMLElement>();\n const selectedUnit = useSelectedUnit();\n const selectUnit = useUnitSelectionDispatch();\n const selected = selectedUnit?.unit_id == unit.unit_id;\n\n const onClick = useCallback(\n (evt: Event) => {\n selectUnit?.(unit, ref.current);\n evt.stopPropagation();\n },\n [unit, selectUnit],\n );\n\n useEffect(() => {\n if (!selected || selectUnit == null) return;\n // In case we haven't set the position of the unit (if we don't have a target), set the selected unit\n selectUnit(unit, ref.current);\n\n // Scroll the unit into view\n ref.current?.scrollIntoView({\n behavior: \"smooth\",\n block: \"center\",\n inline: \"nearest\",\n });\n }, [selected, selectUnit]);\n\n return [ref, selected, onClick];\n}\n\nexport function UnitKeyboardNavigation({\n columnData,\n units,\n allowHorizontalNavigation,\n}: {\n columnData?: ColumnData[];\n units?: UnitLong[];\n allowHorizontalNavigation?: boolean;\n}) {\n if (units == null && columnData == null) {\n throw new Error(\"Either units or columnData must be provided.\");\n }\n\n let _columnData: ColumnData[] = useMemo(() => {\n if (columnData != null) return columnData;\n // Build column data from units\n const colMap = new Map<number, UnitLong[]>();\n for (const unit of units!) {\n if (!colMap.has(unit.col_id)) {\n colMap.set(unit.col_id, []);\n }\n colMap.get(unit.col_id)!.push(unit);\n }\n const cols: ColumnData[] = [];\n for (const [colID, units] of colMap) {\n cols.push({ columnID: colID, units });\n }\n // Sort columns by columnID\n cols.sort((a, b) => a.columnID - b.columnID);\n return cols;\n }, [columnData, units]);\n\n // Default to allowing horizontal navigation only if columnData is provided\n const _allowHorizontalNavigation =\n allowHorizontalNavigation ?? columnData != null;\n\n const selectedUnit = useSelectedUnit() as UnitLong | null;\n const selectUnit = useUnitSelectionDispatch();\n\n const keyMap: Record<number, Direction> = {\n 38: \"up\",\n 40: \"down\",\n };\n if (_allowHorizontalNavigation) {\n keyMap[37] = \"left\";\n keyMap[39] = \"right\";\n }\n\n useKeyHandler(\n (event) => {\n const direction = keyMap[event.keyCode];\n if (direction == null) return;\n const nextUnit = getBestUnit(_columnData, selectedUnit, direction);\n if (nextUnit == null) return;\n selectUnit(nextUnit, null);\n event.stopPropagation();\n },\n [_columnData, selectedUnit],\n );\n return null;\n}\n\ntype Direction = \"up\" | \"down\" | \"left\" | \"right\";\n\nfunction getBestUnit(\n columnData: ColumnData[],\n targetUnit: UnitLong,\n direction: Direction,\n): UnitLong | null {\n const thisColIndex = columnData.findIndex(\n (col) => col.columnID === targetUnit.col_id,\n );\n if (thisColIndex === -1) return null;\n\n // If up or down, stay in the same column\n if (direction === \"up\" || direction === \"down\") {\n const units = columnData[thisColIndex].units;\n const ix = units.findIndex((unit) => unit.unit_id === targetUnit.unit_id);\n if (ix === -1) return null;\n if (direction === \"up\") {\n return units[ix - 1] || null;\n } else {\n return units[ix + 1] || null;\n }\n }\n\n // If left or right, move to adjacent column\n let adjacentColIndex: number;\n if (direction === \"left\") {\n adjacentColIndex =\n (thisColIndex - 1 + columnData.length) % columnData.length;\n } else {\n adjacentColIndex = (thisColIndex + 1) % columnData.length;\n }\n\n const adjacentColUnits = columnData[adjacentColIndex].units;\n return getMostOverlappingUnit(targetUnit, adjacentColUnits);\n}\n\ntype UnitAgeRangeRelationship = AgeRangeQuantifiedDifference & {\n unit: UnitLong;\n};\n\nfunction getMostOverlappingUnit(\n targetUnit: UnitLong,\n candidateUnits: UnitLong[],\n): UnitLong | null {\n const targetAgeRange = [targetUnit.b_age, targetUnit.t_age];\n\n const overlaps: UnitAgeRangeRelationship[] = [];\n for (const candidate of candidateUnits) {\n const candidateAgeRange = [candidate.b_age, candidate.t_age];\n\n const rel = ageRangeQuantifiedDifference(targetAgeRange, candidateAgeRange);\n if (rel.type === AgeRangeRelationship.Identical) {\n return candidate;\n }\n overlaps.push({ ...rel, unit: candidate });\n }\n\n let bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.Containing,\n );\n bestOverlaps.sort((a, b) => b.overlap - a.overlap);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n\n bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.Contained,\n );\n bestOverlaps.sort((a, b) => b.overlap - a.overlap);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n\n bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.PartialOverlap,\n );\n bestOverlaps.sort((a, b) => b.overlap - a.overlap);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n\n bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.Disjoint,\n );\n bestOverlaps.sort((a, b) => a.distance - b.distance);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n return null;\n}\n"],"names":["units"],"mappings":";;;;;AAkBO,SAAS,2BAA+C;AAC7D,SAAO,MAAM,WAAW,gBAAgB;AAC1C;AAEO,SAAS,kBAAkB;AAChC,SAAO,MAAM,aAAa,gBAAgB;AAC5C;AAmBO,MAAM,yBAAyB,KAAc,IAAI;AAEjD,MAAM,qBAAqB,KAAA;AAElC,MAAM,sBAAsB,KAAA;AAE5B,MAAM,gBAAgB,KAAsC,EAAE,SAAS,MAAM;AAEtE,SAAS,eAAe;AAC7B,SAAO,MAAM,aAAa,aAAa;AACzC;AAEA,MAAM,mBAAmB;AAAA,EACvB,CAAC,QAAQ;AACP,QAAI,CAAC,IAAI,sBAAsB,EAAG,QAAO;AAEzC,UAAM,SAAS,IAAI,kBAAkB;AACrC,QAAI,UAAU,KAAM,QAAO;AAC3B,UAAM,WAAW,IAAI,kBAAkB;AACvC,WAAO,UAAU,IAAI,MAAM,KAAK;AAAA,EAClC;AAAA,EACA,CACE,KACA,KACA,cACA,SAA6B,SACT;AACpB,QAAI,CAAC,IAAI,sBAAsB,GAAG;AAChC,cAAQ,MAAM,6BAA6B;AAAA,IAC7C;AAEA,QAAI;AACJ,QAAI,OAAwB;AAC5B,QAAI,gBAAgB,MAAM;AACxB,eAAS;AAAA,IACX,WAAW,OAAO,iBAAiB,UAAU;AAC3C,eAAS;AAAA,IACX,WAAW,aAAa,cAAc;AACpC,eAAS,aAAa;AAAA,IACxB;AAEA,QAAI,UAAU,MAAM;AAElB,YAAM,WAAW,IAAI,kBAAkB;AACvC,UAAI,CAAC,UAAU,IAAI,MAAM,GAAG;AAC1B,cAAM,IAAI;AAAA,UACR,gBAAgB,MAAM;AAAA,QAAA;AAAA,MAE1B;AACA,aAAO,SAAS,IAA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iBAAe,SAAS;AAAA,IACtB,CAAC,MAAM,EAAE,SAAS,qBAAqB;AAAA,EAAA;AAEzC,eAAa,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,OAAO;AACjD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO,aAAa,CAAC,EAAE;AAAA,EACzB;AAEA,iBAAe,SAAS;AAAA,IACtB,CAAC,MAAM,EAAE,SAAS,qBAAqB;AAAA,EAAA;AAEzC,eAAa,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,OAAO;AACjD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO,aAAa,CAAC,EAAE;AAAA,EACzB;AAEA,iBAAe,SAAS;AAAA,IACtB,CAAC,MAAM,EAAE,SAAS,qBAAqB;AAAA,EAAA;AAEzC,eAAa,KAAK,CAAC,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;AACnD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO,aAAa,CAAC,EAAE;AAAA,EACzB;AACA,SAAO;AACT;"}
1
+ {"version":3,"file":"unit-selection.js","sources":["../../src/data-provider/unit-selection.ts"],"sourcesContent":["import type { BaseUnit, UnitLong } from \"@macrostrat/api-types\";\nimport { useKeyHandler } from \"@macrostrat/ui-components\";\nimport { useEffect, useRef, useCallback, useMemo } from \"react\";\nimport type { RectBounds, IUnit } from \"../units/types\";\nimport { atom } from \"jotai\";\nimport { scope, columnUnitsMapAtom } from \"./store\";\nimport {\n AgeRangeQuantifiedDifference,\n ageRangeQuantifiedDifference,\n AgeRangeRelationship,\n} from \"@macrostrat/stratigraphy-utils\";\nimport type { ColumnData } from \"@macrostrat/data-provider\";\n\ntype UnitSelectDispatch = (\n unit: number | BaseUnit | null,\n target: HTMLElement | null,\n) => void;\n\nexport function useUnitSelectionDispatch(): UnitSelectDispatch {\n return scope.useSetAtom(selectedUnitAtom);\n}\n\nexport function useSelectedUnit() {\n return scope.useAtomValue(selectedUnitAtom);\n}\n\nexport interface ColumnClickData {\n unitID: number | null;\n unit: BaseUnit | null;\n target: HTMLElement | null;\n height: number;\n // Room for boundary IDs eventually\n}\n\nexport interface UnitSelectionCallbacks {\n // It's sort of unfortunate that we need to pass in the column ref here\n onClickedColumn?: (columnClickData: ColumnClickData, event: Event) => void;\n onUnitSelected?: <T extends BaseUnit>(\n unitID: number | null,\n unit: T | null,\n ) => void;\n}\n\nexport const allowUnitSelectionAtom = atom<boolean>(true);\n\nexport const selectedUnitIDAtom = atom<number | null>();\n\nconst overlayPositionAtom = atom<RectBounds | null>();\n\nconst columnRefAtom = atom<{ current: HTMLElement | null }>({ current: null });\n\nexport function useColumnRef() {\n return scope.useAtomValue(columnRefAtom);\n}\n\nconst selectedUnitAtom = atom(\n (get) => {\n if (!get(allowUnitSelectionAtom)) return null;\n\n const unitID = get(selectedUnitIDAtom);\n if (unitID == null) return null;\n const unitsMap = get(columnUnitsMapAtom);\n return unitsMap?.get(unitID) || null;\n },\n (\n get,\n set,\n selectedUnit: number | BaseUnit | null,\n target: HTMLElement | null = null,\n ): BaseUnit | null => {\n if (!get(allowUnitSelectionAtom)) {\n console.error(\"Unit selection is disabled.\");\n }\n\n let unitID: number | null = null;\n let unit: BaseUnit | null = null;\n if (selectedUnit == null) {\n unitID = null;\n } else if (typeof selectedUnit === \"number\") {\n unitID = selectedUnit;\n } else if (\"unit_id\" in selectedUnit) {\n unitID = selectedUnit.unit_id;\n }\n\n if (unitID != null) {\n // Verify that the unit exists in the current colum, else throw\n const unitsMap = get(columnUnitsMapAtom);\n if (!unitsMap?.has(unitID)) {\n throw new Error(\n `Unit with ID ${unitID} not found in current column units.`,\n );\n }\n unit = unitsMap.get(unitID) ?? null;\n }\n\n let overlayPosition: RectBounds | null = null;\n\n const columnEl = get(columnRefAtom)?.current;\n\n if (unit != null && columnEl != null && target != null) {\n const rect = columnEl.getBoundingClientRect();\n const targetRect = target.getBoundingClientRect();\n overlayPosition = {\n x: targetRect.left - rect.left,\n y: targetRect.top - rect.top,\n width: targetRect.width,\n height: targetRect.height,\n };\n }\n\n set(selectedUnitIDAtom, unitID);\n set(overlayPositionAtom, overlayPosition);\n\n return unit;\n },\n);\n\nexport function useAtomOverlayPosition() {\n return scope.useAtomValue(overlayPositionAtom);\n}\n\nexport function UnitSelectionCallbackManager({\n onUnitSelected,\n}: UnitSelectionCallbacks) {\n const selectedUnit = scope.useAtomValue(selectedUnitAtom);\n useEffect(() => {\n onUnitSelected?.(selectedUnit?.unit_id ?? null, selectedUnit ?? null);\n }, [selectedUnit?.unit_id]);\n return null;\n}\n\n/** TODO: figure out if onClickedColumn is still needed\n /** This is not the natural place to get positions within the column,\n * but it will work for now.\nif (props.onClickedColumn) {\n // Infer height from top and bottom height of unit (because that's passed back with the call)\n //const py = event.y;\n //const [bottom, top] = getUnitHeightRange(unit, axisType);\n //const height = Math.abs(bottom - top);\n\n const columnClickData: ColumnClickData = {\n unitID: unit?.unit_id,\n unit,\n target,\n height: el?.getBoundingClientRect().height || 0,\n };\n props.onClickedColumn(columnClickData, event);\n}*/\n\nexport function useUnitSelectionTarget(\n unit: IUnit,\n): [React.RefObject<HTMLElement>, boolean, (evt: Event) => void] {\n const ref = useRef<HTMLElement>();\n const selectedUnit = useSelectedUnit();\n const selectUnit = useUnitSelectionDispatch();\n const selected = selectedUnit?.unit_id == unit.unit_id;\n\n const onClick = useCallback(\n (evt: Event) => {\n selectUnit?.(unit, ref.current);\n evt.stopPropagation();\n },\n [unit, selectUnit],\n );\n\n useEffect(() => {\n if (!selected || selectUnit == null) return;\n // In case we haven't set the position of the unit (if we don't have a target), set the selected unit\n selectUnit(unit, ref.current);\n\n // Scroll the unit into view\n ref.current?.scrollIntoView({\n behavior: \"smooth\",\n block: \"center\",\n inline: \"nearest\",\n });\n }, [selected, selectUnit]);\n\n return [ref, selected, onClick];\n}\n\nexport function UnitKeyboardNavigation({\n columnData,\n units,\n allowHorizontalNavigation,\n}: {\n columnData?: ColumnData[];\n units?: UnitLong[];\n allowHorizontalNavigation?: boolean;\n}) {\n if (units == null && columnData == null) {\n throw new Error(\"Either units or columnData must be provided.\");\n }\n\n let _columnData: ColumnData[] = useMemo(() => {\n if (columnData != null) return columnData;\n // Build column data from units\n const colMap = new Map<number, UnitLong[]>();\n for (const unit of units!) {\n if (!colMap.has(unit.col_id)) {\n colMap.set(unit.col_id, []);\n }\n colMap.get(unit.col_id)!.push(unit);\n }\n const cols: ColumnData[] = [];\n for (const [colID, units] of colMap) {\n cols.push({ columnID: colID, units });\n }\n // Sort columns by columnID\n cols.sort((a, b) => a.columnID - b.columnID);\n return cols;\n }, [columnData, units]);\n\n // Default to allowing horizontal navigation only if columnData is provided\n const _allowHorizontalNavigation =\n allowHorizontalNavigation ?? columnData != null;\n\n const selectedUnit = useSelectedUnit() as UnitLong | null;\n const selectUnit = useUnitSelectionDispatch();\n\n const keyMap: Record<number, Direction> = {\n 38: \"up\",\n 40: \"down\",\n };\n if (_allowHorizontalNavigation) {\n keyMap[37] = \"left\";\n keyMap[39] = \"right\";\n }\n\n useKeyHandler(\n (event) => {\n const direction = keyMap[event.keyCode];\n if (direction == null) return;\n const nextUnit = getBestUnit(_columnData, selectedUnit, direction);\n if (nextUnit == null) return;\n selectUnit(nextUnit, null);\n event.stopPropagation();\n },\n [_columnData, selectedUnit],\n );\n return null;\n}\n\ntype Direction = \"up\" | \"down\" | \"left\" | \"right\";\n\nfunction getBestUnit(\n columnData: ColumnData[],\n targetUnit: UnitLong,\n direction: Direction,\n): UnitLong | null {\n const thisColIndex = columnData.findIndex(\n (col) => col.columnID === targetUnit.col_id,\n );\n if (thisColIndex === -1) return null;\n\n // If up or down, stay in the same column\n if (direction === \"up\" || direction === \"down\") {\n const units = columnData[thisColIndex].units;\n const ix = units.findIndex((unit) => unit.unit_id === targetUnit.unit_id);\n if (ix === -1) return null;\n if (direction === \"up\") {\n return units[ix - 1] || null;\n } else {\n return units[ix + 1] || null;\n }\n }\n\n // If left or right, move to adjacent column\n let adjacentColIndex: number;\n if (direction === \"left\") {\n adjacentColIndex =\n (thisColIndex - 1 + columnData.length) % columnData.length;\n } else {\n adjacentColIndex = (thisColIndex + 1) % columnData.length;\n }\n\n const adjacentColUnits = columnData[adjacentColIndex].units;\n return getMostOverlappingUnit(targetUnit, adjacentColUnits);\n}\n\ntype UnitAgeRangeRelationship = AgeRangeQuantifiedDifference & {\n unit: UnitLong;\n};\n\nfunction getMostOverlappingUnit(\n targetUnit: UnitLong,\n candidateUnits: UnitLong[],\n): UnitLong | null {\n const targetAgeRange = [targetUnit.b_age, targetUnit.t_age];\n\n const overlaps: UnitAgeRangeRelationship[] = [];\n for (const candidate of candidateUnits) {\n const candidateAgeRange = [candidate.b_age, candidate.t_age];\n\n const rel = ageRangeQuantifiedDifference(targetAgeRange, candidateAgeRange);\n if (rel.type === AgeRangeRelationship.Identical) {\n return candidate;\n }\n overlaps.push({ ...rel, unit: candidate });\n }\n\n let bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.Containing,\n );\n bestOverlaps.sort((a, b) => b.overlap - a.overlap);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n\n bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.Contained,\n );\n bestOverlaps.sort((a, b) => b.overlap - a.overlap);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n\n bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.PartialOverlap,\n );\n bestOverlaps.sort((a, b) => b.overlap - a.overlap);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n\n bestOverlaps = overlaps.filter(\n (d) => d.type === AgeRangeRelationship.Disjoint,\n );\n bestOverlaps.sort((a, b) => a.distance - b.distance);\n if (bestOverlaps.length > 0) {\n return bestOverlaps[0].unit;\n }\n return null;\n}\n"],"names":["units"],"mappings":";;;;;AAkBO,SAAS,2BAA+C;AAC7D,SAAO,MAAM,WAAW,gBAAgB;AAC1C;AAEO,SAAS,kBAAkB;AAChC,SAAO,MAAM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zC,eAAa,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,OAAO;AACjD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO,aAAa,CAAC,EAAE;AAAA,EACzB;AAEA,iBAAe,SAAS;AAAA,IACtB,CAAC,MAAM,EAAE,SAAS,qBAAqB;AAAA,EAAA;AAEzC,eAAa,KAAK,CAAC,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;AACnD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO,aAAa,CAAC,EAAE;AAAA,EACzB;AACA,SAAO;AACT;"}
@@ -6,8 +6,8 @@ export interface DataAreaProps {
6
6
  children: React.ReactNode;
7
7
  getHeight?: Function;
8
8
  }
9
- declare const IsotopesDataArea: (props: DataAreaProps) => import('react').FunctionComponentElement<import('react').ProviderProps<any>>;
10
- declare const IsotopeDataPoint: (props: any) => import('react').DOMElement<any, Element>;
9
+ declare const IsotopesDataArea: (props: DataAreaProps) => import('react').DetailedReactHTMLElement<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
10
+ declare const IsotopeDataPoint: (props: any) => import('react').DOMElement<any, Element> | null;
11
11
  declare const IsotopeDataLine: (props: any) => import('react').DOMElement<any, Element>;
12
- declare const useDataLocator: () => any;
12
+ declare const useDataLocator: () => null;
13
13
  export { IsotopesDataArea, IsotopeDataPoint, IsotopeDataLine, useDataLocator };
@@ -1,4 +1,4 @@
1
- declare const MeasurementDataContext: import('react').Context<any>;
2
- export declare function MeasurementDataProvider(props: any): import('react').FunctionComponentElement<import('react').ProviderProps<any>>;
3
- declare const useMeasurementData: () => any;
1
+ declare const MeasurementDataContext: import('react').Context<null>;
2
+ export declare function MeasurementDataProvider(props: any): import('react').DetailedReactHTMLElement<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
3
+ declare const useMeasurementData: () => null;
4
4
  export { useMeasurementData, MeasurementDataContext };
@@ -16,7 +16,7 @@ interface DZMeasurementInfo extends ColumnMeasurementData<MeasurementInfo[]> {
16
16
  }
17
17
  declare function DetritalColumn({ columnID, color }: {
18
18
  columnID: any;
19
- color?: string;
19
+ color?: string | undefined;
20
20
  }): import('react').FunctionComponentElement<import('@blueprintjs/core').NonIdealStateProps> | import('react').FunctionComponentElement<import('..').BaseMeasurementsColumnProps<any>>;
21
21
  declare function DetritalGroup(props: DetritalItemProps): import('react').ReactElement<{
22
22
  className: string;
@@ -28,4 +28,4 @@ export interface MeasurementInfo {
28
28
  sample_no: string[];
29
29
  error_units: string;
30
30
  }
31
- export declare function useDetritalMeasurements(columnArgs: any): MeasurementInfo[];
31
+ export declare function useDetritalMeasurements(columnArgs: any): MeasurementInfo[] | null;
@@ -4,4 +4,4 @@ export * from './taxon-ranges';
4
4
  export declare function PBDBFossilsColumn({ columnID, type, }: {
5
5
  columnID: number;
6
6
  type: FossilDataType;
7
- }): import('react').FunctionComponentElement<import('..').BaseMeasurementsColumnProps<any>>;
7
+ }): import('react').FunctionComponentElement<import('..').BaseMeasurementsColumnProps<any>> | null;
@@ -1,3 +1,3 @@
1
1
  export declare function PBDBOccurrencesMatrix({ columnID }: {
2
2
  columnID: any;
3
- }): import('react').DetailedReactHTMLElement<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
3
+ }): import('react').FunctionComponentElement<import('ui-box').BoxProps<import('react').ElementType<any, keyof import("react").JSX.IntrinsicElements>>> | null;
@@ -1,6 +1,6 @@
1
1
  import { CompositeColumnScale } from '../../prepare-units';
2
- import { UnitLong } from '@macrostrat/api-types';
3
- import { ColumnAxisType } from '@macrostrat/column-components';
2
+ import { UnitLong } from '../../../../api-types/src/index.ts';
3
+ import { ColumnAxisType } from '../../../../column-components/src/index.ts';
4
4
  type GetHeightRangeFn<T> = (data: T, unit: UnitLong | null, axisType: ColumnAxisType) => MeasurementHeightData;
5
5
  export interface BaseMeasurementsColumnProps<T> {
6
6
  data: T[];
@@ -29,8 +29,8 @@ export type MeasurementHeightData = {
29
29
  top_height?: number | null;
30
30
  };
31
31
  export declare function BaseMeasurementsColumn({ data, noteComponent, width, paddingLeft, className, deltaConnectorAttachment, focusedNoteComponent, }: BaseMeasurementsColumnProps<any>): import('react').ReactElement<{
32
- className: string;
33
- }, string | import('react').JSXElementConstructor<any>>;
32
+ className: string | undefined;
33
+ }, string | import('react').JSXElementConstructor<any>> | null;
34
34
  interface TruncatedListProps {
35
35
  data: any[];
36
36
  className?: string;
@@ -40,7 +40,7 @@ interface TruncatedListProps {
40
40
  }) => any;
41
41
  }
42
42
  export declare function TruncatedList({ data, className, maxItems, itemRenderer, }: TruncatedListProps): import('react').ReactElement<{
43
- className: string;
43
+ className: string | undefined;
44
44
  }, string | import('react').JSXElementConstructor<any>>;
45
45
  export declare function groupNotesByPixelDistance<T = any>(data: ColumnMeasurementData<T[]>[], scale: CompositeColumnScale, axisType: ColumnAxisType, groupDistance: number): ColumnMeasurementData<T[]>[];
46
46
  export {};
@@ -1,3 +1,3 @@
1
1
  export declare function SGPMeasurementsColumn({ columnID }: {
2
2
  columnID: any;
3
- }): import('react').FunctionComponentElement<import('./base').BaseMeasurementsColumnProps<any>>;
3
+ }): import('react').FunctionComponentElement<import('./base').BaseMeasurementsColumnProps<any>> | null;
@@ -1,6 +1,6 @@
1
1
  import { LineString, Point } from 'geojson';
2
2
  import { StoreApi } from 'zustand';
3
- import { ColumnGeoJSONRecord } from '@macrostrat/api-types';
3
+ import { ColumnGeoJSONRecord } from '../../../../api-types/src/index.ts';
4
4
  import { ReactNode } from 'react';
5
5
  export interface CorrelationMapInput {
6
6
  columns: ColumnGeoJSONRecord[];
@@ -20,7 +20,7 @@ export interface CorrelationProviderProps extends CorrelationMapInput {
20
20
  type ComputedStore = {
21
21
  focusedColumns: FocusedColumnGeoJSONRecord[];
22
22
  };
23
- export declare function ColumnCorrelationProvider({ children, columns, projectID, inProcess, focusedLine, onSelectColumns, }: CorrelationProviderProps): import('react').FunctionComponentElement<import('react').ProviderProps<StoreApi<CorrelationMapStore>>>;
23
+ export declare function ColumnCorrelationProvider({ children, columns, projectID, inProcess, focusedLine, onSelectColumns, }: CorrelationProviderProps): import('react').FunctionComponentElement<import('react').ProviderProps<StoreApi<CorrelationMapStore> | null>>;
24
24
  export declare function useCorrelationMapStore(selector: (state: CorrelationMapStore & ComputedStore) => any): any;
25
25
  interface FocusedColumnGeoJSONRecord extends ColumnGeoJSONRecord {
26
26
  properties: {
@@ -3,6 +3,6 @@ interface KeyboardNavProps {
3
3
  showTriangulation: boolean;
4
4
  triangulationColor?: string;
5
5
  }
6
- export declare function ColumnKeyboardNavigation(props: KeyboardNavProps): any;
6
+ export declare function ColumnKeyboardNavigation(props: KeyboardNavProps): null;
7
7
  export declare function buildKeyboardNavigationStyle(color?: string): Partial<StyleSpecification>;
8
8
  export {};
@@ -1,5 +1,5 @@
1
1
  import { StoreApi } from 'zustand';
2
- import { ColumnGeoJSONRecordWithID } from '@macrostrat/api-types';
2
+ import { ColumnGeoJSONRecordWithID } from '../../../../../api-types/src/index.ts';
3
3
  import { ReactNode } from 'react';
4
4
  export interface NavigationStore {
5
5
  columns: ColumnGeoJSONRecordWithID[];
@@ -19,5 +19,5 @@ export interface NavigationProviderProps {
19
19
  onSelectColumn?: (col_id: number | null, column: any) => void;
20
20
  onHoverColumn?: (col_id: number | null, column: any) => void;
21
21
  }
22
- export declare function ColumnNavigationProvider({ children, columns, columnIDs, selectedColumn, projectID, inProcess, onSelectColumn, onHoverColumn, }: NavigationProviderProps): import('react').FunctionComponentElement<import('react').ProviderProps<StoreApi<NavigationStore>>>;
22
+ export declare function ColumnNavigationProvider({ children, columns, columnIDs, selectedColumn, projectID, inProcess, onSelectColumn, onHoverColumn, }: NavigationProviderProps): import('react').FunctionComponentElement<import('react').ProviderProps<StoreApi<NavigationStore> | null>>;
23
23
  export declare function useColumnNavigationStore(selector: (state: NavigationStore) => any): any;
@@ -3,4 +3,4 @@ export declare function useColumnFeatures({ status_code, project_id, format, }:
3
3
  status_code?: string;
4
4
  project_id?: number;
5
5
  format?: "geojson" | "topojson" | "geojson_bare";
6
- }): import('@macrostrat/api-types').ColumnGeoJSONRecord[];
6
+ }): import('../../../../../api-types/src/index.ts').ColumnGeoJSONRecord[] | null;
@@ -1,5 +1,5 @@
1
1
  export declare function ResizableMapFrame(props: any): import('react').ReactElement<{
2
- ref: import('react').MutableRefObject<any>;
2
+ ref: import('react').RefObject<null>;
3
3
  style: any;
4
4
  className: any;
5
5
  }, string | import('react').JSXElementConstructor<any>>;
@@ -3,11 +3,11 @@ import { Polygon } from 'geojson';
3
3
  export declare function MeasurementsLayer(props: any): import('react').FunctionComponentElement<{
4
4
  [k: string]: any;
5
5
  geometry?: object;
6
- features?: import('@macrostrat/svg-map-components').IFeature[];
6
+ features?: import('../../../../../svg-map-components/src/index.ts').IFeature[];
7
7
  useCanvas?: boolean;
8
8
  } & {
9
9
  children?: import('react').ReactNode | undefined;
10
- }>;
10
+ }> | null;
11
11
  type ColumnProps = {
12
12
  col_id: number;
13
13
  };
@@ -15,7 +15,7 @@ type ColumnFeature = ExtendedFeature<Polygon, ColumnProps>;
15
15
  declare function ColumnFeatures(props: any): import('react').FunctionComponentElement<{
16
16
  [k: string]: any;
17
17
  geometry?: object;
18
- features?: import('@macrostrat/svg-map-components').IFeature[];
18
+ features?: import('../../../../../svg-map-components/src/index.ts').IFeature[];
19
19
  useCanvas?: boolean;
20
20
  } & {
21
21
  children?: import('react').ReactNode | undefined;
@@ -33,7 +33,7 @@ interface KeyboardNavProps extends ColumnNavProps {
33
33
  features: ColumnFeature[];
34
34
  showLayers: boolean;
35
35
  }
36
- declare function ColumnKeyboardNavigation(props: KeyboardNavProps): import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>>;
36
+ declare function ColumnKeyboardNavigation(props: KeyboardNavProps): import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | null;
37
37
  interface ColumnExtraInfo {
38
38
  apiRoute?: string;
39
39
  color?: string;
@@ -41,12 +41,12 @@ interface ColumnExtraInfo {
41
41
  showDebugLayers?: boolean;
42
42
  format?: "topojson" | "geojson";
43
43
  }
44
- declare const Columns: (props: ColumnNavProps & ColumnExtraInfo) => import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>>;
44
+ declare const Columns: (props: ColumnNavProps & ColumnExtraInfo) => import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | null;
45
45
  declare const ColumnCenters: (props: ColumnNavProps) => import('react').FunctionComponentElement<ColumnNavProps & ColumnExtraInfo>;
46
46
  declare const CurrentColumn: (props: any) => import('react').FunctionComponentElement<{
47
47
  [k: string]: any;
48
48
  geometry?: object;
49
- features?: import('@macrostrat/svg-map-components').IFeature[];
49
+ features?: import('../../../../../svg-map-components/src/index.ts').IFeature[];
50
50
  useCanvas?: boolean;
51
51
  } & {
52
52
  children?: import('react').ReactNode | undefined;
@@ -3,7 +3,7 @@ export declare function buildKeyMapping(neighbors: any, centroids: any, currentI
3
3
  38: any;
4
4
  39: any;
5
5
  40: any;
6
- };
6
+ } | undefined;
7
7
  export declare function buildTriangulation(features: any): {
8
8
  centroids: any;
9
9
  tri: any;
@@ -1,4 +1,4 @@
1
- import { MapViewProps } from '@macrostrat/map-interface';
1
+ import { MapViewProps } from '../../../../map-interface/src/index.ts';
2
2
  import { ReactNode, CSSProperties } from 'react';
3
3
  export interface InsetMapProps extends Omit<MapViewProps, "style"> {
4
4
  controls?: ReactNode;
@@ -11,6 +11,6 @@ export interface InsetMapProps extends Omit<MapViewProps, "style"> {
11
11
  showRoads?: boolean;
12
12
  }
13
13
  export declare function InsetMap({ controls, className, children, style, mapStyle, accessToken, showLabels, showAdmin, showRoads, ...rest }: InsetMapProps): import('react').ReactElement<{
14
- className: string;
15
- style: CSSProperties;
14
+ className: string | undefined;
15
+ style: CSSProperties | undefined;
16
16
  }, string | import('react').JSXElementConstructor<any>>;
@@ -1,6 +1,6 @@
1
1
  import { default as GeoJSON, FeatureCollection } from 'geojson';
2
2
  import { GeoJSONFeature } from 'mapbox-gl';
3
- import { StyleFragment } from '@macrostrat/mapbox-react';
3
+ import { StyleFragment } from '../../../../mapbox-react/src/index.ts';
4
4
  export interface ColumnsStyleOptions {
5
5
  color?: string | any[];
6
6
  selectedColor?: string | any[];
@@ -14,14 +14,14 @@ interface ColumnLayerOptions extends ColumnsStyleOptions {
14
14
  enabled: boolean;
15
15
  columns: FeatureCollection | GeoJSONFeature[];
16
16
  }
17
- export declare function BaseColumnsLayer({ enabled, columns, ...rest }: ColumnLayerOptions): any;
17
+ export declare function BaseColumnsLayer({ enabled, columns, ...rest }: ColumnLayerOptions): null;
18
18
  export declare function buildColumnsStyle(opts?: ColumnsStyleOptions): StyleFragment;
19
19
  export type ColumnFeature = GeoJSON.Feature & {
20
20
  id: number;
21
21
  };
22
22
  export declare function SelectedColumnOverlay({ selectedColumn, ...styleOpts }: {
23
23
  selectedColumn: ColumnFeature | null;
24
- } & SelectedColumnStyleOpts): any;
24
+ } & SelectedColumnStyleOpts): null;
25
25
  interface SelectedColumnStyleOpts {
26
26
  color?: string | any[];
27
27
  }
@@ -1,4 +1,4 @@
1
- import { StyleFragment } from '@macrostrat/map-styles';
1
+ import { StyleFragment } from '../../../../map-styles/src/index.ts';
2
2
  export interface UnitsOverlayProps {
3
3
  time: number;
4
4
  ageSpan?: number;
@@ -1,4 +1,4 @@
1
- import { UnitLong } from '@macrostrat/api-types';
1
+ import { UnitLong } from '../../../api-types/src/index.ts';
2
2
  import { ExtUnit, SectionInfo, ColumnScaleOptions, CompositeColumnData, CompositeScaleData, PackageLayoutData, PackageScaleInfo } from './types';
3
3
  export declare function buildCompositeScaleInfo(inputScales: PackageScaleInfo[], unconformityHeight: number): CompositeScaleData;
4
4
  export declare function finalizeSectionHeights<T extends UnitLong>(sections: SectionInfoWithScale<T>[], unconformityHeight: number): CompositeColumnData<T>;
@@ -1,4 +1,4 @@
1
- import { UnitLong } from '@macrostrat/api-types';
1
+ import { UnitLong } from '../../../api-types/src/index.ts';
2
2
  import { ApproxHeightScaleOptions, HybridScaleDefinition, HybridScaleOptions, PackageScaleInfo } from './types';
3
3
  interface BaseSurface {
4
4
  index: number;
@@ -1,5 +1,5 @@
1
- import { BaseUnit, UnitLong } from '@macrostrat/api-types';
2
- import { ColumnAxisType } from '@macrostrat/column-components';
1
+ import { BaseUnit, UnitLong } from '../../../api-types/src/index.ts';
2
+ import { ColumnAxisType } from '../../../column-components/src/index.ts';
3
3
  import { ExtUnit, SectionInfo } from './types';
4
4
  export declare function preprocessUnits<T extends UnitLong = UnitLong>(section: SectionInfo<T>, axisType?: ColumnAxisType): ExtUnit[];
5
5
  export declare function groupUnitsIntoSectionsBySectionID<T extends UnitLong>(units: T[], axisType?: ColumnAxisType): SectionInfo<T>[];
@@ -1,5 +1,5 @@
1
1
  import { preprocessUnits } from './helpers';
2
- import { UnitLong } from '@macrostrat/api-types';
2
+ import { UnitLong } from '../../../api-types/src/index.ts';
3
3
  import { CompositeColumnScale } from './composite-scale';
4
4
  import { PrepareColumnOptions, PreparedColumnData } from './utils';
5
5
  export * from './utils';
@@ -1,5 +1,5 @@
1
- import { UnitLong } from '@macrostrat/api-types';
2
- import { ColumnAxisType } from '@macrostrat/column-components';
1
+ import { UnitLong } from '../../../api-types/src/index.ts';
2
+ import { ColumnAxisType } from '../../../column-components/src/index.ts';
3
3
  import { ScaleContinuousNumeric } from 'd3-scale';
4
4
  export interface ColumnHeightScaleOptions {
5
5
  /** A fixed pixel scale to use for the section (pixels per Myr) */
@@ -1,5 +1,5 @@
1
- import { BaseUnit } from '@macrostrat/api-types';
2
- import { ColumnAxisType } from '@macrostrat/column-components';
1
+ import { BaseUnit } from '../../../api-types/src/index.ts';
2
+ import { ColumnAxisType } from '../../../column-components/src/index.ts';
3
3
  import { ScaleContinuousNumeric } from 'd3-scale';
4
4
  import { ColumnScaleOptions, CompositeColumnData, ExtUnit, PackageLayoutData, StratigraphicPackage } from './types';
5
5
  export interface PrepareColumnOptions extends ColumnScaleOptions {
package/dist/section.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, FunctionComponent } from 'react';
2
- import { ColumnAxisType } from '@macrostrat/column-components';
2
+ import { ColumnAxisType } from '../../column-components/src/index.ts';
3
3
  import { ExtUnit, PackageScaleLayoutData } from './prepare-units/types';
4
4
  export interface SectionSharedProps {
5
5
  unitComponent?: FunctionComponent<any>;
@@ -40,6 +40,6 @@ export declare function UnconformityLabels(props: {
40
40
  style: {
41
41
  width: string | number;
42
42
  };
43
- className: string;
43
+ className: string | undefined;
44
44
  }, string | import('react').JSXElementConstructor<any>>;
45
45
  export {};
@@ -1,4 +1,4 @@
1
- import { IntervalTagProps } from '@macrostrat/data-components';
1
+ import { IntervalTagProps } from '../../../data-components/src/index.ts';
2
2
  export declare function AgeField({ unit, children, ...rest }: {
3
3
  [x: string]: any;
4
4
  unit: any;
@@ -38,8 +38,8 @@ export declare function AgeLabel({ age, maximumFractionDigits, minimumFractionDi
38
38
  }>;
39
39
  export declare function Duration({ value, maximumFractionDigits, minimumFractionDigits, }: {
40
40
  value: any;
41
- maximumFractionDigits?: number;
42
- minimumFractionDigits?: number;
41
+ maximumFractionDigits?: number | undefined;
42
+ minimumFractionDigits?: number | undefined;
43
43
  }): import('react').FunctionComponentElement<{
44
44
  value?: any;
45
45
  unit?: string;
@@ -64,7 +64,7 @@ export interface IntervalProportionsProps extends Omit<IntervalTagProps, "interv
64
64
  export declare function IntervalProportions({ unit, className, showProportions, calculateProportionsFromAges, ...rest }: IntervalProportionsProps): import('react').FunctionComponentElement<{
65
65
  children?: import('react').ReactNode;
66
66
  className: string;
67
- }>;
67
+ }> | null;
68
68
  export declare function getAgeRange(_unit: any): any[];
69
69
  export declare function getAge(value: any): any[];
70
70
  export {};
@@ -1 +1 @@
1
- export declare function UnitDetailsPanelWithNavigation(props: any): import('react').FunctionComponentElement<import('./panel').UnitDetailsPanelProps>;
1
+ export declare function UnitDetailsPanelWithNavigation(props: any): import('react').FunctionComponentElement<import('./panel').UnitDetailsPanelProps> | null;
@@ -6,4 +6,8 @@ export declare function UnitDetailsPopover({ style, children, viewportPadding, }
6
6
  }): import('react').ReactElement<{
7
7
  style: object;
8
8
  }, string | import('react').JSXElementConstructor<any>>;
9
- export declare function UnitSelectionPopover(props: Omit<UnitDetailsPanelProps, "onSelectUnit" | "unit">): import('react').DOMElement<import('react').DOMAttributes<Element>, Element>;
9
+ export declare function UnitSelectionPopover(props: Omit<UnitDetailsPanelProps, "onSelectUnit" | "unit">): import('react').ReactElement<import('react').FunctionComponentElement<{
10
+ style: object;
11
+ viewportPadding?: number;
12
+ children: React.ReactNode;
13
+ }>, string | import('react').JSXElementConstructor<any>> | null;
@@ -1,3 +1,3 @@
1
1
  export declare const formatProportion: (d: any) => any;
2
- export declare function formatRange(min: any, max: any, precision?: any): any;
3
- export declare function formatSignificance(value: any, precision?: any): any;
2
+ export declare function formatRange(min: any, max: any, precision?: null): any;
3
+ export declare function formatSignificance(value: any, precision?: null): any;
@@ -1,5 +1,5 @@
1
- import { ColumnAxisType } from '@macrostrat/column-components';
2
- import { Clickable } from '@macrostrat/ui-components';
1
+ import { ColumnAxisType } from '../../../column-components/src/index.ts';
2
+ import { Clickable } from '../../../ui-components/src/index.ts';
3
3
  import { ReactNode } from 'react';
4
4
  import { IUnit, RectBounds } from './types';
5
5
  interface UnitRectOptions {
@@ -32,14 +32,14 @@ export interface LabeledUnitProps extends UnitRectOptions, Clickable, Partial<Re
32
32
  export declare function MinimalUnit(props: any): import('react').ReactElement<{
33
33
  className: any;
34
34
  style: {
35
- "--column-unit-background-color": string;
36
- "--column-stroke-color": string;
35
+ "--column-unit-background-color": string | null;
36
+ "--column-stroke-color": string | null;
37
37
  };
38
38
  }, string | import('react').JSXElementConstructor<any>>;
39
39
  declare function Unit(props: UnitProps): import('react').ReactElement<{
40
40
  className: string;
41
41
  style: {
42
- "--column-unit-background-color": string;
42
+ "--column-unit-background-color": string | undefined;
43
43
  };
44
44
  }, string | import('react').JSXElementConstructor<any>>;
45
45
  declare function LabeledUnit(props: LabeledUnitProps): import('react').FunctionComponentElement<UnitProps>;
@@ -50,5 +50,5 @@ declare function UnitBoxes<T>(props: {
50
50
  unitComponentProps?: any;
51
51
  transformDivisions?(divisions: T[]): T[];
52
52
  transformDivision?: (division: any, index: number, divisions: any[]) => T | null;
53
- }): import('react').FunctionComponentElement<any>;
53
+ }): import('react').FunctionComponentElement<any> | null;
54
54
  export { LabeledUnit, Unit, UnitBoxes, UnitProps };
@@ -1,4 +1,4 @@
1
- import { Environment, Lithology, UnitLithology, UnitLong } from '@macrostrat/api-types';
1
+ import { Environment, Lithology, UnitLithology, UnitLong } from '../../../api-types/src/index.ts';
2
2
  interface KeyOptions {
3
3
  key?: "lith" | "environ";
4
4
  id_key?: "lith_id" | "environ_id";
@@ -1,9 +1,9 @@
1
- import { BaseUnit } from '@macrostrat/api-types';
2
- export declare function LabelTrackerProvider(props: any): import('react').FunctionComponentElement<import('react').ProviderProps<any>>;
1
+ import { BaseUnit } from '../../../api-types/src/index.ts';
2
+ export declare function LabelTrackerProvider(props: any): import('react').DetailedReactHTMLElement<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
3
3
  declare function TrackedLabeledUnit({ division, nameForDivision, ...rest }: {
4
4
  [x: string]: any;
5
5
  division: any;
6
- nameForDivision?: (div: any) => any;
6
+ nameForDivision?: ((div: any) => any) | undefined;
7
7
  }): import('react').FunctionComponentElement<import('./boxes').LabeledUnitProps>;
8
8
  export declare const CompositeUnitComponent: typeof TrackedLabeledUnit;
9
9
  type BaseUnitProps = {
@@ -32,8 +32,8 @@ interface CompositeUnitProps {
32
32
  showLabels?: boolean;
33
33
  clipToFrame?: boolean;
34
34
  }
35
- export declare function CompositeUnitsColumn(props: CompositeUnitProps): import('react').FunctionComponentElement<import('@macrostrat/column-components').LithologyColumnProps>;
36
- export declare function AnnotatedUnitsColumn(props: ICompositeUnitProps): any;
35
+ export declare function CompositeUnitsColumn(props: CompositeUnitProps): import('react').FunctionComponentElement<import('../../../column-components/src/index.ts').LithologyColumnProps>;
36
+ export declare function AnnotatedUnitsColumn(props: ICompositeUnitProps): null;
37
37
  export declare function SectionLabelsColumn(props: ICompositeUnitProps): import('react').DOMElement<import('react').DOMAttributes<Element>, Element>;
38
- export declare function ColumnNotesProvider(props: any): import('react').FunctionComponentElement<import('react').ProviderProps<import('@macrostrat/column-components').ColumnCtx<import('@macrostrat/column-components').ColumnDivision>>>;
38
+ export declare function ColumnNotesProvider(props: any): import('react').FunctionComponentElement<import('react').ProviderProps<import('../../../column-components/src/index.ts').ColumnCtx<import('../../../column-components/src/index.ts').ColumnDivision>>>;
39
39
  export { TrackedLabeledUnit, ICompositeUnitProps };
@@ -3,8 +3,8 @@ export * from './composite';
3
3
  export * from './types';
4
4
  export * from './colors';
5
5
  export declare function UnitsColumn({ width }: {
6
- width?: number;
7
- }): import('react').FunctionComponentElement<import('@macrostrat/column-components').LithologyColumnProps>;
6
+ width?: number | undefined;
7
+ }): import('react').FunctionComponentElement<import('../../../column-components/src/index.ts').LithologyColumnProps>;
8
8
  export declare function SimpleUnitsColumn(props: ICompositeUnitProps): import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>>;
9
9
  export declare function BasicUnitComponent({ division, ...rest }: {
10
10
  [x: string]: any;
@@ -12,16 +12,16 @@ export declare function BasicUnitComponent({ division, ...rest }: {
12
12
  }): import('react').FunctionComponentElement<{
13
13
  [x: string]: any;
14
14
  division: any;
15
- nColumns?: number;
15
+ nColumns?: number | undefined;
16
16
  }>;
17
17
  export declare function UnitComponent({ division, nColumns, ...rest }: {
18
18
  [x: string]: any;
19
19
  division: any;
20
- nColumns?: number;
20
+ nColumns?: number | undefined;
21
21
  }): import('react').FunctionComponentElement<{
22
22
  [x: string]: any;
23
23
  division: any;
24
- nameForDivision?: (div: any) => any;
24
+ nameForDivision?: ((div: any) => any) | undefined;
25
25
  }>;
26
26
  interface UnitColorOptions {
27
27
  asBackground?: boolean;
@@ -30,11 +30,11 @@ export declare function useUnitColor(unit: any, opts?: UnitColorOptions): string
30
30
  export declare function ColoredUnitComponent(props: any): import('react').FunctionComponentElement<{
31
31
  [x: string]: any;
32
32
  division: any;
33
- nColumns?: number;
33
+ nColumns?: number | undefined;
34
34
  }>;
35
35
  export declare function useUnitColorByEnvironment(unit: any, opts?: UnitColorOptions): string | null;
36
36
  export declare function EnvironmentColoredUnitComponent(props: any): import('react').FunctionComponentElement<{
37
37
  [x: string]: any;
38
38
  division: any;
39
- nColumns?: number;
39
+ nColumns?: number | undefined;
40
40
  }>;
@@ -1,4 +1,4 @@
1
- import { ColumnAxisType, ColumnDivision, NoteData, NotesColumnProps } from '@macrostrat/column-components';
1
+ import { ColumnAxisType, ColumnDivision, NoteData, NotesColumnProps } from '../../../column-components/src/index.ts';
2
2
  import { IUnit } from './types';
3
3
  import { default as React } from 'react';
4
4
  import { CompositeColumnScale } from '../prepare-units';
@@ -23,7 +23,8 @@ declare function noteForDivision(div: IUnit, opts: {
23
23
  nameForDivision?: (obj: IUnit) => string;
24
24
  }): UnitNote;
25
25
  declare const defaultNameFunction: (div: any) => any;
26
- declare const UnitDataColumn: React.NamedExoticComponent<UnitDataProps>;
26
+ declare function UnitDataColumn_(props: UnitDataProps): import('react').FunctionComponentElement<NotesColumnProps> | null;
27
+ declare const UnitDataColumn: React.MemoExoticComponent<typeof UnitDataColumn_>;
27
28
  export interface UnitNamesProps extends UnitDataProps {
28
29
  paddingLeft?: number;
29
30
  width: number;
@@ -1,4 +1,4 @@
1
- import { Lithology, UnitLithology } from '@macrostrat/api-types';
1
+ import { Lithology, UnitLithology } from '../../../api-types/src/index.ts';
2
2
  export declare function getBestFGDCPatternForLithologyList<T extends UnitLithology | Lithology>(liths: T[]): {
3
3
  lith: T;
4
4
  patternID: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@macrostrat/column-views",
3
- "version": "3.3.3",
3
+ "version": "3.3.4",
4
4
  "description": "Data views for Macrostrat stratigraphic columns",
5
5
  "repository": {
6
6
  "type": "git",
@@ -49,17 +49,17 @@
49
49
  "@macrostrat/api-types": "^1.1.5",
50
50
  "@macrostrat/color-utils": "^1.2.1",
51
51
  "@macrostrat/column-components": "^2.0.6",
52
- "@macrostrat/data-components": "^1.1.5",
52
+ "@macrostrat/data-components": "^1.1.8",
53
53
  "@macrostrat/data-provider": "^1.0.2",
54
54
  "@macrostrat/hyper": "^3.1.0",
55
- "@macrostrat/map-interface": "^2.2.3",
56
- "@macrostrat/map-styles": "^2.1.2",
57
- "@macrostrat/mapbox-react": "^3.1.3",
55
+ "@macrostrat/map-interface": "^2.2.4",
56
+ "@macrostrat/map-styles": "^2.2.1",
57
+ "@macrostrat/mapbox-react": "^3.2.0",
58
58
  "@macrostrat/mapbox-utils": "^1.7.3",
59
59
  "@macrostrat/stratigraphy-utils": "^1.2.1",
60
60
  "@macrostrat/svg-map-components": "^2.0.2",
61
61
  "@macrostrat/timescale": "^3.1.2",
62
- "@macrostrat/ui-components": "^5.0.7",
62
+ "@macrostrat/ui-components": "^5.0.8",
63
63
  "@turf/boolean-point-in-polygon": "^7.3.2",
64
64
  "@turf/buffer": "^7.3.2",
65
65
  "@turf/centroid": "^7.3.2",
@@ -167,7 +167,7 @@ function Package({
167
167
  }) {
168
168
  return h("g.package", { transform: `translate(0 ${offset})` }, [
169
169
  // Disable the SVG overlay for now
170
- //h(PackageSVGOverlay, { data, columnSpacing }),
170
+ //h(PackageSVGOverlay, { columnData, columnSpacing }),
171
171
  h("g.column-units", [
172
172
  columnData.map((data, i) => {
173
173
  return h(Column, {
@@ -237,7 +237,7 @@ function Column(props: ColumnProps) {
237
237
  unitComponentProps: {
238
238
  nColumns: 2,
239
239
  width: columnWidth,
240
- showLabel: false,
240
+ showLabel: true,
241
241
  },
242
242
  }),
243
243
  ),
@@ -72,7 +72,7 @@ const selectedUnitAtom = atom(
72
72
  console.error("Unit selection is disabled.");
73
73
  }
74
74
 
75
- let unitID: number | null;
75
+ let unitID: number | null = null;
76
76
  let unit: BaseUnit | null = null;
77
77
  if (selectedUnit == null) {
78
78
  unitID = null;