@macrostrat/column-views 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/age-axis.js +2 -2
- package/dist/age-axis.js.map +1 -1
- package/dist/age-axis.module.sass.cjs +6 -1
- package/dist/age-axis.module.sass.cjs.map +1 -1
- package/dist/age-axis.module.sass.js +4 -1
- package/dist/age-axis.module.sass.js.map +1 -1
- package/dist/age-model-overlay.js +2 -2
- package/dist/age-model-overlay.js.map +1 -1
- package/dist/age-model-overlay.module.sass.cjs +6 -1
- package/dist/age-model-overlay.module.sass.cjs.map +1 -1
- package/dist/age-model-overlay.module.sass.js +4 -1
- package/dist/age-model-overlay.module.sass.js.map +1 -1
- package/dist/column.js +2 -2
- package/dist/column.js.map +1 -1
- package/dist/column.module.sass.cjs +6 -1
- package/dist/column.module.sass.cjs.map +1 -1
- package/dist/column.module.sass.js +4 -1
- package/dist/column.module.sass.js.map +1 -1
- package/dist/correlation-chart/main.js +2 -2
- package/dist/correlation-chart/main.js.map +1 -1
- package/dist/correlation-chart/main.module.sass.cjs +6 -1
- package/dist/correlation-chart/main.module.sass.cjs.map +1 -1
- package/dist/correlation-chart/main.module.sass.js +4 -1
- package/dist/correlation-chart/main.module.sass.js.map +1 -1
- package/dist/data-provider/store.cjs +1 -1
- package/dist/data-provider/store.cjs.map +1 -1
- package/dist/data-provider/store.js +1 -1
- package/dist/data-provider/store.js.map +1 -1
- package/dist/facets/carbon-isotopes/isotopes-column.js +2 -2
- package/dist/facets/carbon-isotopes/isotopes-column.js.map +1 -1
- package/dist/facets/carbon-isotopes/isotopes-column.module.sass.cjs +6 -1
- package/dist/facets/carbon-isotopes/isotopes-column.module.sass.cjs.map +1 -1
- package/dist/facets/carbon-isotopes/isotopes-column.module.sass.js +4 -1
- package/dist/facets/carbon-isotopes/isotopes-column.module.sass.js.map +1 -1
- package/dist/facets/detrital-zircon/index.js +2 -2
- package/dist/facets/detrital-zircon/index.js.map +1 -1
- package/dist/facets/detrital-zircon/index.module.sass.cjs +6 -1
- package/dist/facets/detrital-zircon/index.module.sass.cjs.map +1 -1
- package/dist/facets/detrital-zircon/index.module.sass.js +4 -1
- package/dist/facets/detrital-zircon/index.module.sass.js.map +1 -1
- package/dist/facets/fossils/index.js +2 -2
- package/dist/facets/fossils/index.js.map +1 -1
- package/dist/facets/fossils/taxon-ranges.js +2 -2
- package/dist/facets/fossils/taxon-ranges.js.map +1 -1
- package/dist/facets/fossils/taxon-ranges.module.sass.cjs +6 -1
- package/dist/facets/fossils/taxon-ranges.module.sass.cjs.map +1 -1
- package/dist/facets/fossils/taxon-ranges.module.sass.js +4 -1
- package/dist/facets/fossils/taxon-ranges.module.sass.js.map +1 -1
- package/dist/facets/measurements/base.js +2 -2
- package/dist/facets/measurements/base.js.map +1 -1
- package/dist/facets/measurements/base.module.sass.cjs +6 -1
- package/dist/facets/measurements/base.module.sass.cjs.map +1 -1
- package/dist/facets/measurements/base.module.sass.js +4 -1
- package/dist/facets/measurements/base.module.sass.js.map +1 -1
- package/dist/index.cjs +10 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/maps/_shared/styles.cjs +6 -1
- package/dist/maps/_shared/styles.cjs.map +1 -1
- package/dist/maps/_shared/styles.js +6 -1
- package/dist/maps/_shared/styles.js.map +1 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +1 -1
- package/dist/maps/index.d.ts +1 -0
- package/dist/maps/units-overlay/index.cjs +254 -0
- package/dist/maps/units-overlay/index.cjs.map +1 -0
- package/dist/maps/units-overlay/index.d.ts +14 -0
- package/dist/maps/units-overlay/index.js +252 -0
- package/dist/maps/units-overlay/index.js.map +1 -0
- package/dist/section.js +2 -2
- package/dist/section.js.map +1 -1
- package/dist/unit-details/panel.js +2 -2
- package/dist/unit-details/panel.js.map +1 -1
- package/dist/unit-details/panel.module.sass.cjs +6 -1
- package/dist/unit-details/panel.module.sass.cjs.map +1 -1
- package/dist/unit-details/panel.module.sass.js +4 -1
- package/dist/unit-details/panel.module.sass.js.map +1 -1
- package/dist/unit-details/popover.js +2 -2
- package/dist/unit-details/popover.js.map +1 -1
- package/dist/unit-details/popover.module.sass.cjs +6 -1
- package/dist/unit-details/popover.module.sass.cjs.map +1 -1
- package/dist/unit-details/popover.module.sass.js +4 -1
- package/dist/unit-details/popover.module.sass.js.map +1 -1
- package/dist/units/boxes.js +2 -2
- package/dist/units/boxes.js.map +1 -1
- package/dist/units/boxes.module.sass.cjs +6 -1
- package/dist/units/boxes.module.sass.cjs.map +1 -1
- package/dist/units/boxes.module.sass.js +4 -1
- package/dist/units/boxes.module.sass.js.map +1 -1
- package/dist/units/colors.cjs +79 -18
- package/dist/units/colors.cjs.map +1 -1
- package/dist/units/colors.d.ts +17 -4
- package/dist/units/colors.js +79 -18
- package/dist/units/colors.js.map +1 -1
- package/dist/units/composite.js +2 -2
- package/dist/units/composite.js.map +1 -1
- package/dist/units/composite.module.sass.cjs +6 -1
- package/dist/units/composite.module.sass.cjs.map +1 -1
- package/dist/units/composite.module.sass.js +4 -1
- package/dist/units/composite.module.sass.js.map +1 -1
- package/dist/units/index.cjs +2 -0
- package/dist/units/index.cjs.map +1 -1
- package/dist/units/index.js +3 -0
- package/dist/units/index.js.map +1 -1
- package/dist/units/resolvers.cjs +11 -0
- package/dist/units/resolvers.cjs.map +1 -1
- package/dist/units/resolvers.d.ts +5 -0
- package/dist/units/resolvers.js +11 -0
- package/dist/units/resolvers.js.map +1 -1
- package/package.json +10 -9
- package/src/data-provider/store.ts +1 -0
- package/src/maps/_shared/styles.ts +10 -3
- package/src/maps/index.ts +1 -0
- package/src/maps/unit-map.stories.ts +64 -0
- package/src/maps/units-overlay/index.ts +336 -0
- package/src/units/colors.ts +137 -25
- package/src/units/resolvers.ts +16 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isotopes-column.js","sources":["../../../src/facets/carbon-isotopes/isotopes-column.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport hyper from \"@macrostrat/hyper\";\nimport classNames from \"classnames\";\nimport { AxisBottom } from \"@visx/axis\";\nimport { useMeasurementData } from \"./data-provider\";\n\nimport {\n IsotopesDataArea,\n useDataLocator,\n IsotopeDataPoint,\n} from \"./data-area\";\nimport { referenceMeasuresToColumn } from \"@macrostrat/stratigraphy-utils\";\nimport {\n SVG,\n ColumnLayoutProvider,\n useColumnLayout,\n} from \"@macrostrat/column-components\";\nimport {\n useMacrostratColumnData,\n useMacrostratUnits,\n} from \"../../data-provider\";\nimport styles from \"./isotopes-column.module.sass\";\nimport { scaleLinear } from \"d3-scale\";\n\nconst h = hyper.styled(styles);\n\ntype IsotopesTextProps = {\n datum: any;\n text: string;\n};\n\nfunction IsotopeText({ datum, text, ...rest }: IsotopesTextProps) {\n const { pointLocator } = useDataLocator();\n const [x, y] = pointLocator(datum);\n return h(\n \"text\",\n {\n x,\n y,\n ...rest,\n },\n text,\n );\n}\n\ninterface ScaleLineProps {\n value: number;\n className?: string;\n labelBottom?: boolean;\n labelOffset?: number;\n strokeDasharray?: string;\n stroke?: string | number;\n}\n\nfunction ScaleLine(props: ScaleLineProps) {\n let { value, className, labelBottom, labelOffset, ...rest } = props;\n const { sections } = useMacrostratColumnData();\n\n const { xScale } = useColumnLayout();\n const x = xScale(value);\n const transform = `translate(${x})`;\n className = classNames(className, { zero: value === 0 });\n return h(\"g.tick\", { transform, className, key: value }, [\n h(\n \"g.tick-lines\",\n sections.map((d) => {\n const { scaleInfo } = d;\n const y1 = scaleInfo.offset;\n const y2 = y1 + scaleInfo.pixelHeight;\n return h(\"line\", {\n y1,\n y2,\n strokeDasharray: props.strokeDasharray,\n strokeWidth: 1,\n });\n }),\n ),\n ]);\n}\n\nfunction unnestPoints(measures) {\n let points = [];\n for (const meas of measures) {\n const vals = meas.measure_value.map((d, i) => {\n return {\n value: d,\n age: meas.measure_age[i],\n position: meas.measure_position[i],\n unit_id: meas.unit_id,\n sample_id: meas.sample_no[i],\n measurement: meas.measurement,\n };\n });\n Array.prototype.push.apply(points, vals);\n }\n return points;\n}\n\ninterface IsotopesDatasetProps {\n color?: string;\n parameter: string;\n}\n\ninterface IsotopeColumnProps extends IsotopesDatasetProps {\n width: number;\n tickValues?: number[];\n label: string;\n domain?: [number, number];\n transform?: string;\n getHeight?: Function;\n nTicks?: number;\n showAxis?: boolean;\n}\n\nfunction IsotopesDataset(props) {\n const { parameter, color = \"dodgerblue\" } = props;\n const units = useMacrostratUnits();\n const measures = useMeasurementData() ?? [];\n\n const points = useMemo(() => {\n const data = measures.filter((d) => d.measurement === parameter);\n const refMeasures = referenceMeasuresToColumn(units, data);\n return unnestPoints(refMeasures);\n }, [measures, parameter, units]);\n\n return h(\n IsotopesDataArea,\n {\n getHeight(d) {\n return d.age;\n },\n } as any,\n h(\n \"g.data-points\",\n points.map((d) => {\n return h(IsotopeDataPoint, {\n datum: d,\n fill: color,\n });\n }),\n ),\n );\n}\n\nfunction IsotopesColumn(\n props: IsotopeColumnProps & { children?: React.ReactNode },\n) {\n const {\n width = 120,\n domain = [-14, 6],\n parameter,\n label,\n color = \"dodgerblue\",\n children = null,\n transform,\n getHeight,\n showAxis = true,\n tickValues: _tickVals,\n nTicks = 6,\n ...rest\n } = props;\n\n const { totalHeight } = useMacrostratColumnData();\n\n let _children: any = children;\n if (children == null && parameter != null) {\n _children = h(IsotopesDataset, { parameter, color, getHeight });\n }\n\n const xScale = useMemo(\n () => scaleLinear().domain(domain).range([0, width]),\n [domain, width],\n );\n\n const tickValues = _tickVals ?? xScale.ticks(nTicks);\n\n return h(\"div.isotopes-column\", [\n h(\n SVG,\n {\n height: totalHeight,\n innerWidth: width,\n paddingH: 15,\n },\n h(\n ColumnLayoutProvider,\n { width, xScale },\n h(\"g.isotopes-column\", { className: parameter, transform }, [\n h(ColumnScaleLines, {\n xScale,\n tickValues,\n width,\n ...rest,\n }),\n _children,\n ]),\n ),\n ),\n h.if(showAxis)(ColumnScaleAxis, {\n width,\n label: label ?? parameter,\n xScale,\n tickValues,\n ...rest,\n }),\n ]);\n}\n\nfunction ColumnScaleAxis(props) {\n const { label, xScale, width, showAxis = true, tickValues, ...rest } = props;\n\n return h(\"div.isotopes-scale-axis\", [\n h(\n SVG,\n {\n innerWidth: width,\n height: 45,\n paddingH: 15,\n },\n [\n h(AxisBottom, {\n scale: xScale,\n tickLength: 5,\n tickValues,\n stroke: \"var(--column-stroke-color)\",\n tickStroke: \"var(--column-stroke-color)\",\n ...rest,\n label,\n }),\n ],\n ),\n ]);\n}\n\nfunction ColumnScaleLines(props) {\n const { tickValues, xScale } = props;\n\n return h(\n \"g.scale-lines\",\n tickValues.map((value) => {\n return h(ScaleLine, { value });\n }),\n );\n}\n\nexport { IsotopesColumn, IsotopesDataset };\n"],"names":["hyper"],"mappings":";;;;;;;;;;;AAwBA,MAAM,IAAIA,IAAM,
|
|
1
|
+
{"version":3,"file":"isotopes-column.js","sources":["../../../src/facets/carbon-isotopes/isotopes-column.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport hyper from \"@macrostrat/hyper\";\nimport classNames from \"classnames\";\nimport { AxisBottom } from \"@visx/axis\";\nimport { useMeasurementData } from \"./data-provider\";\n\nimport {\n IsotopesDataArea,\n useDataLocator,\n IsotopeDataPoint,\n} from \"./data-area\";\nimport { referenceMeasuresToColumn } from \"@macrostrat/stratigraphy-utils\";\nimport {\n SVG,\n ColumnLayoutProvider,\n useColumnLayout,\n} from \"@macrostrat/column-components\";\nimport {\n useMacrostratColumnData,\n useMacrostratUnits,\n} from \"../../data-provider\";\nimport styles from \"./isotopes-column.module.sass\";\nimport { scaleLinear } from \"d3-scale\";\n\nconst h = hyper.styled(styles);\n\ntype IsotopesTextProps = {\n datum: any;\n text: string;\n};\n\nfunction IsotopeText({ datum, text, ...rest }: IsotopesTextProps) {\n const { pointLocator } = useDataLocator();\n const [x, y] = pointLocator(datum);\n return h(\n \"text\",\n {\n x,\n y,\n ...rest,\n },\n text,\n );\n}\n\ninterface ScaleLineProps {\n value: number;\n className?: string;\n labelBottom?: boolean;\n labelOffset?: number;\n strokeDasharray?: string;\n stroke?: string | number;\n}\n\nfunction ScaleLine(props: ScaleLineProps) {\n let { value, className, labelBottom, labelOffset, ...rest } = props;\n const { sections } = useMacrostratColumnData();\n\n const { xScale } = useColumnLayout();\n const x = xScale(value);\n const transform = `translate(${x})`;\n className = classNames(className, { zero: value === 0 });\n return h(\"g.tick\", { transform, className, key: value }, [\n h(\n \"g.tick-lines\",\n sections.map((d) => {\n const { scaleInfo } = d;\n const y1 = scaleInfo.offset;\n const y2 = y1 + scaleInfo.pixelHeight;\n return h(\"line\", {\n y1,\n y2,\n strokeDasharray: props.strokeDasharray,\n strokeWidth: 1,\n });\n }),\n ),\n ]);\n}\n\nfunction unnestPoints(measures) {\n let points = [];\n for (const meas of measures) {\n const vals = meas.measure_value.map((d, i) => {\n return {\n value: d,\n age: meas.measure_age[i],\n position: meas.measure_position[i],\n unit_id: meas.unit_id,\n sample_id: meas.sample_no[i],\n measurement: meas.measurement,\n };\n });\n Array.prototype.push.apply(points, vals);\n }\n return points;\n}\n\ninterface IsotopesDatasetProps {\n color?: string;\n parameter: string;\n}\n\ninterface IsotopeColumnProps extends IsotopesDatasetProps {\n width: number;\n tickValues?: number[];\n label: string;\n domain?: [number, number];\n transform?: string;\n getHeight?: Function;\n nTicks?: number;\n showAxis?: boolean;\n}\n\nfunction IsotopesDataset(props) {\n const { parameter, color = \"dodgerblue\" } = props;\n const units = useMacrostratUnits();\n const measures = useMeasurementData() ?? [];\n\n const points = useMemo(() => {\n const data = measures.filter((d) => d.measurement === parameter);\n const refMeasures = referenceMeasuresToColumn(units, data);\n return unnestPoints(refMeasures);\n }, [measures, parameter, units]);\n\n return h(\n IsotopesDataArea,\n {\n getHeight(d) {\n return d.age;\n },\n } as any,\n h(\n \"g.data-points\",\n points.map((d) => {\n return h(IsotopeDataPoint, {\n datum: d,\n fill: color,\n });\n }),\n ),\n );\n}\n\nfunction IsotopesColumn(\n props: IsotopeColumnProps & { children?: React.ReactNode },\n) {\n const {\n width = 120,\n domain = [-14, 6],\n parameter,\n label,\n color = \"dodgerblue\",\n children = null,\n transform,\n getHeight,\n showAxis = true,\n tickValues: _tickVals,\n nTicks = 6,\n ...rest\n } = props;\n\n const { totalHeight } = useMacrostratColumnData();\n\n let _children: any = children;\n if (children == null && parameter != null) {\n _children = h(IsotopesDataset, { parameter, color, getHeight });\n }\n\n const xScale = useMemo(\n () => scaleLinear().domain(domain).range([0, width]),\n [domain, width],\n );\n\n const tickValues = _tickVals ?? xScale.ticks(nTicks);\n\n return h(\"div.isotopes-column\", [\n h(\n SVG,\n {\n height: totalHeight,\n innerWidth: width,\n paddingH: 15,\n },\n h(\n ColumnLayoutProvider,\n { width, xScale },\n h(\"g.isotopes-column\", { className: parameter, transform }, [\n h(ColumnScaleLines, {\n xScale,\n tickValues,\n width,\n ...rest,\n }),\n _children,\n ]),\n ),\n ),\n h.if(showAxis)(ColumnScaleAxis, {\n width,\n label: label ?? parameter,\n xScale,\n tickValues,\n ...rest,\n }),\n ]);\n}\n\nfunction ColumnScaleAxis(props) {\n const { label, xScale, width, showAxis = true, tickValues, ...rest } = props;\n\n return h(\"div.isotopes-scale-axis\", [\n h(\n SVG,\n {\n innerWidth: width,\n height: 45,\n paddingH: 15,\n },\n [\n h(AxisBottom, {\n scale: xScale,\n tickLength: 5,\n tickValues,\n stroke: \"var(--column-stroke-color)\",\n tickStroke: \"var(--column-stroke-color)\",\n ...rest,\n label,\n }),\n ],\n ),\n ]);\n}\n\nfunction ColumnScaleLines(props) {\n const { tickValues, xScale } = props;\n\n return h(\n \"g.scale-lines\",\n tickValues.map((value) => {\n return h(ScaleLine, { value });\n }),\n );\n}\n\nexport { IsotopesColumn, IsotopesDataset };\n"],"names":["hyper","styles"],"mappings":";;;;;;;;;;;AAwBA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AA8B7B,SAAS,UAA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AAA,UAC1D,EAAE,kBAAkB;AAAA,YAClB;AAAA,YACA;AAAA,YACA;AAAA,YACA,GAAG;AAAA,UAAA,CACJ;AAAA,UACD;AAAA,QAAA,CACD;AAAA,MAAA;AAAA,IACH;AAAA,IAEF,EAAE,GAAG,QAAQ,EAAE,iBAAiB;AAAA,MAC9B;AAAA,MACA,OAAO,SAAS;AAAA,MAChB;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,EAAA,CACF;AACH;AAEA,SAAS,gBAAgB,OAAO;AAC9B,QAAM,EAAE,OAAO,QAAQ,OAAO,WAAW,MAAM,YAAY,GAAG,KAAA,IAAS;AAEvE,SAAO,EAAE,2BAA2B;AAAA,IAClC;AAAA,MACE;AAAA,MACA;AAAA,QACE,YAAY;AAAA,QACZ,QAAQ;AAAA,QACR,UAAU;AAAA,MAAA;AAAA,MAEZ;AAAA,QACE,EAAE,YAAY;AAAA,UACZ,OAAO;AAAA,UACP,YAAY;AAAA,UACZ;AAAA,UACA,QAAQ;AAAA,UACR,YAAY;AAAA,UACZ,GAAG;AAAA,UACH;AAAA,QAAA,CACD;AAAA,MAAA;AAAA,IACH;AAAA,EACF,CACD;AACH;AAEA,SAAS,iBAAiB,OAAO;AAC/B,QAAM,EAAE,YAAY,OAAA,IAAW;AAE/B,SAAO;AAAA,IACL;AAAA,IACA,WAAW,IAAI,CAAC,UAAU;AACxB,aAAO,EAAE,WAAW,EAAE,OAAO;AAAA,IAC/B,CAAC;AAAA,EAAA;AAEL;"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const h$1 = require("@macrostrat/hyper");
|
|
4
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
5
|
+
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
3
6
|
const tick = "_tick_y4y1w_24";
|
|
4
7
|
const zero = "_zero_y4y1w_24";
|
|
5
8
|
const styles = {
|
|
@@ -9,7 +12,9 @@ const styles = {
|
|
|
9
12
|
tick,
|
|
10
13
|
zero
|
|
11
14
|
};
|
|
12
|
-
|
|
15
|
+
let h = h__default.default.styled(styles);
|
|
16
|
+
Object.assign(h, styles);
|
|
17
|
+
exports.default = h;
|
|
13
18
|
exports.tick = tick;
|
|
14
19
|
exports.zero = zero;
|
|
15
20
|
//# sourceMappingURL=isotopes-column.module.sass.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isotopes-column.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isotopes-column.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import h$1 from "@macrostrat/hyper";
|
|
1
2
|
const tick = "_tick_y4y1w_24";
|
|
2
3
|
const zero = "_zero_y4y1w_24";
|
|
3
4
|
const styles = {
|
|
@@ -7,8 +8,10 @@ const styles = {
|
|
|
7
8
|
tick,
|
|
8
9
|
zero
|
|
9
10
|
};
|
|
11
|
+
let h = h$1.styled(styles);
|
|
12
|
+
Object.assign(h, styles);
|
|
10
13
|
export {
|
|
11
|
-
|
|
14
|
+
h as default,
|
|
12
15
|
tick,
|
|
13
16
|
zero
|
|
14
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isotopes-column.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isotopes-column.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -2,14 +2,14 @@ import { DetritalSpectrumPlot, DetritalSeries, usePlotArea } from "@macrostrat/d
|
|
|
2
2
|
import h$1 from "@macrostrat/hyper";
|
|
3
3
|
import { useDetritalMeasurements } from "./provider.js";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
-
import
|
|
5
|
+
import h$2 from "./index.module.sass.js";
|
|
6
6
|
import classNames from "classnames";
|
|
7
7
|
import { group } from "d3-array";
|
|
8
8
|
import { NonIdealState, Spinner } from "@blueprintjs/core";
|
|
9
9
|
import { BaseMeasurementsColumn, mergeHeightRanges } from "../measurements/base.js";
|
|
10
10
|
import { useMacrostratColumnData } from "../../data-provider/store.js";
|
|
11
11
|
import { getUnitHeightRange } from "../../prepare-units/utils.js";
|
|
12
|
-
const h = h$1.styled(
|
|
12
|
+
const h = h$1.styled(h$2);
|
|
13
13
|
function prepareDetritalData(data, units, axisType) {
|
|
14
14
|
const measurementsGrouped = group(data, (d) => d.measuremeta_id);
|
|
15
15
|
const resMap = /* @__PURE__ */ new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/facets/detrital-zircon/index.ts"],"sourcesContent":["import {\n DetritalSpectrumPlot,\n DetritalSeries,\n usePlotArea,\n} from \"@macrostrat/data-components\";\nimport type { IUnit } from \"../../units/types\";\nimport hyper from \"@macrostrat/hyper\";\nimport { useDetritalMeasurements, MeasurementInfo } from \"./provider\";\nimport { useMemo } from \"react\";\nimport styles from \"./index.module.sass\";\nimport classNames from \"classnames\";\nimport {\n BaseMeasurementsColumn,\n mergeHeightRanges,\n ColumnMeasurementData,\n} from \"../measurements\";\nimport { group } from \"d3-array\";\nimport { ColumnAxisType } from \"@macrostrat/column-components\";\nimport { useMacrostratColumnData } from \"../../data-provider\";\nimport { getUnitHeightRange } from \"../../prepare-units\";\nimport { NonIdealState, Spinner } from \"@blueprintjs/core\";\n\nconst h = hyper.styled(styles);\n\ninterface DetritalItemProps {\n note: DZMeasurementInfo;\n spacing?: {\n below?: number;\n above?: number;\n };\n width?: number;\n height?: number;\n color?: string;\n}\n\ninterface DZMeasurementInfo extends ColumnMeasurementData<MeasurementInfo[]> {\n units: IUnit[];\n}\n\nfunction prepareDetritalData(\n data: MeasurementInfo[],\n units: IUnit[],\n axisType: ColumnAxisType,\n) {\n /** Right now measurement data could be duplicated if there are multiple units linked to the same\n * measuremeta_id. THis happens because matches to units might be at a lower rank (e.g, if the column\n * contains Formations but the measurements are linked to a Group). To handle this, we group by measuremeta_id\n * and then create unique keys based on the set of units linked to each measurement.\n */\n\n // Group data by measuremeta_id\n const measurementsGrouped = group(data, (d) => d.measuremeta_id);\n\n const resMap = new Map<string, DZMeasurementInfo>();\n\n for (const measurements of measurementsGrouped.values()) {\n // Get a list of unique unit_ids for this measurement\n const unitIDs = new Set(measurements.map((m) => m.unit_id));\n const ids = Array.from(unitIDs);\n ids.sort();\n // Key is unique to the set of units\n const key = ids.join(\"-\");\n\n if (!resMap.has(key)) {\n const unitData = ids\n .map((id) => {\n return units.find((u) => u.unit_id === id);\n })\n .filter(Boolean);\n\n const positions = unitData.map((unit) => {\n const [height, top_height] = getUnitHeightRange(unit, axisType);\n return { height, top_height };\n });\n\n // merge positions (note: we could also have multiple separate notes per measurement)\n const pos = mergeHeightRanges(positions, axisType);\n\n resMap.set(key, {\n id: key,\n data: [],\n units: unitData as IUnit[],\n ...pos,\n });\n }\n resMap.get(key)!.data.push(measurements[0]);\n }\n\n return Array.from(resMap.values());\n}\n\nfunction DetritalColumn({ columnID, color = \"magenta\" }) {\n const data = useDetritalMeasurements({ col_id: columnID });\n\n const width = 400;\n const paddingLeft = 40;\n\n const spectrumWidth = width - paddingLeft;\n\n const noteComponent = useMemo(() => {\n return (props) => {\n return h(DetritalGroup, {\n width: spectrumWidth,\n height: 40,\n color,\n ...props,\n });\n };\n }, [width, color]);\n\n const { axisType, units } = useMacrostratColumnData();\n\n const data1 = useMemo(() => {\n if (data == null || units == null) return null;\n return prepareDetritalData(data, units, axisType);\n }, [data, units, axisType]);\n\n if (data1 == null) return h(NonIdealState, h(Spinner));\n\n return h(BaseMeasurementsColumn, {\n data: data1,\n noteComponent,\n deltaConnectorAttachment: 20,\n });\n}\n\nfunction DepositionalAge({ unit }) {\n const { xScale, height } = usePlotArea();\n\n const { t_age, b_age } = unit;\n const x = xScale(t_age);\n const x1 = xScale(b_age);\n\n return h(\"rect.depositional-age\", { x, width: x1 - x, y: 0, height });\n}\n\nfunction DetritalGroup(props: DetritalItemProps) {\n const { note, width, height, color, spacing } = props;\n const { data, units } = note;\n\n const _color = color;\n\n const spaceBelow = spacing?.below ?? 100;\n const hideAxisLabels = spaceBelow < 60;\n\n return h(\n \"div.detrital-group\",\n { className: classNames({ \"hide-axis\": hideAxisLabels }) },\n [\n h(\n DetritalSpectrumPlot,\n { width, innerHeight: height, showAxisLabels: true, paddingBottom: 40 },\n [\n units.map((unit) => {\n return h(DepositionalAge, { unit });\n }),\n data.map((d) => {\n return h(DetritalSeries, {\n bandwidth: 20,\n data: d.measure_value,\n color: _color,\n });\n }),\n ],\n ),\n ],\n );\n}\n\nexport { DetritalColumn, DetritalGroup };\n"],"names":["hyper"],"mappings":";;;;;;;;;;;AAsBA,MAAM,IAAIA,IAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/facets/detrital-zircon/index.ts"],"sourcesContent":["import {\n DetritalSpectrumPlot,\n DetritalSeries,\n usePlotArea,\n} from \"@macrostrat/data-components\";\nimport type { IUnit } from \"../../units/types\";\nimport hyper from \"@macrostrat/hyper\";\nimport { useDetritalMeasurements, MeasurementInfo } from \"./provider\";\nimport { useMemo } from \"react\";\nimport styles from \"./index.module.sass\";\nimport classNames from \"classnames\";\nimport {\n BaseMeasurementsColumn,\n mergeHeightRanges,\n ColumnMeasurementData,\n} from \"../measurements\";\nimport { group } from \"d3-array\";\nimport { ColumnAxisType } from \"@macrostrat/column-components\";\nimport { useMacrostratColumnData } from \"../../data-provider\";\nimport { getUnitHeightRange } from \"../../prepare-units\";\nimport { NonIdealState, Spinner } from \"@blueprintjs/core\";\n\nconst h = hyper.styled(styles);\n\ninterface DetritalItemProps {\n note: DZMeasurementInfo;\n spacing?: {\n below?: number;\n above?: number;\n };\n width?: number;\n height?: number;\n color?: string;\n}\n\ninterface DZMeasurementInfo extends ColumnMeasurementData<MeasurementInfo[]> {\n units: IUnit[];\n}\n\nfunction prepareDetritalData(\n data: MeasurementInfo[],\n units: IUnit[],\n axisType: ColumnAxisType,\n) {\n /** Right now measurement data could be duplicated if there are multiple units linked to the same\n * measuremeta_id. THis happens because matches to units might be at a lower rank (e.g, if the column\n * contains Formations but the measurements are linked to a Group). To handle this, we group by measuremeta_id\n * and then create unique keys based on the set of units linked to each measurement.\n */\n\n // Group data by measuremeta_id\n const measurementsGrouped = group(data, (d) => d.measuremeta_id);\n\n const resMap = new Map<string, DZMeasurementInfo>();\n\n for (const measurements of measurementsGrouped.values()) {\n // Get a list of unique unit_ids for this measurement\n const unitIDs = new Set(measurements.map((m) => m.unit_id));\n const ids = Array.from(unitIDs);\n ids.sort();\n // Key is unique to the set of units\n const key = ids.join(\"-\");\n\n if (!resMap.has(key)) {\n const unitData = ids\n .map((id) => {\n return units.find((u) => u.unit_id === id);\n })\n .filter(Boolean);\n\n const positions = unitData.map((unit) => {\n const [height, top_height] = getUnitHeightRange(unit, axisType);\n return { height, top_height };\n });\n\n // merge positions (note: we could also have multiple separate notes per measurement)\n const pos = mergeHeightRanges(positions, axisType);\n\n resMap.set(key, {\n id: key,\n data: [],\n units: unitData as IUnit[],\n ...pos,\n });\n }\n resMap.get(key)!.data.push(measurements[0]);\n }\n\n return Array.from(resMap.values());\n}\n\nfunction DetritalColumn({ columnID, color = \"magenta\" }) {\n const data = useDetritalMeasurements({ col_id: columnID });\n\n const width = 400;\n const paddingLeft = 40;\n\n const spectrumWidth = width - paddingLeft;\n\n const noteComponent = useMemo(() => {\n return (props) => {\n return h(DetritalGroup, {\n width: spectrumWidth,\n height: 40,\n color,\n ...props,\n });\n };\n }, [width, color]);\n\n const { axisType, units } = useMacrostratColumnData();\n\n const data1 = useMemo(() => {\n if (data == null || units == null) return null;\n return prepareDetritalData(data, units, axisType);\n }, [data, units, axisType]);\n\n if (data1 == null) return h(NonIdealState, h(Spinner));\n\n return h(BaseMeasurementsColumn, {\n data: data1,\n noteComponent,\n deltaConnectorAttachment: 20,\n });\n}\n\nfunction DepositionalAge({ unit }) {\n const { xScale, height } = usePlotArea();\n\n const { t_age, b_age } = unit;\n const x = xScale(t_age);\n const x1 = xScale(b_age);\n\n return h(\"rect.depositional-age\", { x, width: x1 - x, y: 0, height });\n}\n\nfunction DetritalGroup(props: DetritalItemProps) {\n const { note, width, height, color, spacing } = props;\n const { data, units } = note;\n\n const _color = color;\n\n const spaceBelow = spacing?.below ?? 100;\n const hideAxisLabels = spaceBelow < 60;\n\n return h(\n \"div.detrital-group\",\n { className: classNames({ \"hide-axis\": hideAxisLabels }) },\n [\n h(\n DetritalSpectrumPlot,\n { width, innerHeight: height, showAxisLabels: true, paddingBottom: 40 },\n [\n units.map((unit) => {\n return h(DepositionalAge, { unit });\n }),\n data.map((d) => {\n return h(DetritalSeries, {\n bandwidth: 20,\n data: d.measure_value,\n color: _color,\n });\n }),\n ],\n ),\n ],\n );\n}\n\nexport { DetritalColumn, DetritalGroup };\n"],"names":["hyper","styles"],"mappings":";;;;;;;;;;;AAsBA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAiB7B,SAAS,oBACP,MACA,OACA,UACA;AAQA,QAAM,sBAAsB,MAAM,MAAM,CAAC,MAAM,EAAE,cAAc;AAE/D,QAAM,6BAAa,IAAA;AAEnB,aAAW,gBAAgB,oBAAoB,UAAU;AAEvD,UAAM,UAAU,IAAI,IAAI,aAAa,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;AAC1D,UAAM,MAAM,MAAM,KAAK,OAAO;AAC9B,QAAI,KAAA;AAEJ,UAAM,MAAM,IAAI,KAAK,GAAG;AAExB,QAAI,CAAC,OAAO,IAAI,GAAG,GAAG;AACpB,YAAM,WAAW,IACd,IAAI,CAAC,OAAO;AACX,eAAO,MAAM,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE;AAAA,MAC3C,CAAC,EACA,OAAO,OAAO;AAEjB,YA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QAAQ,OAAA,IAAW,YAAA;AAE3B,QAAM,EAAE,OAAO,MAAA,IAAU;AACzB,QAAM,IAAI,OAAO,KAAK;AACtB,QAAM,KAAK,OAAO,KAAK;AAEvB,SAAO,EAAE,yBAAyB,EAAE,GAAG,OAAO,KAAK,GAAG,GAAG,GAAG,QAAQ;AACtE;AAEA,SAAS,cAAc,OAA0B;AAC/C,QAAM,EAAE,MAAM,OAAO,QAAQ,OAAO,YAAY;AAChD,QAAM,EAAE,MAAM,MAAA,IAAU;AAExB,QAAM,SAAS;AAEf,QAAM,aAAa,SAAS,SAAS;AACrC,QAAM,iBAAiB,aAAa;AAEpC,SAAO;AAAA,IACL;AAAA,IACA,EAAE,WAAW,WAAW,EAAE,aAAa,eAAA,CAAgB,EAAA;AAAA,IACvD;AAAA,MACE;AAAA,QACE;AAAA,QACA,EAAE,OAAO,aAAa,QAAQ,gBAAgB,MAAM,eAAe,GAAA;AAAA,QACnE;AAAA,UACE,MAAM,IAAI,CAAC,SAAS;AAClB,mBAAO,EAAE,iBAAiB,EAAE,MAAM;AAAA,UACpC,CAAC;AAAA,UACD,KAAK,IAAI,CAAC,MAAM;AACd,mBAAO,EAAE,gBAAgB;AAAA,cACvB,WAAW;AAAA,cACX,MAAM,EAAE;AAAA,cACR,OAAO;AAAA,YAAA,CACR;AAAA,UACH,CAAC;AAAA,QAAA;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEJ;"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const h$1 = require("@macrostrat/hyper");
|
|
3
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
4
|
+
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
2
5
|
const styles = {
|
|
3
6
|
"depositional-age": "_depositional-age_ngsgr_1",
|
|
4
7
|
"detrital-group": "_detrital-group_ngsgr_8",
|
|
@@ -6,5 +9,7 @@ const styles = {
|
|
|
6
9
|
"dz-spectra": "_dz-spectra_ngsgr_16",
|
|
7
10
|
"floating-axis": "_floating-axis_ngsgr_20"
|
|
8
11
|
};
|
|
9
|
-
|
|
12
|
+
let h = h__default.default.styled(styles);
|
|
13
|
+
Object.assign(h, styles);
|
|
14
|
+
module.exports = h;
|
|
10
15
|
//# sourceMappingURL=index.module.sass.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import h$1 from "@macrostrat/hyper";
|
|
1
2
|
const styles = {
|
|
2
3
|
"depositional-age": "_depositional-age_ngsgr_1",
|
|
3
4
|
"detrital-group": "_detrital-group_ngsgr_8",
|
|
@@ -5,7 +6,9 @@ const styles = {
|
|
|
5
6
|
"dz-spectra": "_dz-spectra_ngsgr_16",
|
|
6
7
|
"floating-axis": "_floating-axis_ngsgr_20"
|
|
7
8
|
};
|
|
9
|
+
let h = h$1.styled(styles);
|
|
10
|
+
Object.assign(h, styles);
|
|
8
11
|
export {
|
|
9
|
-
|
|
12
|
+
h as default
|
|
10
13
|
};
|
|
11
14
|
//# sourceMappingURL=index.module.sass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import h$1 from "@macrostrat/hyper";
|
|
2
2
|
import { useFossilData, FossilDataType } from "./provider.js";
|
|
3
3
|
import { ColumnAxisType } from "@macrostrat/column-components";
|
|
4
|
-
import
|
|
4
|
+
import h$2 from "./taxon-ranges.module.sass.js";
|
|
5
5
|
import { scaleLinear } from "d3-scale";
|
|
6
6
|
import { BaseMeasurementsColumn, groupNotesByPixelDistance, TruncatedList, standardizeMeasurementHeight } from "../measurements/base.js";
|
|
7
7
|
import { useMacrostratColumnData, useCompositeScale } from "../../data-provider/store.js";
|
|
8
8
|
import { getPositionWithinUnit, getUnitHeightRange } from "../../prepare-units/utils.js";
|
|
9
|
-
const h = h$1.styled(
|
|
9
|
+
const h = h$1.styled(h$2);
|
|
10
10
|
function PBDBFossilsColumn({
|
|
11
11
|
columnID,
|
|
12
12
|
type = FossilDataType.Collections
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/facets/fossils/index.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n FossilDataType,\n type PBDBCollection,\n type PBDBEntity,\n type PBDBOccurrence,\n useFossilData,\n} from \"./provider\";\nimport type { IUnit } from \"../../units\";\nimport {\n BaseMeasurementsColumn,\n ColumnMeasurementData,\n MeasurementHeightData,\n standardizeMeasurementHeight,\n groupNotesByPixelDistance,\n TruncatedList,\n} from \"../measurements\";\nimport { ColumnAxisType } from \"@macrostrat/column-components\";\nimport {\n useCompositeScale,\n useMacrostratColumnData,\n} from \"../../data-provider\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport styles from \"./taxon-ranges.module.sass\";\nimport {\n CompositeColumnScale,\n getPositionWithinUnit,\n getUnitHeightRange,\n} from \"../../prepare-units\";\nimport { scaleLinear } from \"d3-scale\";\n\nexport {\n FossilDataType,\n type PBDBCollection,\n type PBDBEntity,\n type PBDBOccurrence,\n useFossilData,\n};\nexport * from \"./taxon-ranges\";\n\nconst h = hyper.styled(styles);\n\nexport function PBDBFossilsColumn({\n columnID,\n type = FossilDataType.Collections,\n}: {\n columnID: number;\n type: FossilDataType;\n}) {\n const data = useFossilData(columnID, type);\n const { axisType, units } = useMacrostratColumnData();\n const scale = useCompositeScale();\n\n if (data == null || units == null || scale == null) return null;\n\n const data1 = preparePBDBData(data, units, scale, axisType);\n\n return h(BaseMeasurementsColumn, {\n data: data1,\n noteComponent: FossilInfo,\n focusedNoteComponent: FossilInfo,\n className: \"fossil-collections\",\n });\n}\n\ninterface FossilItemProps {\n note: {\n data: PBDBCollection[];\n unit?: IUnit;\n };\n spacing?: {\n below?: number;\n above?: number;\n };\n width?: number;\n height?: number;\n color?: string;\n focused?: boolean;\n maxItems?: number;\n}\n\nfunction FossilInfo(props: FossilItemProps) {\n const { note, maxItems, focused = false } = props;\n const { data } = note;\n // Sort collections by name\n data.sort((a, b) => {\n const nameA = a.best_name ?? a.cltn_name ?? \"\";\n const nameB = b.best_name ?? b.cltn_name ?? \"\";\n return nameA.localeCompare(nameB);\n });\n\n return h(TruncatedList, {\n data,\n className: \"fossil-collections\",\n itemRenderer: PBDBCollectionLink,\n maxItems: focused ? Infinity : (maxItems ?? 5),\n });\n}\n\nfunction PBDBCollectionLink({\n data,\n}: {\n data: PBDBCollection | PBDBOccurrence;\n}) {\n /** A link to a PBDB collection that handles either an occurrence or collection object */\n return h(\n \"a.link-id\",\n {\n href: `https://paleobiodb.org/app/collections#display=col:${data.cltn_id}`,\n target: \"_blank\",\n onClick(e) {\n e.stopPropagation();\n },\n },\n data.best_name ?? data.cltn_name,\n );\n}\n\ninterface PreparePBDBDataOptions {\n /** If set, group close notes within this distance (in pixels in display space)\n * into a single note. If a number is provided, that number is used as the distance,\n * otherwise a default of 5 pixels is used.\n */\n groupCloseNotes?: boolean | number;\n}\n\nfunction preparePBDBData<T extends PBDBEntity>(\n data: T[],\n units: UnitLong[],\n scale: CompositeColumnScale,\n axisType: ColumnAxisType,\n options?: PreparePBDBDataOptions,\n) {\n /** Prepare PBDB fossil data for display in a measurements column */\n const { groupCloseNotes = true } = options ?? {};\n const groupDistance =\n typeof groupCloseNotes === \"number\" ? groupCloseNotes : 10;\n\n // Map of data to its defined height ranges\n const dataMap = new Map<string, ColumnMeasurementData<T[]>>();\n\n // Todo: if we wanted, we could add a step where we group notes that are too close together here...\n\n for (const d of data) {\n const range = getHeightRangeForPBDBEntity(d, units, axisType);\n\n if (range == null) continue;\n const { height, top_height } = range;\n // compose the key based on height info\n let key = `${height}`;\n if (top_height != null) {\n key += `-${top_height}`;\n }\n\n // Group by height key\n if (!dataMap.has(key)) {\n dataMap.set(key, {\n height,\n top_height: top_height ?? height,\n data: [],\n id: key,\n });\n }\n dataMap.get(key)!.data.push(d);\n }\n\n return groupNotesByPixelDistance(\n Array.from(dataMap.values()),\n scale,\n axisType,\n groupDistance,\n );\n}\n\nfunction getHeightRangeForPBDBEntity<T extends PBDBEntity>(\n d: T,\n units: UnitLong[],\n axisType: ColumnAxisType,\n): MeasurementHeightData | null {\n let height: number | null = null;\n if (d.slb != null && d.slu == \"mbsf\") {\n // Meters below sea floor - special case for eODP where we have\n // specific depth data referenced\n height = Number(d.slb);\n if (axisType === ColumnAxisType.DEPTH) {\n // Data is already in depth units\n return { height };\n }\n }\n if (d.unit_id == null) return null;\n if (height != null) {\n // If we have both height and unit info, we need to adjust the height\n // to fit whatever scale type we're using.\n // TODO: we could improve how this works by having concurrent age and\n // height scales, which would allow us to do this without having to\n // reference to a specific unit.\n const unit = units.find((u) => u.unit_id === d.unit_id);\n if (unit == null) return null;\n const relHeight = getRelativePositionInUnit(\n height,\n unit,\n ColumnAxisType.DEPTH,\n );\n if (relHeight == null) return null;\n height = getPositionWithinUnit(relHeight, unit, axisType);\n return { height };\n }\n // We can just get the height within the unit, clipped to the unit boundaries\n return standardizeMeasurementHeight({ unit_id: d.unit_id }, units, axisType);\n}\n\nfunction getRelativePositionInUnit(\n pos: number,\n unit: UnitLong,\n axisType: ColumnAxisType,\n): number | null {\n // This is the inverse of getPositionWithinUnit\n const heights = getUnitHeightRange(unit, axisType, false);\n const scale = scaleLinear(heights).domain([0, 1]);\n const relPos = scale.invert(pos);\n if (relPos < 0 || relPos > 1) return null;\n return relPos;\n}\n"],"names":["hyper"],"mappings":";;;;;;;;AAwCA,MAAM,IAAIA,IAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/facets/fossils/index.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n FossilDataType,\n type PBDBCollection,\n type PBDBEntity,\n type PBDBOccurrence,\n useFossilData,\n} from \"./provider\";\nimport type { IUnit } from \"../../units\";\nimport {\n BaseMeasurementsColumn,\n ColumnMeasurementData,\n MeasurementHeightData,\n standardizeMeasurementHeight,\n groupNotesByPixelDistance,\n TruncatedList,\n} from \"../measurements\";\nimport { ColumnAxisType } from \"@macrostrat/column-components\";\nimport {\n useCompositeScale,\n useMacrostratColumnData,\n} from \"../../data-provider\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport styles from \"./taxon-ranges.module.sass\";\nimport {\n CompositeColumnScale,\n getPositionWithinUnit,\n getUnitHeightRange,\n} from \"../../prepare-units\";\nimport { scaleLinear } from \"d3-scale\";\n\nexport {\n FossilDataType,\n type PBDBCollection,\n type PBDBEntity,\n type PBDBOccurrence,\n useFossilData,\n};\nexport * from \"./taxon-ranges\";\n\nconst h = hyper.styled(styles);\n\nexport function PBDBFossilsColumn({\n columnID,\n type = FossilDataType.Collections,\n}: {\n columnID: number;\n type: FossilDataType;\n}) {\n const data = useFossilData(columnID, type);\n const { axisType, units } = useMacrostratColumnData();\n const scale = useCompositeScale();\n\n if (data == null || units == null || scale == null) return null;\n\n const data1 = preparePBDBData(data, units, scale, axisType);\n\n return h(BaseMeasurementsColumn, {\n data: data1,\n noteComponent: FossilInfo,\n focusedNoteComponent: FossilInfo,\n className: \"fossil-collections\",\n });\n}\n\ninterface FossilItemProps {\n note: {\n data: PBDBCollection[];\n unit?: IUnit;\n };\n spacing?: {\n below?: number;\n above?: number;\n };\n width?: number;\n height?: number;\n color?: string;\n focused?: boolean;\n maxItems?: number;\n}\n\nfunction FossilInfo(props: FossilItemProps) {\n const { note, maxItems, focused = false } = props;\n const { data } = note;\n // Sort collections by name\n data.sort((a, b) => {\n const nameA = a.best_name ?? a.cltn_name ?? \"\";\n const nameB = b.best_name ?? b.cltn_name ?? \"\";\n return nameA.localeCompare(nameB);\n });\n\n return h(TruncatedList, {\n data,\n className: \"fossil-collections\",\n itemRenderer: PBDBCollectionLink,\n maxItems: focused ? Infinity : (maxItems ?? 5),\n });\n}\n\nfunction PBDBCollectionLink({\n data,\n}: {\n data: PBDBCollection | PBDBOccurrence;\n}) {\n /** A link to a PBDB collection that handles either an occurrence or collection object */\n return h(\n \"a.link-id\",\n {\n href: `https://paleobiodb.org/app/collections#display=col:${data.cltn_id}`,\n target: \"_blank\",\n onClick(e) {\n e.stopPropagation();\n },\n },\n data.best_name ?? data.cltn_name,\n );\n}\n\ninterface PreparePBDBDataOptions {\n /** If set, group close notes within this distance (in pixels in display space)\n * into a single note. If a number is provided, that number is used as the distance,\n * otherwise a default of 5 pixels is used.\n */\n groupCloseNotes?: boolean | number;\n}\n\nfunction preparePBDBData<T extends PBDBEntity>(\n data: T[],\n units: UnitLong[],\n scale: CompositeColumnScale,\n axisType: ColumnAxisType,\n options?: PreparePBDBDataOptions,\n) {\n /** Prepare PBDB fossil data for display in a measurements column */\n const { groupCloseNotes = true } = options ?? {};\n const groupDistance =\n typeof groupCloseNotes === \"number\" ? groupCloseNotes : 10;\n\n // Map of data to its defined height ranges\n const dataMap = new Map<string, ColumnMeasurementData<T[]>>();\n\n // Todo: if we wanted, we could add a step where we group notes that are too close together here...\n\n for (const d of data) {\n const range = getHeightRangeForPBDBEntity(d, units, axisType);\n\n if (range == null) continue;\n const { height, top_height } = range;\n // compose the key based on height info\n let key = `${height}`;\n if (top_height != null) {\n key += `-${top_height}`;\n }\n\n // Group by height key\n if (!dataMap.has(key)) {\n dataMap.set(key, {\n height,\n top_height: top_height ?? height,\n data: [],\n id: key,\n });\n }\n dataMap.get(key)!.data.push(d);\n }\n\n return groupNotesByPixelDistance(\n Array.from(dataMap.values()),\n scale,\n axisType,\n groupDistance,\n );\n}\n\nfunction getHeightRangeForPBDBEntity<T extends PBDBEntity>(\n d: T,\n units: UnitLong[],\n axisType: ColumnAxisType,\n): MeasurementHeightData | null {\n let height: number | null = null;\n if (d.slb != null && d.slu == \"mbsf\") {\n // Meters below sea floor - special case for eODP where we have\n // specific depth data referenced\n height = Number(d.slb);\n if (axisType === ColumnAxisType.DEPTH) {\n // Data is already in depth units\n return { height };\n }\n }\n if (d.unit_id == null) return null;\n if (height != null) {\n // If we have both height and unit info, we need to adjust the height\n // to fit whatever scale type we're using.\n // TODO: we could improve how this works by having concurrent age and\n // height scales, which would allow us to do this without having to\n // reference to a specific unit.\n const unit = units.find((u) => u.unit_id === d.unit_id);\n if (unit == null) return null;\n const relHeight = getRelativePositionInUnit(\n height,\n unit,\n ColumnAxisType.DEPTH,\n );\n if (relHeight == null) return null;\n height = getPositionWithinUnit(relHeight, unit, axisType);\n return { height };\n }\n // We can just get the height within the unit, clipped to the unit boundaries\n return standardizeMeasurementHeight({ unit_id: d.unit_id }, units, axisType);\n}\n\nfunction getRelativePositionInUnit(\n pos: number,\n unit: UnitLong,\n axisType: ColumnAxisType,\n): number | null {\n // This is the inverse of getPositionWithinUnit\n const heights = getUnitHeightRange(unit, axisType, false);\n const scale = scaleLinear(heights).domain([0, 1]);\n const relPos = scale.invert(pos);\n if (relPos < 0 || relPos > 1) return null;\n return relPos;\n}\n"],"names":["hyper","styles"],"mappings":";;;;;;;;AAwCA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAEtB,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA,OAAO,eAAe;AACxB,GAGG;AACD,QAAM,OAAO,cAAc,UAAU,IAAI;AACzC,QAAM,EAAE,UAAU,MAAA,IAAU,wBAAA;AAC5B,QAAM,QAAQ,kBAAA;AAEd,MAAI,QAAQ,QAAQ,SAAS,QAAQ,SAAS,KAAM,QAAO;AAE3D,QAAM,QAAQ,gBAAgB,MAAM,OAAO,OAAO,QAAQ;AAE1D,SAAO,EAAE,wBAAwB;AAAA,IAC/B,MAAM;AAAA,IACN,eAAe;AAAA,IACf,sBAAsB;AAAA,IACtB,WAAW;AAA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YAAQ,IAAI,GAAG,EAAG,KAAK,KAAK,CAAC;AAAA,EAC/B;AAEA,SAAO;AAAA,IACL,MAAM,KAAK,QAAQ,QAAQ;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEA,SAAS,4BACP,GACA,OACA,UAC8B;AAC9B,MAAI,SAAwB;AAC5B,MAAI,EAAE,OAAO,QAAQ,EAAE,OAAO,QAAQ;AAGpC,aAAS,OAAO,EAAE,GAAG;AACrB,QAAI,aAAa,eAAe,OAAO;AAErC,aAAO,EAAE,OAAA;AAAA,IACX;AAAA,EACF;AACA,MAAI,EAAE,WAAW,KAAM,QAAO;AAC9B,MAAI,UAAU,MAAM;AAMlB,UAAM,OAAO,MAAM,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO;AACtD,QAAI,QAAQ,KAAM,QAAO;AACzB,UAAM,YAAY;AAAA,MAChB;AAAA,MACA;AAAA,MACA,eAAe;AAAA,IAAA;AAEjB,QAAI,aAAa,KAAM,QAAO;AAC9B,aAAS,sBAAsB,WAAW,MAAM,QAAQ;AACxD,WAAO,EAAE,OAAA;AAAA,EACX;AAEA,SAAO,6BAA6B,EAAE,SAAS,EAAE,QAAA,GAAW,OAAO,QAAQ;AAC7E;AAEA,SAAS,0BACP,KACA,MACA,UACe;AAEf,QAAM,UAAU,mBAAmB,MAAM,UAAU,KAAK;AACxD,QAAM,QAAQ,YAAY,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;AAChD,QAAM,SAAS,MAAM,OAAO,GAAG;AAC/B,MAAI,SAAS,KAAK,SAAS,EAAG,QAAO;AACrC,SAAO;AACT;"}
|
|
@@ -3,10 +3,10 @@ import { useFossilData, FossilDataType } from "./provider.js";
|
|
|
3
3
|
import { Box, useElementSize } from "@macrostrat/ui-components";
|
|
4
4
|
import { group } from "d3-array";
|
|
5
5
|
import { ColumnAxisType, ColumnSVG } from "@macrostrat/column-components";
|
|
6
|
-
import
|
|
6
|
+
import h$2 from "./taxon-ranges.module.sass.js";
|
|
7
7
|
import { useRef } from "react";
|
|
8
8
|
import { useMacrostratColumnData, useCompositeScale } from "../../data-provider/store.js";
|
|
9
|
-
const h = h$1.styled(
|
|
9
|
+
const h = h$1.styled(h$2);
|
|
10
10
|
function PBDBOccurrencesMatrix({ columnID }) {
|
|
11
11
|
const data = useFossilData(columnID, FossilDataType.Occurrences);
|
|
12
12
|
const col = useMacrostratColumnData();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taxon-ranges.js","sources":["../../../src/facets/fossils/taxon-ranges.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n FossilDataType,\n PBDBEntity,\n PBDBOccurrence,\n useFossilData,\n} from \"./provider\";\nimport { Box, useElementSize } from \"@macrostrat/ui-components\";\nimport { group } from \"d3-array\";\nimport { ColumnAxisType, ColumnSVG } from \"@macrostrat/column-components\";\nimport {\n useMacrostratColumnData,\n useCompositeScale,\n} from \"../../data-provider\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport styles from \"./taxon-ranges.module.sass\";\nimport { useRef } from \"react\";\n\nconst h = hyper.styled(styles);\n\nexport function PBDBOccurrencesMatrix({ columnID }) {\n /* A column for a matrix of taxon occurrences displayed as a table beside the main column. This will\n eventually be extended with first/last occurrence markers and range bars.\n */\n const data = useFossilData(columnID, FossilDataType.Occurrences);\n const col = useMacrostratColumnData();\n const scale = useCompositeScale();\n\n if (data == null) return null;\n\n // convert the data to a map\n const occurrenceMap = new Map(group(data, (d) => d.unit_id)) as Map<\n number,\n PBDBOccurrence[]\n >;\n\n const matrix = createOccurrenceMatrix(col.units, occurrenceMap, col.axisType);\n\n const { taxonRanges } = matrix;\n\n const padding = 16;\n const spacing = 16;\n\n const taxonEntries = Array.from(taxonRanges.entries());\n //const taxon = taxonEntries.slice(0, 50); // limit to top 50 taxa\n\n const width = padding * 2 + spacing * taxonEntries.length;\n\n return h(Box, { className: \"taxon-ranges\", width, height: col.totalHeight }, [\n h(TaxonOccurrenceLabels, {\n taxonEntries,\n padding,\n spacing,\n scale,\n }),\n h(\n ColumnSVG,\n {\n width: padding * 2 + spacing * taxonEntries.length,\n },\n h(\n \"g.taxa-occurrences-matrix\",\n taxonEntries.map(([taxonName, ranges], rowIndex) => {\n const xPosition = padding + rowIndex * spacing;\n return h(\"g\", { transform: `translate(${xPosition})` }, [\n ranges.map(([top, bottom]) => {\n return h(\"line\", {\n y1: scale(top),\n y2: scale(bottom),\n });\n }),\n ]);\n }),\n ),\n ),\n ]);\n}\n\nfunction TaxonOccurrenceLabels({ taxonEntries, padding, spacing, scale }) {\n return h(\"div.taxon-labels\", [\n taxonEntries.map(([taxonName, ranges], rowIndex) => {\n const top = ranges[0]?.[0] ?? 0;\n let topPx = scale(top) - 20;\n if (topPx < 200) topPx = 0;\n\n return h(TaxonLabel, {\n top: topPx,\n left: padding + rowIndex * spacing,\n taxonName,\n });\n }),\n ]);\n}\n\nfunction TaxonLabel({ top, left, taxonName }) {\n const ref = useRef();\n const textSize = useElementSize(ref);\n const labelWidth = textSize?.height ?? 200;\n return h(\n \"div.taxon-label\",\n {\n style: {\n top: `${top}px`,\n marginLeft: `${left}px`,\n \"--label-width\": `${labelWidth}px`,\n },\n },\n h(\"div.taxon-label-inner\", h(\"div.taxon-label-text\", { ref }, taxonName)),\n );\n}\n\ntype TaxonUnitMap = Map<string, Set<number>>;\n\ninterface OccurrenceMatrixData {\n occurrenceMap: Map<number, PBDBEntity[]>; // Map of unit IDs to occurrences (original data)\n taxonUnitMap: TaxonUnitMap; // Map of taxon names to sets of unit IDs\n taxonOccurrenceMap: Map<string, PBDBOccurrence[]>; // Map of taxon names to occurrences\n taxonRanges: Map<string, [number, number][]>; // Map of taxon names to [top, bottom] pixel ranges\n}\n\nfunction TaxonOccurrenceEntry({\n xPosition,\n ranges,\n scale,\n name,\n}: {\n xPosition: number;\n units: Set<number>;\n ranges: any;\n scale: any;\n name: string;\n}) {\n return h(\"g\", { transform: `translate(${xPosition})` }, [\n ranges.map(([top, bottom]) => {\n return h(\"line\", {\n y1: scale(top),\n y2: scale(bottom),\n });\n }),\n ]);\n}\n\nfunction createOccurrenceMatrix(\n units: UnitLong[],\n data: Map<number, PBDBOccurrence[]>,\n axisType: ColumnAxisType = ColumnAxisType.AGE,\n): OccurrenceMatrixData {\n const taxonUnitMap = new Map<string, Set<number>>();\n const taxonOccurrenceMap = new Map<string, PBDBOccurrence[]>();\n\n for (const [unit_id, occurrences] of data.entries()) {\n for (const occ of occurrences) {\n const taxonName = occ.best_name ?? occ.taxon_name;\n if (!taxonUnitMap.has(taxonName)) {\n taxonUnitMap.set(taxonName, new Set());\n taxonOccurrenceMap.set(taxonName, []);\n }\n taxonUnitMap.get(taxonName).add(unit_id);\n taxonOccurrenceMap.get(taxonName).push(occ);\n }\n }\n\n // sort the taxon occurrence map by number of occurrences\n const sortedTaxa = Array.from(taxonUnitMap.entries()).sort((a, b) => {\n // Sort alphabetically by taxon name\n return b[0].localeCompare(a[0]);\n });\n\n const taxonRanges = new Map<string, [number, number][]>();\n for (const [taxonName, unitSet] of taxonUnitMap.entries()) {\n taxonRanges.set(\n taxonName,\n accumulatePresenceDomains(units, unitSet, axisType),\n );\n }\n\n return {\n occurrenceMap: data,\n taxonUnitMap: new Map(sortedTaxa),\n taxonOccurrenceMap: taxonOccurrenceMap,\n taxonRanges,\n };\n}\n\nfunction accumulatePresenceDomains(\n unit: UnitLong[],\n presenceUnits: Set<number>,\n axisType: ColumnAxisType,\n): Array<[number, number]> {\n const domains: Array<[number, number]> = [];\n let currentDomain: [number, number] | null = null;\n\n for (const u of unit) {\n if (presenceUnits.has(u.unit_id)) {\n if (currentDomain == null) {\n if (\n axisType == ColumnAxisType.DEPTH ||\n axisType == ColumnAxisType.HEIGHT\n ) {\n currentDomain = [u.t_pos, u.b_pos];\n } else {\n currentDomain = [u.t_age, u.b_age];\n }\n } else {\n if (\n axisType == ColumnAxisType.DEPTH ||\n axisType == ColumnAxisType.HEIGHT\n ) {\n currentDomain[1] = u.b_pos;\n } else {\n currentDomain[1] = u.b_age;\n }\n }\n } else {\n if (currentDomain != null) {\n domains.push(currentDomain);\n currentDomain = null;\n }\n }\n }\n\n if (currentDomain != null) {\n domains.push(currentDomain);\n }\n\n return domains;\n}\n"],"names":["hyper"],"mappings":";;;;;;;;AAkBA,MAAM,IAAIA,IAAM,
|
|
1
|
+
{"version":3,"file":"taxon-ranges.js","sources":["../../../src/facets/fossils/taxon-ranges.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n FossilDataType,\n PBDBEntity,\n PBDBOccurrence,\n useFossilData,\n} from \"./provider\";\nimport { Box, useElementSize } from \"@macrostrat/ui-components\";\nimport { group } from \"d3-array\";\nimport { ColumnAxisType, ColumnSVG } from \"@macrostrat/column-components\";\nimport {\n useMacrostratColumnData,\n useCompositeScale,\n} from \"../../data-provider\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport styles from \"./taxon-ranges.module.sass\";\nimport { useRef } from \"react\";\n\nconst h = hyper.styled(styles);\n\nexport function PBDBOccurrencesMatrix({ columnID }) {\n /* A column for a matrix of taxon occurrences displayed as a table beside the main column. This will\n eventually be extended with first/last occurrence markers and range bars.\n */\n const data = useFossilData(columnID, FossilDataType.Occurrences);\n const col = useMacrostratColumnData();\n const scale = useCompositeScale();\n\n if (data == null) return null;\n\n // convert the data to a map\n const occurrenceMap = new Map(group(data, (d) => d.unit_id)) as Map<\n number,\n PBDBOccurrence[]\n >;\n\n const matrix = createOccurrenceMatrix(col.units, occurrenceMap, col.axisType);\n\n const { taxonRanges } = matrix;\n\n const padding = 16;\n const spacing = 16;\n\n const taxonEntries = Array.from(taxonRanges.entries());\n //const taxon = taxonEntries.slice(0, 50); // limit to top 50 taxa\n\n const width = padding * 2 + spacing * taxonEntries.length;\n\n return h(Box, { className: \"taxon-ranges\", width, height: col.totalHeight }, [\n h(TaxonOccurrenceLabels, {\n taxonEntries,\n padding,\n spacing,\n scale,\n }),\n h(\n ColumnSVG,\n {\n width: padding * 2 + spacing * taxonEntries.length,\n },\n h(\n \"g.taxa-occurrences-matrix\",\n taxonEntries.map(([taxonName, ranges], rowIndex) => {\n const xPosition = padding + rowIndex * spacing;\n return h(\"g\", { transform: `translate(${xPosition})` }, [\n ranges.map(([top, bottom]) => {\n return h(\"line\", {\n y1: scale(top),\n y2: scale(bottom),\n });\n }),\n ]);\n }),\n ),\n ),\n ]);\n}\n\nfunction TaxonOccurrenceLabels({ taxonEntries, padding, spacing, scale }) {\n return h(\"div.taxon-labels\", [\n taxonEntries.map(([taxonName, ranges], rowIndex) => {\n const top = ranges[0]?.[0] ?? 0;\n let topPx = scale(top) - 20;\n if (topPx < 200) topPx = 0;\n\n return h(TaxonLabel, {\n top: topPx,\n left: padding + rowIndex * spacing,\n taxonName,\n });\n }),\n ]);\n}\n\nfunction TaxonLabel({ top, left, taxonName }) {\n const ref = useRef();\n const textSize = useElementSize(ref);\n const labelWidth = textSize?.height ?? 200;\n return h(\n \"div.taxon-label\",\n {\n style: {\n top: `${top}px`,\n marginLeft: `${left}px`,\n \"--label-width\": `${labelWidth}px`,\n },\n },\n h(\"div.taxon-label-inner\", h(\"div.taxon-label-text\", { ref }, taxonName)),\n );\n}\n\ntype TaxonUnitMap = Map<string, Set<number>>;\n\ninterface OccurrenceMatrixData {\n occurrenceMap: Map<number, PBDBEntity[]>; // Map of unit IDs to occurrences (original data)\n taxonUnitMap: TaxonUnitMap; // Map of taxon names to sets of unit IDs\n taxonOccurrenceMap: Map<string, PBDBOccurrence[]>; // Map of taxon names to occurrences\n taxonRanges: Map<string, [number, number][]>; // Map of taxon names to [top, bottom] pixel ranges\n}\n\nfunction TaxonOccurrenceEntry({\n xPosition,\n ranges,\n scale,\n name,\n}: {\n xPosition: number;\n units: Set<number>;\n ranges: any;\n scale: any;\n name: string;\n}) {\n return h(\"g\", { transform: `translate(${xPosition})` }, [\n ranges.map(([top, bottom]) => {\n return h(\"line\", {\n y1: scale(top),\n y2: scale(bottom),\n });\n }),\n ]);\n}\n\nfunction createOccurrenceMatrix(\n units: UnitLong[],\n data: Map<number, PBDBOccurrence[]>,\n axisType: ColumnAxisType = ColumnAxisType.AGE,\n): OccurrenceMatrixData {\n const taxonUnitMap = new Map<string, Set<number>>();\n const taxonOccurrenceMap = new Map<string, PBDBOccurrence[]>();\n\n for (const [unit_id, occurrences] of data.entries()) {\n for (const occ of occurrences) {\n const taxonName = occ.best_name ?? occ.taxon_name;\n if (!taxonUnitMap.has(taxonName)) {\n taxonUnitMap.set(taxonName, new Set());\n taxonOccurrenceMap.set(taxonName, []);\n }\n taxonUnitMap.get(taxonName).add(unit_id);\n taxonOccurrenceMap.get(taxonName).push(occ);\n }\n }\n\n // sort the taxon occurrence map by number of occurrences\n const sortedTaxa = Array.from(taxonUnitMap.entries()).sort((a, b) => {\n // Sort alphabetically by taxon name\n return b[0].localeCompare(a[0]);\n });\n\n const taxonRanges = new Map<string, [number, number][]>();\n for (const [taxonName, unitSet] of taxonUnitMap.entries()) {\n taxonRanges.set(\n taxonName,\n accumulatePresenceDomains(units, unitSet, axisType),\n );\n }\n\n return {\n occurrenceMap: data,\n taxonUnitMap: new Map(sortedTaxa),\n taxonOccurrenceMap: taxonOccurrenceMap,\n taxonRanges,\n };\n}\n\nfunction accumulatePresenceDomains(\n unit: UnitLong[],\n presenceUnits: Set<number>,\n axisType: ColumnAxisType,\n): Array<[number, number]> {\n const domains: Array<[number, number]> = [];\n let currentDomain: [number, number] | null = null;\n\n for (const u of unit) {\n if (presenceUnits.has(u.unit_id)) {\n if (currentDomain == null) {\n if (\n axisType == ColumnAxisType.DEPTH ||\n axisType == ColumnAxisType.HEIGHT\n ) {\n currentDomain = [u.t_pos, u.b_pos];\n } else {\n currentDomain = [u.t_age, u.b_age];\n }\n } else {\n if (\n axisType == ColumnAxisType.DEPTH ||\n axisType == ColumnAxisType.HEIGHT\n ) {\n currentDomain[1] = u.b_pos;\n } else {\n currentDomain[1] = u.b_age;\n }\n }\n } else {\n if (currentDomain != null) {\n domains.push(currentDomain);\n currentDomain = null;\n }\n }\n }\n\n if (currentDomain != null) {\n domains.push(currentDomain);\n }\n\n return domains;\n}\n"],"names":["hyper","styles"],"mappings":";;;;;;;;AAkBA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAEtB,SAAS,sBAAsB,EAAE,YAAY;AAIlD,QAAM,OAAO,cAAc,UAAU,eAAe,WAAW;AAC/D,QAAM,MAAM,wBAAA;AACZ,QAAM,QAAQ,kBAAA;AAEd,MAAI,QAAQ,KAAM,QAAO;AAGzB,QAAM,gBAAgB,IAAI,IAAI,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;AAK3D,QAAM,SAAS,uBAAuB,IAAI,OAAO,eAAe,IAAI,QAAQ;AAE5E,QAAM,EAAE,gBAAgB;AAExB,QAAM,UAAU;AAChB,QAAM,UAAU;AAEhB,QAAM,eAAe,MAAM,KAAK,YAAY,SAAS;AAGrD,QAAM,QAAQ,UAAU,IAAI,UAAU,aAAa;AAEnD,SAAO,EAAE,KAAK,EAAE,WAAW,gBAAgB,OAAO,QAAQ,IAAI,eAAe;AAAA,IAC3E,EAAE,uBAAuB;AAAA,MACvB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,IACD;AAAA,MACE;AAAA,MACA;AAAA,QACE,OAAO,UAAU,IAAI,UAAU,aAAa;AAAA,MAAA;AAAA,MAE9C;AAAA,QACE;AAAA,QACA,aAAa,IAAI,CAAC,CAAC,WAAW,MAAM,GAAG,aAAa;AAClD,gBAAM,YAAY,UAAU,WAAW;AACvC,iBAAO,EAAE,KAAK,EAAE,WAAW,aAAa,SAAS,OAAO;AAAA,YACtD,OAAO,IAAI,CAAC,CAAC,KAAK,MAAM,MAAM;AAC5B,qBAAO,EAAE,QAAQ;AAAA,gBACf,IAAI,MAAM,GAAG;AAAA,gBACb,IAAI,MAAM,MAAM;AAAA,cAAA,CACjB;AAAA,YACH,CAAC;AAAA,UAAA,CAC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use strict";
|
|
2
|
+
const h$1 = require("@macrostrat/hyper");
|
|
3
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
4
|
+
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
2
5
|
const styles = {
|
|
3
6
|
"taxa-occurrences-matrix": "_taxa-occurrences-matrix_14h8h_1",
|
|
4
7
|
"taxon-name": "_taxon-name_14h8h_8",
|
|
@@ -8,5 +11,7 @@ const styles = {
|
|
|
8
11
|
"taxon-label-inner": "_taxon-label-inner_14h8h_35",
|
|
9
12
|
"taxon-label-text": "_taxon-label-text_14h8h_42"
|
|
10
13
|
};
|
|
11
|
-
|
|
14
|
+
let h = h__default.default.styled(styles);
|
|
15
|
+
Object.assign(h, styles);
|
|
16
|
+
module.exports = h;
|
|
12
17
|
//# sourceMappingURL=taxon-ranges.module.sass.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taxon-ranges.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"taxon-ranges.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import h$1 from "@macrostrat/hyper";
|
|
1
2
|
const styles = {
|
|
2
3
|
"taxa-occurrences-matrix": "_taxa-occurrences-matrix_14h8h_1",
|
|
3
4
|
"taxon-name": "_taxon-name_14h8h_8",
|
|
@@ -7,7 +8,9 @@ const styles = {
|
|
|
7
8
|
"taxon-label-inner": "_taxon-label-inner_14h8h_35",
|
|
8
9
|
"taxon-label-text": "_taxon-label-text_14h8h_42"
|
|
9
10
|
};
|
|
11
|
+
let h = h$1.styled(styles);
|
|
12
|
+
Object.assign(h, styles);
|
|
10
13
|
export {
|
|
11
|
-
|
|
14
|
+
h as default
|
|
12
15
|
};
|
|
13
16
|
//# sourceMappingURL=taxon-ranges.module.sass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taxon-ranges.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"taxon-ranges.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import h$1 from "@macrostrat/hyper";
|
|
2
|
-
import
|
|
2
|
+
import h$2 from "./base.module.sass.js";
|
|
3
3
|
import { ColumnNotes } from "../../notes.js";
|
|
4
4
|
import { ColumnAxisType } from "@macrostrat/column-components";
|
|
5
5
|
import { getPositionWithinUnit, getUnitHeightRange } from "../../prepare-units/utils.js";
|
|
6
|
-
const h = h$1.styled(
|
|
6
|
+
const h = h$1.styled(h$2);
|
|
7
7
|
function standardizeMeasurementHeight(pos, units, axisType) {
|
|
8
8
|
if ("height" in pos) {
|
|
9
9
|
return pos;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sources":["../../../src/facets/measurements/base.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport styles from \"./base.module.sass\";\nimport {\n type CompositeColumnScale,\n getPositionWithinUnit,\n getUnitHeightRange,\n} from \"../../prepare-units\";\nimport { ColumnNotes } from \"../../notes\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport { ColumnAxisType } from \"@macrostrat/column-components\";\nconst h = hyper.styled(styles);\n\ntype GetHeightRangeFn<T> = (\n data: T,\n unit: UnitLong | null,\n axisType: ColumnAxisType,\n) => MeasurementHeightData;\n\nexport interface BaseMeasurementsColumnProps<T> {\n data: T[];\n noteComponent?: any;\n width?: number;\n paddingLeft?: number;\n className?: string;\n // TODO: these props are confusing\n getUnitID?: (d: T) => number | string;\n isMatchingUnit?: (d: T, unit: UnitLong) => boolean;\n getHeightRange?: GetHeightRangeFn<T>;\n deltaConnectorAttachment?: number;\n focusedNoteComponent?: any;\n}\n\nexport interface ColumnMeasurementData<T = any> extends MeasurementHeightData {\n data: T;\n id: string | number;\n}\n\ntype MeasurementPositionInformation =\n | MeasurementHeightData\n | {\n unit_id: number;\n unit_rel_pos?: number;\n };\n\nexport function standardizeMeasurementHeight(\n pos: MeasurementPositionInformation,\n units: UnitLong[],\n axisType: ColumnAxisType,\n): MeasurementHeightData | null {\n /** Get a standardized height representation from position information for\n * a measurement\n */\n if (\"height\" in pos) {\n return pos;\n }\n const unit = units.find((u) => u.unit_id === pos.unit_id);\n if (unit == null) {\n return null;\n }\n if (pos.unit_rel_pos != null) {\n const res = getPositionWithinUnit(pos.unit_rel_pos, unit, axisType);\n if (res == null) return null;\n return { height: res };\n } else {\n const [height, top_height] = getUnitHeightRange(unit, axisType);\n return { height, top_height };\n }\n}\n\nexport function mergeHeightRanges(\n data: MeasurementHeightData[],\n axisType: ColumnAxisType,\n): MeasurementHeightData {\n /** Merge multiple height ranges into a single range */\n const heights = [];\n\n for (const d of data) {\n heights.push(d.height);\n if (d.top_height != null) {\n heights.push(d.top_height);\n }\n }\n\n let height: number;\n let top_height: number;\n if (axisType === ColumnAxisType.AGE || axisType === ColumnAxisType.DEPTH) {\n height = Math.max(...heights);\n top_height = Math.min(...heights);\n } else {\n height = Math.min(...heights);\n top_height = Math.max(...heights);\n }\n\n if (top_height === height) {\n return { height };\n }\n return { height, top_height };\n}\n\nexport type MeasurementHeightData = {\n height: number;\n top_height?: number | null;\n};\n\nexport function BaseMeasurementsColumn({\n data,\n noteComponent,\n width = 500,\n paddingLeft = 40,\n className,\n deltaConnectorAttachment,\n focusedNoteComponent,\n}: BaseMeasurementsColumnProps<any>) {\n if (data == null) return null;\n\n return h(\n \"div.measurements-column\",\n { className },\n h(ColumnNotes, {\n width,\n paddingLeft,\n notes: data,\n noteComponent,\n deltaConnectorAttachment,\n focusedNoteComponent,\n }),\n );\n}\n\ninterface TruncatedListProps {\n data: any[];\n className?: string;\n maxItems?: number;\n itemRenderer?: (props: { data: any }) => any;\n}\n\nexport function TruncatedList({\n data,\n className,\n maxItems = 5,\n itemRenderer = (p) => h(\"span\", p.data),\n}: TruncatedListProps) {\n let tooMany = null;\n let d1 = data;\n if (data.length > maxItems) {\n const n = data.length - maxItems;\n d1 = data.slice(0, maxItems);\n tooMany = h(\"li.too-many\", `and ${n} more`);\n }\n\n return h(\"ul.truncated-list\", { className }, [\n d1.map((d, i) => {\n return h(\"li.element\", { key: i }, h(itemRenderer, { data: d }));\n }),\n tooMany,\n ]);\n}\n\nexport function groupNotesByPixelDistance<T = any>(\n data: ColumnMeasurementData<T[]>[],\n scale: CompositeColumnScale,\n axisType: ColumnAxisType,\n groupDistance: number,\n) {\n /** Group notes that are within a certain pixel distance of each other\n * in display space\n */\n if (data.length === 0 || groupDistance <= 0) return data;\n if (axisType === ColumnAxisType.AGE || axisType === ColumnAxisType.DEPTH) {\n data.sort((a, b) => b.height - a.height);\n } else {\n // Sort data by height (ascending up the column)\n data.sort((a, b) => a.height - b.height);\n }\n\n const groupedData: ColumnMeasurementData<T[]>[] = [];\n let currentGroup: ColumnMeasurementData<T[]> | null = null;\n let currentGroupPosition: number = Infinity;\n\n for (const d of data) {\n // Check distance from current max position\n // Pixels go up as we go down in the section\n\n // The _top_ of the next group must be within groupDistance of the\n // _bottom_ of the current group. This makes sure that we don't collapse\n // groups that are separated by a large distance\n const distance = currentGroupPosition - scale(d.top_height ?? d.height);\n\n if (distance <= groupDistance) {\n if (currentGroup == null) {\n throw new Error(\"Current group is null when it shouldn't be\");\n }\n // Merge into current group\n currentGroup.data.push(...d.data);\n // Update height range\n const top_height = d.top_height ?? d.height;\n if (\n axisType === ColumnAxisType.AGE ||\n axisType === ColumnAxisType.DEPTH\n ) {\n // Inverted axis\n currentGroup.top_height = Math.min(currentGroup.top_height, top_height);\n } else {\n currentGroup.top_height = Math.max(currentGroup.top_height, top_height);\n }\n currentGroup.id = `${currentGroup.height}-${currentGroup.top_height}`;\n } else {\n // Start a new group\n currentGroup = { ...d, data: [...d.data] };\n currentGroupPosition =\n scale(currentGroup.height) ??\n scale(currentGroup.top_height) ??\n Infinity;\n groupedData.push(currentGroup);\n }\n }\n\n return groupedData;\n}\n"],"names":["hyper"],"mappings":";;;;;AAUA,MAAM,IAAIA,IAAM,
|
|
1
|
+
{"version":3,"file":"base.js","sources":["../../../src/facets/measurements/base.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport styles from \"./base.module.sass\";\nimport {\n type CompositeColumnScale,\n getPositionWithinUnit,\n getUnitHeightRange,\n} from \"../../prepare-units\";\nimport { ColumnNotes } from \"../../notes\";\nimport { UnitLong } from \"@macrostrat/api-types\";\nimport { ColumnAxisType } from \"@macrostrat/column-components\";\nconst h = hyper.styled(styles);\n\ntype GetHeightRangeFn<T> = (\n data: T,\n unit: UnitLong | null,\n axisType: ColumnAxisType,\n) => MeasurementHeightData;\n\nexport interface BaseMeasurementsColumnProps<T> {\n data: T[];\n noteComponent?: any;\n width?: number;\n paddingLeft?: number;\n className?: string;\n // TODO: these props are confusing\n getUnitID?: (d: T) => number | string;\n isMatchingUnit?: (d: T, unit: UnitLong) => boolean;\n getHeightRange?: GetHeightRangeFn<T>;\n deltaConnectorAttachment?: number;\n focusedNoteComponent?: any;\n}\n\nexport interface ColumnMeasurementData<T = any> extends MeasurementHeightData {\n data: T;\n id: string | number;\n}\n\ntype MeasurementPositionInformation =\n | MeasurementHeightData\n | {\n unit_id: number;\n unit_rel_pos?: number;\n };\n\nexport function standardizeMeasurementHeight(\n pos: MeasurementPositionInformation,\n units: UnitLong[],\n axisType: ColumnAxisType,\n): MeasurementHeightData | null {\n /** Get a standardized height representation from position information for\n * a measurement\n */\n if (\"height\" in pos) {\n return pos;\n }\n const unit = units.find((u) => u.unit_id === pos.unit_id);\n if (unit == null) {\n return null;\n }\n if (pos.unit_rel_pos != null) {\n const res = getPositionWithinUnit(pos.unit_rel_pos, unit, axisType);\n if (res == null) return null;\n return { height: res };\n } else {\n const [height, top_height] = getUnitHeightRange(unit, axisType);\n return { height, top_height };\n }\n}\n\nexport function mergeHeightRanges(\n data: MeasurementHeightData[],\n axisType: ColumnAxisType,\n): MeasurementHeightData {\n /** Merge multiple height ranges into a single range */\n const heights = [];\n\n for (const d of data) {\n heights.push(d.height);\n if (d.top_height != null) {\n heights.push(d.top_height);\n }\n }\n\n let height: number;\n let top_height: number;\n if (axisType === ColumnAxisType.AGE || axisType === ColumnAxisType.DEPTH) {\n height = Math.max(...heights);\n top_height = Math.min(...heights);\n } else {\n height = Math.min(...heights);\n top_height = Math.max(...heights);\n }\n\n if (top_height === height) {\n return { height };\n }\n return { height, top_height };\n}\n\nexport type MeasurementHeightData = {\n height: number;\n top_height?: number | null;\n};\n\nexport function BaseMeasurementsColumn({\n data,\n noteComponent,\n width = 500,\n paddingLeft = 40,\n className,\n deltaConnectorAttachment,\n focusedNoteComponent,\n}: BaseMeasurementsColumnProps<any>) {\n if (data == null) return null;\n\n return h(\n \"div.measurements-column\",\n { className },\n h(ColumnNotes, {\n width,\n paddingLeft,\n notes: data,\n noteComponent,\n deltaConnectorAttachment,\n focusedNoteComponent,\n }),\n );\n}\n\ninterface TruncatedListProps {\n data: any[];\n className?: string;\n maxItems?: number;\n itemRenderer?: (props: { data: any }) => any;\n}\n\nexport function TruncatedList({\n data,\n className,\n maxItems = 5,\n itemRenderer = (p) => h(\"span\", p.data),\n}: TruncatedListProps) {\n let tooMany = null;\n let d1 = data;\n if (data.length > maxItems) {\n const n = data.length - maxItems;\n d1 = data.slice(0, maxItems);\n tooMany = h(\"li.too-many\", `and ${n} more`);\n }\n\n return h(\"ul.truncated-list\", { className }, [\n d1.map((d, i) => {\n return h(\"li.element\", { key: i }, h(itemRenderer, { data: d }));\n }),\n tooMany,\n ]);\n}\n\nexport function groupNotesByPixelDistance<T = any>(\n data: ColumnMeasurementData<T[]>[],\n scale: CompositeColumnScale,\n axisType: ColumnAxisType,\n groupDistance: number,\n) {\n /** Group notes that are within a certain pixel distance of each other\n * in display space\n */\n if (data.length === 0 || groupDistance <= 0) return data;\n if (axisType === ColumnAxisType.AGE || axisType === ColumnAxisType.DEPTH) {\n data.sort((a, b) => b.height - a.height);\n } else {\n // Sort data by height (ascending up the column)\n data.sort((a, b) => a.height - b.height);\n }\n\n const groupedData: ColumnMeasurementData<T[]>[] = [];\n let currentGroup: ColumnMeasurementData<T[]> | null = null;\n let currentGroupPosition: number = Infinity;\n\n for (const d of data) {\n // Check distance from current max position\n // Pixels go up as we go down in the section\n\n // The _top_ of the next group must be within groupDistance of the\n // _bottom_ of the current group. This makes sure that we don't collapse\n // groups that are separated by a large distance\n const distance = currentGroupPosition - scale(d.top_height ?? d.height);\n\n if (distance <= groupDistance) {\n if (currentGroup == null) {\n throw new Error(\"Current group is null when it shouldn't be\");\n }\n // Merge into current group\n currentGroup.data.push(...d.data);\n // Update height range\n const top_height = d.top_height ?? d.height;\n if (\n axisType === ColumnAxisType.AGE ||\n axisType === ColumnAxisType.DEPTH\n ) {\n // Inverted axis\n currentGroup.top_height = Math.min(currentGroup.top_height, top_height);\n } else {\n currentGroup.top_height = Math.max(currentGroup.top_height, top_height);\n }\n currentGroup.id = `${currentGroup.height}-${currentGroup.top_height}`;\n } else {\n // Start a new group\n currentGroup = { ...d, data: [...d.data] };\n currentGroupPosition =\n scale(currentGroup.height) ??\n scale(currentGroup.top_height) ??\n Infinity;\n groupedData.push(currentGroup);\n }\n }\n\n return groupedData;\n}\n"],"names":["hyper","styles"],"mappings":";;;;;AAUA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAkCtB,SAAS,6BACd,KACA,OACA,UAC8B;AAI9B,MAAI,YAAY,KAAK;AACnB,WAAO;AAAA,EACT;AACA,QAAM,OAAO,MAAM,KAAK,CAAC,MAAM,EAAE,YAAY,IAAI,OAAO;AACxD,MAAI,QAAQ,MAAM;AAChB,WAAO;AAAA,EACT;AACA,MAAI,IAAI,gBAAgB,MAAM;AAC5B,UAAM,MAAM,sBAAsB,IAAI,cAAc,MAAM,QAAQ;AAClE,QAAI,OAAO,KAAM,QAAO;AACxB,WAAO,EAAE,QAAQ,IAAA;AAAA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6BACE,MAAM,aAAa,MAAM,KACzB,MAAM,aAAa,UAAU,KAC7B;AACF,kBAAY,KAAK,YAAY;AAAA,IAC/B;AAAA,EACF;AAEA,SAAO;AACT;"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const h$1 = require("@macrostrat/hyper");
|
|
3
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
4
|
+
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
2
5
|
const styles = {
|
|
3
6
|
"truncated-list": "_truncated-list_120po_1",
|
|
4
7
|
"too-many": "_too-many_120po_16"
|
|
5
8
|
};
|
|
6
|
-
|
|
9
|
+
let h = h__default.default.styled(styles);
|
|
10
|
+
Object.assign(h, styles);
|
|
11
|
+
module.exports = h;
|
|
7
12
|
//# sourceMappingURL=base.module.sass.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import h$1 from "@macrostrat/hyper";
|
|
1
2
|
const styles = {
|
|
2
3
|
"truncated-list": "_truncated-list_120po_1",
|
|
3
4
|
"too-many": "_too-many_120po_16"
|
|
4
5
|
};
|
|
6
|
+
let h = h$1.styled(styles);
|
|
7
|
+
Object.assign(h, styles);
|
|
5
8
|
export {
|
|
6
|
-
|
|
9
|
+
h as default
|
|
7
10
|
};
|
|
8
11
|
//# sourceMappingURL=base.module.sass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const index = require("./units/index.cjs");
|
|
4
4
|
const ageAxis = require("./age-axis.cjs");
|
|
5
|
-
const index$
|
|
5
|
+
const index$6 = require("./prepare-units/index.cjs");
|
|
6
6
|
const column = require("./column.cjs");
|
|
7
7
|
const ageModelOverlay = require("./age-model-overlay.cjs");
|
|
8
8
|
const notes = require("./notes.cjs");
|
|
@@ -22,9 +22,10 @@ const types = require("./prepare-units/types.cjs");
|
|
|
22
22
|
const insetMap = require("./maps/_shared/inset-map.cjs");
|
|
23
23
|
const isotopesColumn = require("./facets/carbon-isotopes/isotopes-column.cjs");
|
|
24
24
|
const store = require("./data-provider/store.cjs");
|
|
25
|
+
const index$4 = require("./maps/units-overlay/index.cjs");
|
|
25
26
|
const dataProvider = require("./facets/carbon-isotopes/data-provider.cjs");
|
|
26
27
|
const utils = require("./prepare-units/utils.cjs");
|
|
27
|
-
const index$
|
|
28
|
+
const index$5 = require("./facets/fossils/index.cjs");
|
|
28
29
|
const taxonRanges = require("./facets/fossils/taxon-ranges.cjs");
|
|
29
30
|
const sgp = require("./facets/measurements/sgp.cjs");
|
|
30
31
|
const modalPanel = require("./unit-details/modal-panel.cjs");
|
|
@@ -47,8 +48,8 @@ exports.ApproximateHeightAxis = ageAxis.ApproximateHeightAxis;
|
|
|
47
48
|
exports.CompositeAgeAxis = ageAxis.CompositeAgeAxis;
|
|
48
49
|
exports.CompositeAgeAxisCore = ageAxis.CompositeAgeAxisCore;
|
|
49
50
|
exports.VerticalAxisLabel = ageAxis.VerticalAxisLabel;
|
|
50
|
-
exports.prepareColumnUnits = index$
|
|
51
|
-
exports.usePreparedColumnUnits = index$
|
|
51
|
+
exports.prepareColumnUnits = index$6.prepareColumnUnits;
|
|
52
|
+
exports.usePreparedColumnUnits = index$6.usePreparedColumnUnits;
|
|
52
53
|
exports.Column = column.Column;
|
|
53
54
|
exports.ColumnBasicInfo = column.ColumnBasicInfo;
|
|
54
55
|
exports.ColumnContainer = column.ColumnContainer;
|
|
@@ -111,6 +112,8 @@ exports.useColumnUnitsMap = store.useColumnUnitsMap;
|
|
|
111
112
|
exports.useCompositeScale = store.useCompositeScale;
|
|
112
113
|
exports.useMacrostratColumnData = store.useMacrostratColumnData;
|
|
113
114
|
exports.useMacrostratUnits = store.useMacrostratUnits;
|
|
115
|
+
exports.MacrostratUnitsOverlay = index$4.MacrostratUnitsOverlay;
|
|
116
|
+
exports.buildUnitsStyle = index$4.buildUnitsStyle;
|
|
114
117
|
exports.MeasurementDataContext = dataProvider.MeasurementDataContext;
|
|
115
118
|
exports.MeasurementDataProvider = dataProvider.MeasurementDataProvider;
|
|
116
119
|
exports.useMeasurementData = dataProvider.useMeasurementData;
|
|
@@ -122,7 +125,7 @@ exports.ensureRealFloat = utils.ensureRealFloat;
|
|
|
122
125
|
exports.getPositionWithinUnit = utils.getPositionWithinUnit;
|
|
123
126
|
exports.getUnitHeightRange = utils.getUnitHeightRange;
|
|
124
127
|
exports.unitsOverlap = utils.unitsOverlap;
|
|
125
|
-
exports.PBDBFossilsColumn = index$
|
|
128
|
+
exports.PBDBFossilsColumn = index$5.PBDBFossilsColumn;
|
|
126
129
|
exports.PBDBOccurrencesMatrix = taxonRanges.PBDBOccurrencesMatrix;
|
|
127
130
|
exports.SGPMeasurementsColumn = sgp.SGPMeasurementsColumn;
|
|
128
131
|
exports.UnitDetailsPanelWithNavigation = modalPanel.UnitDetailsPanelWithNavigation;
|
|
@@ -138,6 +141,8 @@ exports.useSelectedUnit = unitSelection.useSelectedUnit;
|
|
|
138
141
|
exports.useUnitSelectionDispatch = unitSelection.useUnitSelectionDispatch;
|
|
139
142
|
exports.useUnitSelectionTarget = unitSelection.useUnitSelectionTarget;
|
|
140
143
|
exports.buildColumnsStyle = styles.buildColumnsStyle;
|
|
144
|
+
exports.flattenLithologies = colors.flattenLithologies;
|
|
145
|
+
exports.getMixedColorForData = colors.getMixedColorForData;
|
|
141
146
|
exports.getMixedUnitColor = colors.getMixedUnitColor;
|
|
142
147
|
exports.parseLineFromString = hashString.parseLineFromString;
|
|
143
148
|
exports.stringifyLine = hashString.stringifyLine;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import { HeightMethod, HybridScaleType } from "./prepare-units/types.js";
|
|
|
20
20
|
import { InsetMap } from "./maps/_shared/inset-map.js";
|
|
21
21
|
import { IsotopesColumn, IsotopesDataset } from "./facets/carbon-isotopes/isotopes-column.js";
|
|
22
22
|
import { LithologiesProvider, MacrostratColumnDataProvider, MacrostratColumnProvider, MacrostratColumnStateProvider, UnitSelectionProvider, columnUnitsAtom, columnUnitsMapAtom, scope, useColumnUnitsMap, useCompositeScale, useMacrostratColumnData, useMacrostratUnits } from "./data-provider/store.js";
|
|
23
|
+
import { MacrostratUnitsOverlay, buildUnitsStyle } from "./maps/units-overlay/index.js";
|
|
23
24
|
import { MeasurementDataContext, MeasurementDataProvider, useMeasurementData } from "./facets/carbon-isotopes/data-provider.js";
|
|
24
25
|
import { MergeSectionsMode, agesOverlap, createUnitSorter, ensureArray, ensureRealFloat, getPositionWithinUnit, getUnitHeightRange, unitsOverlap } from "./prepare-units/utils.js";
|
|
25
26
|
import { PBDBFossilsColumn } from "./facets/fossils/index.js";
|
|
@@ -29,7 +30,7 @@ import { UnitDetailsPanelWithNavigation } from "./unit-details/modal-panel.js";
|
|
|
29
30
|
import { UnitDetailsPopover, UnitSelectionPopover } from "./unit-details/popover.js";
|
|
30
31
|
import { UnitKeyboardNavigation, UnitSelectionCallbackManager, allowUnitSelectionAtom, selectedUnitIDAtom, useAtomOverlayPosition, useColumnRef, useSelectedUnit, useUnitSelectionDispatch, useUnitSelectionTarget } from "./data-provider/unit-selection.js";
|
|
31
32
|
import { buildColumnsStyle } from "./maps/_shared/styles.js";
|
|
32
|
-
import { getMixedUnitColor } from "./units/colors.js";
|
|
33
|
+
import { flattenLithologies, getMixedColorForData, getMixedUnitColor } from "./units/colors.js";
|
|
33
34
|
import { parseLineFromString, stringifyLine } from "./correlation-chart/hash-string.js";
|
|
34
35
|
import { preprocessUnits } from "./prepare-units/helpers.js";
|
|
35
36
|
export {
|
|
@@ -80,6 +81,7 @@ export {
|
|
|
80
81
|
MacrostratColumnDataProvider,
|
|
81
82
|
MacrostratColumnProvider,
|
|
82
83
|
MacrostratColumnStateProvider,
|
|
84
|
+
MacrostratUnitsOverlay,
|
|
83
85
|
MeasurementDataContext,
|
|
84
86
|
MeasurementDataProvider,
|
|
85
87
|
MeasurementsLayer,
|
|
@@ -107,11 +109,14 @@ export {
|
|
|
107
109
|
agesOverlap,
|
|
108
110
|
allowUnitSelectionAtom,
|
|
109
111
|
buildColumnsStyle,
|
|
112
|
+
buildUnitsStyle,
|
|
110
113
|
columnUnitsAtom,
|
|
111
114
|
columnUnitsMapAtom,
|
|
112
115
|
createUnitSorter,
|
|
113
116
|
ensureArray,
|
|
114
117
|
ensureRealFloat,
|
|
118
|
+
flattenLithologies,
|
|
119
|
+
getMixedColorForData,
|
|
115
120
|
getMixedUnitColor,
|
|
116
121
|
getPositionWithinUnit,
|
|
117
122
|
getUnitHeightRange,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -5,7 +5,12 @@ const mapboxUtils = require("@macrostrat/mapbox-utils");
|
|
|
5
5
|
function buildColumnsStyle(color) {
|
|
6
6
|
let columnColor = color ?? colorUtils.getCSSVariable("--text-subtle-color", "black");
|
|
7
7
|
const columnSelectedColor = colorUtils.getCSSVariable("--selection-color", "purple");
|
|
8
|
-
columnColor = [
|
|
8
|
+
columnColor = [
|
|
9
|
+
"coalesce",
|
|
10
|
+
["feature-state", "color"],
|
|
11
|
+
["get", "color"],
|
|
12
|
+
columnColor
|
|
13
|
+
];
|
|
9
14
|
return {
|
|
10
15
|
sources: {
|
|
11
16
|
columns: mapboxUtils.buildGeoJSONSource()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.cjs","sources":["../../../src/maps/_shared/styles.ts"],"sourcesContent":["import { getCSSVariable } from \"@macrostrat/color-utils\";\nimport { buildGeoJSONSource } from \"@macrostrat/mapbox-utils\";\nimport type { Style } from \"mapbox-gl\";\n\nexport function buildColumnsStyle(color: string): Style {\n let columnColor
|
|
1
|
+
{"version":3,"file":"styles.cjs","sources":["../../../src/maps/_shared/styles.ts"],"sourcesContent":["import { getCSSVariable } from \"@macrostrat/color-utils\";\nimport { buildGeoJSONSource } from \"@macrostrat/mapbox-utils\";\nimport type { Style } from \"mapbox-gl\";\n\nexport function buildColumnsStyle(color: string): Style {\n let columnColor: any =\n color ?? getCSSVariable(\"--text-subtle-color\", \"black\");\n const columnSelectedColor = getCSSVariable(\"--selection-color\", \"purple\");\n\n // If color is in the feature state or geojson properties, use that as second choice\n\n columnColor = [\n \"coalesce\",\n [\"feature-state\", \"color\"],\n [\"get\", \"color\"],\n columnColor,\n ];\n\n return {\n sources: {\n columns: buildGeoJSONSource(),\n },\n version: 8,\n layers: [\n {\n id: \"columns-fill\",\n type: \"fill\",\n source: \"columns\",\n paint: {\n \"fill-color\": columnColor,\n \"fill-opacity\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"selected\"], false],\n 0.5,\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n 0.3,\n 0.1,\n ],\n },\n },\n {\n id: \"columns-line\",\n type: \"line\",\n source: \"columns\",\n paint: {\n \"line-color\": columnColor,\n \"line-width\": 2,\n \"line-opacity\": 0.5,\n },\n },\n {\n id: \"columns-points\",\n type: \"circle\",\n source: \"columns\",\n paint: {\n \"circle-radius\": 4,\n \"circle-color\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"selected\"], false],\n columnSelectedColor,\n columnColor,\n ],\n \"circle-opacity\": [\n \"case\",\n [\"boolean\", [\"feature-state\", \"selected\"], false],\n 1,\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n 0.7,\n 0.5,\n ],\n },\n filter: [\"==\", \"$type\", \"Point\"],\n },\n ],\n };\n}\n"],"names":["getCSSVariable","buildGeoJSONSource"],"mappings":";;;;AAIO,SAAS,kBAAkB,OAAsB;AACtD,MAAI,cACF,SAASA,0BAAe,uBAAuB,OAAO;AACxD,QAAM,sBAAsBA,WAAAA,eAAe,qBAAqB,QAAQ;AAIxE,gBAAc;AAAA,IACZ;AAAA,IACA,CAAC,iBAAiB,OAAO;AAAA,IACzB,CAAC,OAAO,OAAO;AAAA,IACf;AAAA,EAAA;AAGF,SAAO;AAAA,IACL,SAAS;AAAA,MACP,SAASC,YAAAA,mBAAA;AAAA,IAAmB;AAAA,IAE9B,SAAS;AAAA,IACT,QAAQ;AAAA,MACN;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,OAAO;AAAA,UACL,cAAc;AAAA,UACd,gBAAgB;AAAA,YACd;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,UAAU,GAAG,KAAK;AAAA,YAChD;AAAA,YACA,CAAC,WAAW,CAAC,iBAAiB,OAAO,GAAG,KAAK;AAAA,YAC7C;AAAA,YACA;AAAA,UAAA;AAAA,QACF;AAAA,MACF;AAAA,MAEF;AAAA,Q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