@macrostrat/column-views 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/{age-axis.7ce58d66.js → esm/age-axis.64c509ee.js} +11 -11
- package/dist/{age-axis.7ce58d66.js.map → esm/age-axis.64c509ee.js.map} +1 -1
- package/dist/{boxes.6d3192e6.js → esm/boxes.13968b76.js} +26 -26
- package/dist/{boxes.6d3192e6.js.map → esm/boxes.13968b76.js.map} +1 -1
- package/dist/{boxes.module.dd631fe3.css → esm/boxes.module.28873d08.css} +1 -1
- package/dist/{boxes.module.dd631fe3.css.map → esm/boxes.module.28873d08.css.map} +1 -1
- package/dist/{boxes.module.998ff312.js → esm/boxes.module.605bdcd6.js} +1 -1
- package/dist/{boxes.module.998ff312.js.map → esm/boxes.module.605bdcd6.js.map} +1 -1
- package/dist/esm/carbon-isotopes.3b502a9e.js +11 -0
- package/dist/{carbon-isotopes.6d9bddcf.js.map → esm/carbon-isotopes.3b502a9e.js.map} +1 -1
- package/dist/{column.e35a471f.js → esm/column.97e31037.js} +21 -21
- package/dist/{column.e35a471f.js.map → esm/column.97e31037.js.map} +1 -1
- package/dist/{column.e901b5d4.js → esm/column.db058031.js} +17 -17
- package/dist/{column.e901b5d4.js.map → esm/column.db058031.js.map} +1 -1
- package/dist/{column.module.35ba04e7.js → esm/column.module.7f47d25a.js} +1 -1
- package/dist/{column.module.35ba04e7.js.map → esm/column.module.7f47d25a.js.map} +1 -1
- package/dist/{column.module.2e29259c.js → esm/column.module.9b8ce99d.js} +1 -1
- package/dist/{column.module.2e29259c.js.map → esm/column.module.9b8ce99d.js.map} +1 -1
- package/dist/{column.module.c9df6edf.css → esm/column.module.b5e18f0c.css} +1 -1
- package/dist/{column.module.c9df6edf.css.map → esm/column.module.b5e18f0c.css.map} +1 -1
- package/dist/{column.module.35184ea7.css → esm/column.module.cbb072df.css} +1 -1
- package/dist/{column.module.35184ea7.css.map → esm/column.module.cbb072df.css.map} +1 -1
- package/dist/{composite.494beffc.js → esm/composite.608a4ca2.js} +20 -20
- package/dist/{composite.494beffc.js.map → esm/composite.608a4ca2.js.map} +1 -1
- package/dist/{composite.module.6359deba.js → esm/composite.module.0638e7ee.js} +1 -1
- package/dist/{composite.module.6359deba.js.map → esm/composite.module.0638e7ee.js.map} +1 -1
- package/dist/esm/composite.module.69a38fd1.css +4 -0
- package/dist/{composite.module.5cc0e747.css.map → esm/composite.module.69a38fd1.css.map} +1 -1
- package/dist/{core.f3824dd8.js → esm/core.4db8e452.js} +15 -15
- package/dist/{core.f3824dd8.js.map → esm/core.4db8e452.js.map} +1 -1
- package/dist/{data-area.f9bb9ad9.js → esm/data-area.daff8da0.js} +15 -15
- package/dist/{data-area.f9bb9ad9.js.map → esm/data-area.daff8da0.js.map} +1 -1
- package/dist/{data-provider.61ef7f9a.js → esm/data-provider.1506eb64.js} +8 -8
- package/dist/{data-provider.61ef7f9a.js.map → esm/data-provider.1506eb64.js.map} +1 -1
- package/dist/{helpers.2af05ee4.js → esm/helpers.8a03cfc7.js} +6 -6
- package/dist/{helpers.2af05ee4.js.map → esm/helpers.8a03cfc7.js.map} +1 -1
- package/dist/{index.js → esm/index.js} +8 -8
- package/dist/{index.module.de76feb2.css → esm/index.module.0844afd8.css} +1 -1
- package/dist/{index.module.de76feb2.css.map → esm/index.module.0844afd8.css.map} +1 -1
- package/dist/{index.module.8fad0020.js → esm/index.module.24fe3a2e.js} +1 -1
- package/dist/{index.module.8fad0020.js.map → esm/index.module.24fe3a2e.js.map} +1 -1
- package/dist/{isotopes-column.b5442b4d.js → esm/isotopes-column.7cb5cc45.js} +33 -33
- package/dist/{isotopes-column.b5442b4d.js.map → esm/isotopes-column.7cb5cc45.js.map} +1 -1
- package/dist/{layers.946aaa37.js → esm/layers.ad5fd25d.js} +31 -31
- package/dist/{layers.946aaa37.js.map → esm/layers.ad5fd25d.js.map} +1 -1
- package/dist/{map.e782010f.js → esm/map.7aa26f17.js} +17 -17
- package/dist/{map.e782010f.js.map → esm/map.7aa26f17.js.map} +1 -1
- package/dist/{names.ab14789e.js → esm/names.f6a4e9a4.js} +11 -11
- package/dist/{names.ab14789e.js.map → esm/names.f6a4e9a4.js.map} +1 -1
- package/dist/{providers.abcb2cbe.js → esm/providers.cd1e652f.js} +7 -7
- package/dist/{providers.abcb2cbe.js.map → esm/providers.cd1e652f.js.map} +1 -1
- package/dist/{resolvers.2949c4c0.js → esm/resolvers.b5c82b78.js} +1 -1
- package/dist/{resolvers.2949c4c0.js.map → esm/resolvers.b5c82b78.js.map} +1 -1
- package/dist/{section.6f6fc929.js → esm/section.2513d610.js} +19 -19
- package/dist/{section.6f6fc929.js.map → esm/section.2513d610.js.map} +1 -1
- package/dist/{selection-popover.7e008544.js → esm/selection-popover.17d1bd55.js} +9 -9
- package/dist/{selection-popover.7e008544.js.map → esm/selection-popover.17d1bd55.js.map} +1 -1
- package/dist/{selection-popover.module.2732ebc0.css → esm/selection-popover.module.0a701258.css} +1 -1
- package/dist/{selection-popover.module.2732ebc0.css.map → esm/selection-popover.module.0a701258.css.map} +1 -1
- package/dist/{selection-popover.module.fdbfb40e.js → esm/selection-popover.module.e22f5183.js} +1 -1
- package/dist/{selection-popover.module.fdbfb40e.js.map → esm/selection-popover.module.e22f5183.js.map} +1 -1
- package/dist/{selection.add9f8b0.js → esm/selection.bbf26d0e.js} +23 -23
- package/dist/{selection.add9f8b0.js.map → esm/selection.bbf26d0e.js.map} +1 -1
- package/dist/{store.c5271371.js → esm/store.25eaa168.js} +6 -6
- package/dist/{store.c5271371.js.map → esm/store.25eaa168.js.map} +1 -1
- package/dist/{types.ff938b22.js → esm/types.f016e032.js} +1 -1
- package/dist/{types.ff938b22.js.map → esm/types.f016e032.js.map} +1 -1
- package/dist/{unit-details.0c1edd00.js → esm/unit-details.56ff8b70.js} +30 -30
- package/dist/{unit-details.0c1edd00.js.map → esm/unit-details.56ff8b70.js.map} +1 -1
- package/dist/{units.5ec6a44c.js → esm/units.361088d4.js} +13 -13
- package/dist/{units.5ec6a44c.js.map → esm/units.361088d4.js.map} +1 -1
- package/dist/node/index.js +2 -0
- package/dist/node/index.js.map +1 -0
- package/package.json +19 -10
- package/dist/carbon-isotopes.6d9bddcf.js +0 -11
- package/dist/composite.module.5cc0e747.css +0 -4
- /package/dist/{index.d.ts → esm/index.d.ts} +0 -0
- /package/dist/{index.d.ts.map → esm/index.d.ts.map} +0 -0
- /package/dist/{index.js.map → esm/index.js.map} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {useMeasurementData as $8adf39b8c41fe3cc$export$8a0335fd9ff72150} from "./data-provider.
|
|
2
|
-
import {useDataLocator as $1dbd903fb3e2f029$export$919dbb10b6b5b75, IsotopesDataArea as $1dbd903fb3e2f029$export$309ef8546e07d921, IsotopeDataPoint as $1dbd903fb3e2f029$export$4cb5d059db4e2bd} from "./data-area.
|
|
3
|
-
import {format as $
|
|
4
|
-
import {useContext as $
|
|
5
|
-
import $
|
|
6
|
-
import $
|
|
7
|
-
import {AxisBottom as $
|
|
8
|
-
import {referenceMeasuresToColumn as $
|
|
9
|
-
import {ColumnLayoutContext as $
|
|
1
|
+
import {useMeasurementData as $8adf39b8c41fe3cc$export$8a0335fd9ff72150} from "./data-provider.1506eb64.js";
|
|
2
|
+
import {useDataLocator as $1dbd903fb3e2f029$export$919dbb10b6b5b75, IsotopesDataArea as $1dbd903fb3e2f029$export$309ef8546e07d921, IsotopeDataPoint as $1dbd903fb3e2f029$export$4cb5d059db4e2bd} from "./data-area.daff8da0.js";
|
|
3
|
+
import {format as $cjrRw$format} from "d3-format";
|
|
4
|
+
import {useContext as $cjrRw$useContext} from "react";
|
|
5
|
+
import $cjrRw$macrostrathyper from "@macrostrat/hyper";
|
|
6
|
+
import $cjrRw$classnames from "classnames";
|
|
7
|
+
import {AxisBottom as $cjrRw$AxisBottom} from "@visx/axis";
|
|
8
|
+
import {referenceMeasuresToColumn as $cjrRw$referenceMeasuresToColumn} from "@macrostrat/stratigraphy-utils";
|
|
9
|
+
import {ColumnLayoutContext as $cjrRw$ColumnLayoutContext, useColumnDivisions as $cjrRw$useColumnDivisions, CrossAxisLayoutProvider as $cjrRw$CrossAxisLayoutProvider} from "@macrostrat/column-components";
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -17,11 +17,11 @@ import {ColumnLayoutContext as $5FELH$ColumnLayoutContext, useColumnDivisions as
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
const $d5a3eba6c540ff58$var$fmt = (0, $
|
|
20
|
+
const $d5a3eba6c540ff58$var$fmt = (0, $cjrRw$format)(".1f");
|
|
21
21
|
function $d5a3eba6c540ff58$var$IsotopeText({ datum: datum, text: text, ...rest }) {
|
|
22
22
|
const { pointLocator: pointLocator } = (0, $1dbd903fb3e2f029$export$919dbb10b6b5b75)();
|
|
23
23
|
const [x, y] = pointLocator(datum);
|
|
24
|
-
return (0, $
|
|
24
|
+
return (0, $cjrRw$macrostrathyper)("text", {
|
|
25
25
|
x: x,
|
|
26
26
|
y: y,
|
|
27
27
|
...rest
|
|
@@ -29,25 +29,25 @@ function $d5a3eba6c540ff58$var$IsotopeText({ datum: datum, text: text, ...rest }
|
|
|
29
29
|
}
|
|
30
30
|
function $d5a3eba6c540ff58$var$ColumnScale(props) {
|
|
31
31
|
const { label: label, showAxis: showAxis = true, nTicks: nTicks = 6, tickValues: _tickVals, ...rest } = props;
|
|
32
|
-
const { xScale: xScale, pixelHeight: pixelHeight, width: width } = (0, $
|
|
32
|
+
const { xScale: xScale, pixelHeight: pixelHeight, width: width } = (0, $cjrRw$useContext)((0, $cjrRw$ColumnLayoutContext));
|
|
33
33
|
const tickValues = _tickVals ?? xScale.ticks(nTicks);
|
|
34
|
-
return (0, $
|
|
35
|
-
(0, $
|
|
34
|
+
return (0, $cjrRw$macrostrathyper)("g.scale.isotope-scale-axis", [
|
|
35
|
+
(0, $cjrRw$macrostrathyper)("g.scale-lines", tickValues.map((value)=>{
|
|
36
36
|
const strokeDasharray = value == 0 ? null : "2 6";
|
|
37
|
-
return (0, $
|
|
37
|
+
return (0, $cjrRw$macrostrathyper)($d5a3eba6c540ff58$var$ScaleLine, {
|
|
38
38
|
value: value,
|
|
39
39
|
stroke: "#ddd",
|
|
40
40
|
strokeDasharray: strokeDasharray
|
|
41
41
|
});
|
|
42
42
|
})),
|
|
43
|
-
(0, $
|
|
44
|
-
(0, $
|
|
43
|
+
(0, $cjrRw$macrostrathyper).if(showAxis)([
|
|
44
|
+
(0, $cjrRw$macrostrathyper)("rect.underlay", {
|
|
45
45
|
x: 0,
|
|
46
46
|
y: pixelHeight,
|
|
47
47
|
width: width,
|
|
48
48
|
height: 30
|
|
49
49
|
}),
|
|
50
|
-
(0, $
|
|
50
|
+
(0, $cjrRw$macrostrathyper)((0, $cjrRw$AxisBottom), {
|
|
51
51
|
scale: xScale,
|
|
52
52
|
tickLength: 3,
|
|
53
53
|
tickValues: tickValues,
|
|
@@ -75,25 +75,25 @@ function $d5a3eba6c540ff58$var$ScaleLine(props) {
|
|
|
75
75
|
let { value: value, className: className, labelBottom: labelBottom, labelOffset: labelOffset, ...rest } = props;
|
|
76
76
|
if (labelBottom == null) labelBottom = false;
|
|
77
77
|
if (labelOffset == null) labelOffset = 12;
|
|
78
|
-
const { xScale: xScale, pixelHeight: pixelHeight } = (0, $
|
|
78
|
+
const { xScale: xScale, pixelHeight: pixelHeight } = (0, $cjrRw$useContext)((0, $cjrRw$ColumnLayoutContext));
|
|
79
79
|
const x = xScale(value);
|
|
80
80
|
const transform = `translate(${x})`;
|
|
81
|
-
className = (0, $
|
|
81
|
+
className = (0, $cjrRw$classnames)(className, {
|
|
82
82
|
zero: value === 0
|
|
83
83
|
});
|
|
84
|
-
return (0, $
|
|
84
|
+
return (0, $cjrRw$macrostrathyper)("g.tick", {
|
|
85
85
|
transform: transform,
|
|
86
86
|
className: className,
|
|
87
87
|
key: value
|
|
88
88
|
}, [
|
|
89
|
-
(0, $
|
|
89
|
+
(0, $cjrRw$macrostrathyper)("line", {
|
|
90
90
|
x0: 0,
|
|
91
91
|
x1: 0,
|
|
92
92
|
y0: 0,
|
|
93
93
|
y1: pixelHeight,
|
|
94
94
|
...rest
|
|
95
95
|
}),
|
|
96
|
-
(0, $
|
|
96
|
+
(0, $cjrRw$macrostrathyper).if(labelBottom)("text", {
|
|
97
97
|
y: pixelHeight + labelOffset
|
|
98
98
|
}, `${value}`)
|
|
99
99
|
]);
|
|
@@ -117,16 +117,16 @@ function $d5a3eba6c540ff58$var$unnestPoints(measures) {
|
|
|
117
117
|
}
|
|
118
118
|
function $d5a3eba6c540ff58$export$c69bd0285aa5d775(props) {
|
|
119
119
|
const { parameter: parameter, color: color = "dodgerblue" } = props;
|
|
120
|
-
const divisions = (0, $
|
|
120
|
+
const divisions = (0, $cjrRw$useColumnDivisions)();
|
|
121
121
|
const measures = (0, $8adf39b8c41fe3cc$export$8a0335fd9ff72150)() ?? [];
|
|
122
|
-
const refMeasures = (0, $
|
|
122
|
+
const refMeasures = (0, $cjrRw$referenceMeasuresToColumn)(divisions, measures).filter((d)=>d.measurement == parameter);
|
|
123
123
|
const points = $d5a3eba6c540ff58$var$unnestPoints(refMeasures);
|
|
124
|
-
return (0, $
|
|
124
|
+
return (0, $cjrRw$macrostrathyper)((0, $1dbd903fb3e2f029$export$309ef8546e07d921), {
|
|
125
125
|
getHeight (d) {
|
|
126
126
|
return d.age;
|
|
127
127
|
}
|
|
128
|
-
}, (0, $
|
|
129
|
-
return (0, $
|
|
128
|
+
}, (0, $cjrRw$macrostrathyper)("g.data-points", points.map((d)=>{
|
|
129
|
+
return (0, $cjrRw$macrostrathyper)((0, $1dbd903fb3e2f029$export$4cb5d059db4e2bd), {
|
|
130
130
|
datum: d,
|
|
131
131
|
fill: color
|
|
132
132
|
});
|
|
@@ -138,19 +138,19 @@ function $d5a3eba6c540ff58$export$5d8aa8022c284748(props) {
|
|
|
138
138
|
6
|
|
139
139
|
], parameter: parameter, label: label, color: color = "dodgerblue", children: children = null, transform: transform, getHeight: getHeight, ...rest } = props;
|
|
140
140
|
let _children = children;
|
|
141
|
-
if (children == null && parameter != null) _children = (0, $
|
|
141
|
+
if (children == null && parameter != null) _children = (0, $cjrRw$macrostrathyper)($d5a3eba6c540ff58$export$c69bd0285aa5d775, {
|
|
142
142
|
parameter: parameter,
|
|
143
143
|
color: color,
|
|
144
144
|
getHeight: getHeight
|
|
145
145
|
});
|
|
146
|
-
return (0, $
|
|
146
|
+
return (0, $cjrRw$macrostrathyper)((0, $cjrRw$CrossAxisLayoutProvider), {
|
|
147
147
|
width: width,
|
|
148
148
|
domain: domain
|
|
149
|
-
}, (0, $
|
|
149
|
+
}, (0, $cjrRw$macrostrathyper)("g.isotopes-column", {
|
|
150
150
|
className: parameter,
|
|
151
151
|
transform: transform
|
|
152
152
|
}, [
|
|
153
|
-
(0, $
|
|
153
|
+
(0, $cjrRw$macrostrathyper)($d5a3eba6c540ff58$var$ColumnScale, {
|
|
154
154
|
label: label ?? parameter,
|
|
155
155
|
...rest
|
|
156
156
|
}),
|
|
@@ -160,4 +160,4 @@ function $d5a3eba6c540ff58$export$5d8aa8022c284748(props) {
|
|
|
160
160
|
|
|
161
161
|
|
|
162
162
|
export {$d5a3eba6c540ff58$export$c69bd0285aa5d775 as IsotopesDataset, $d5a3eba6c540ff58$export$5d8aa8022c284748 as IsotopesColumn};
|
|
163
|
-
//# sourceMappingURL=isotopes-column.
|
|
163
|
+
//# sourceMappingURL=isotopes-column.7cb5cc45.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,MAAM,4BAAM,CAAA,GAAA,aAAK,EAAE;AAOnB,SAAS,kCAAY,SAAE,KAAK,QAAE,IAAI,EAAE,GAAG,MAAyB;IAC9D,MAAM,gBAAE,YAAY,EAAE,GAAG,CAAA,GAAA,wCAAa;IACtC,MAAM,CAAC,GAAG,EAAE,GAAG,aA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B,MAAM,SAAS,mCAAa;IAE5B,OAAO,CAAA,GAAA,sBAAA,EACL,CAAA,GAAA,yCAAe,GACf;QACE,WAAU,CAAC;YACT,OAAO,EAAE,GAAG;QACd;IACF,GACA,CAAA,GAAA,sBAAA,EACE,iBACA,OAAO,GAAG,CAAC,CAAC;QACV,OAAO,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,wCAAe,GAAG;YACzB,OAAO;YACP,MAAM;QACR;IACF;AAGN;AAEA,SAAS,0CACP,KAA2E;IAE3E,MAAM,SACJ,QAAQ,aACR,SAAS;QAAC;QAAK;KAAE,aACjB,SAAS,SACT,KAAK,SACL,QAAQ,wBACR,WAAW,iBACX,SAAS,aACT,SAAS,EACT,GAAG,MACJ,GAAG;IAEJ,IAAI,YAAiB;IACrB,IAAI,YAAY,QAAQ,aAAa,MACnC,YAAY,CAAA,GAAA,sBAAA,EAAE,2CAAiB;mBAAE;eAAW;mBAAO;IAAU;IAG/D,OAAO,CAAA,GAAA,sBAAA,EACL,CAAA,GAAA,8BAAsB,GACtB;eAAE;gBAAO;IAAO,GAChB,CAAA,GAAA,sBAAA,EAAE,qBAAqB;QAAE,WAAW;mBAAW;IAAU,GAAG;QAC1D,CAAA,GAAA,sBAAA,EAAE,mCAAa;YAAE,OAAO,SAAS;YAAW,GAAG,IAAI;QAAC;QACpD;KACD;AAEL","sources":["packages/column-views/src/carbon-isotopes/isotopes-column.ts"],"sourcesContent":["import { format } from \"d3-format\";\nimport { useContext } from \"react\";\nimport h 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 CrossAxisLayoutProvider,\n ColumnLayoutContext,\n useColumnDivisions,\n} from \"@macrostrat/column-components\";\nimport { BaseUnit } from \"@macrostrat/api-types\";\nimport { AxisProps } from \"@visx/axis/lib/axis/Axis\";\n\nconst fmt = format(\".1f\");\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\nfunction ColumnScale(props) {\n const {\n label,\n showAxis = true,\n nTicks = 6,\n tickValues: _tickVals,\n ...rest\n } = props;\n const { xScale, pixelHeight, width } = useContext(ColumnLayoutContext);\n\n const tickValues = _tickVals ?? xScale.ticks(nTicks);\n\n return h(\"g.scale.isotope-scale-axis\", [\n h(\n \"g.scale-lines\",\n tickValues.map((value) => {\n const strokeDasharray = value == 0 ? null : \"2 6\";\n return h(ScaleLine, { value, stroke: \"#ddd\", strokeDasharray });\n })\n ),\n h.if(showAxis)([\n h(\"rect.underlay\", {\n x: 0,\n y: pixelHeight,\n width,\n height: 30,\n }),\n h(AxisBottom, {\n scale: xScale,\n tickLength: 3,\n tickValues,\n ...rest,\n top: pixelHeight,\n tickLabelProps(tickValue, i) {\n // Compensate for negative sign\n let dx;\n if (tickValue < 0) {\n dx = -2;\n }\n return {\n dy: \"-1px\",\n dx,\n fontSize: 10,\n textAnchor: \"middle\",\n fill: \"#aaa\",\n };\n },\n labelOffset: 0,\n label,\n }),\n ]),\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 if (labelBottom == null) {\n labelBottom = false;\n }\n if (labelOffset == null) {\n labelOffset = 12;\n }\n const { xScale, pixelHeight } = useContext(ColumnLayoutContext);\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(\"line\", { x0: 0, x1: 0, y0: 0, y1: pixelHeight, ...rest }),\n h.if(labelBottom)(\"text\", { y: pixelHeight + labelOffset }, `${value}`),\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}\n\nfunction IsotopesDataset(props) {\n const { parameter, color = \"dodgerblue\" } = props;\n const divisions: BaseUnit[] = useColumnDivisions() as any;\n const measures = useMeasurementData() ?? [];\n const refMeasures = referenceMeasuresToColumn(divisions, measures).filter(\n (d) => d.measurement == parameter\n );\n const points = unnestPoints(refMeasures);\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 } & AxisProps<any>\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 ...rest\n } = props;\n\n let _children: any = children;\n if (children == null && parameter != null) {\n _children = h(IsotopesDataset, { parameter, color, getHeight });\n }\n\n return h(\n CrossAxisLayoutProvider,\n { width, domain },\n h(\"g.isotopes-column\", { className: parameter, transform }, [\n h(ColumnScale, { label: label ?? parameter, ...rest }),\n _children,\n ])\n );\n}\n\nexport { IsotopesColumn, IsotopesDataset };\n"],"names":[],"version":3,"file":"isotopes-column.
|
|
1
|
+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,aAAE,SAAS,SAAE,QAAQ,cAAc,GAAG;IAC5C,MAAM,YAAwB,CAAA,GAAA,yBAAiB;IAC/C,MAAM,WAAW,CAAA,GAAA,yCAAiB,OAAO,EAAE;IAC3C,MAAM,cAAc,CAAA,GAAA,gCAAwB,EAAE,WAAW,UAAU,MAAM,CACvE,CAAC,IAAM,EAAE,WAAW,IAAI;IAE1B,MAAM,SAAS,mCAAa;IAE5B,OAAO,CAAA,GAAA,sBAAA,EACL,CAAA,GAAA,yCAAe,GACf;QACE,WAAU,CAAC;YACT,OAAO,EAAE,GAAG;QACd;IACF,GACA,CAAA,GAAA,sBAAA,EACE,iBACA,OAAO,GAAG,CAAC,CAAC;QACV,OAAO,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,wCAAe,GAAG;YACzB,OAAO;YACP,MAAM;QACR;IACF;AAGN;AAEA,SAAS,0CACP,KAA2E;IAE3E,MAAM,SACJ,QAAQ,aACR,SAAS;QAAC;QAAK;KAAE,aACjB,SAAS,SACT,KAAK,SACL,QAAQ,wBACR,WAAW,iBACX,SAAS,aACT,SAAS,EACT,GAAG,MACJ,GAAG;IAEJ,IAAI,YAAiB;IACrB,IAAI,YAAY,QAAQ,aAAa,MACnC,YAAY,CAAA,GAAA,sBAAA,EAAE,2CAAiB;mBAAE;eAAW;mBAAO;IAAU;IAG/D,OAAO,CAAA,GAAA,sBAAA,EACL,CAAA,GAAA,8BAAsB,GACtB;eAAE;gBAAO;IAAO,GAChB,CAAA,GAAA,sBAAA,EAAE,qBAAqB;QAAE,WAAW;mBAAW;IAAU,GAAG;QAC1D,CAAA,GAAA,sBAAA,EAAE,mCAAa;YAAE,OAAO,SAAS;YAAW,GAAG,IAAI;QAAC;QACpD;KACD;AAEL","sources":["packages/column-views/src/carbon-isotopes/isotopes-column.ts"],"sourcesContent":["import { format } from \"d3-format\";\nimport { useContext } from \"react\";\nimport h 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 CrossAxisLayoutProvider,\n ColumnLayoutContext,\n useColumnDivisions,\n} from \"@macrostrat/column-components\";\nimport { BaseUnit } from \"@macrostrat/api-types\";\nimport { AxisProps } from \"@visx/axis/lib/axis/Axis\";\n\nconst fmt = format(\".1f\");\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\nfunction ColumnScale(props) {\n const {\n label,\n showAxis = true,\n nTicks = 6,\n tickValues: _tickVals,\n ...rest\n } = props;\n const { xScale, pixelHeight, width } = useContext(ColumnLayoutContext);\n\n const tickValues = _tickVals ?? xScale.ticks(nTicks);\n\n return h(\"g.scale.isotope-scale-axis\", [\n h(\n \"g.scale-lines\",\n tickValues.map((value) => {\n const strokeDasharray = value == 0 ? null : \"2 6\";\n return h(ScaleLine, { value, stroke: \"#ddd\", strokeDasharray });\n })\n ),\n h.if(showAxis)([\n h(\"rect.underlay\", {\n x: 0,\n y: pixelHeight,\n width,\n height: 30,\n }),\n h(AxisBottom, {\n scale: xScale,\n tickLength: 3,\n tickValues,\n ...rest,\n top: pixelHeight,\n tickLabelProps(tickValue, i) {\n // Compensate for negative sign\n let dx;\n if (tickValue < 0) {\n dx = -2;\n }\n return {\n dy: \"-1px\",\n dx,\n fontSize: 10,\n textAnchor: \"middle\",\n fill: \"#aaa\",\n };\n },\n labelOffset: 0,\n label,\n }),\n ]),\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 if (labelBottom == null) {\n labelBottom = false;\n }\n if (labelOffset == null) {\n labelOffset = 12;\n }\n const { xScale, pixelHeight } = useContext(ColumnLayoutContext);\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(\"line\", { x0: 0, x1: 0, y0: 0, y1: pixelHeight, ...rest }),\n h.if(labelBottom)(\"text\", { y: pixelHeight + labelOffset }, `${value}`),\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}\n\nfunction IsotopesDataset(props) {\n const { parameter, color = \"dodgerblue\" } = props;\n const divisions: BaseUnit[] = useColumnDivisions() as any;\n const measures = useMeasurementData() ?? [];\n const refMeasures = referenceMeasuresToColumn(divisions, measures).filter(\n (d) => d.measurement == parameter\n );\n const points = unnestPoints(refMeasures);\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 } & AxisProps<any>\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 ...rest\n } = props;\n\n let _children: any = children;\n if (children == null && parameter != null) {\n _children = h(IsotopesDataset, { parameter, color, getHeight });\n }\n\n return h(\n CrossAxisLayoutProvider,\n { width, domain },\n h(\"g.isotopes-column\", { className: parameter, transform }, [\n h(ColumnScale, { label: label ?? parameter, ...rest }),\n _children,\n ])\n );\n}\n\nexport { IsotopesColumn, IsotopesDataset };\n"],"names":[],"version":3,"file":"isotopes-column.7cb5cc45.js.map"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import $
|
|
2
|
-
import {FeatureLayer as $
|
|
3
|
-
import {useAPIResult as $
|
|
4
|
-
import $
|
|
5
|
-
import {geoCentroid as $
|
|
6
|
-
import {geoVoronoi as $
|
|
7
|
-
import {useContext as $
|
|
8
|
-
import {feature as $
|
|
1
|
+
import $eaw9D$macrostrathyper from "@macrostrat/hyper";
|
|
2
|
+
import {FeatureLayer as $eaw9D$FeatureLayer, Feature as $eaw9D$Feature, MapContext as $eaw9D$MapContext} from "@macrostrat/svg-map-components";
|
|
3
|
+
import {useAPIResult as $eaw9D$useAPIResult, useKeyHandler as $eaw9D$useKeyHandler} from "@macrostrat/ui-components";
|
|
4
|
+
import $eaw9D$chromajs from "chroma-js";
|
|
5
|
+
import {geoCentroid as $eaw9D$geoCentroid} from "d3-geo";
|
|
6
|
+
import {geoVoronoi as $eaw9D$geoVoronoi} from "d3-geo-voronoi";
|
|
7
|
+
import {useContext as $eaw9D$useContext, useMemo as $eaw9D$useMemo} from "react";
|
|
8
|
+
import {feature as $eaw9D$feature} from "topojson-client";
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -21,13 +21,13 @@ const $347c34ac01fb689b$var$defaultStyle = {
|
|
|
21
21
|
};
|
|
22
22
|
function $347c34ac01fb689b$export$2254347cd20e6080(props) {
|
|
23
23
|
const { style: style = $347c34ac01fb689b$var$defaultStyle, ...params } = props;
|
|
24
|
-
const res = (0, $
|
|
24
|
+
const res = (0, $eaw9D$useAPIResult)("/measurements", {
|
|
25
25
|
...params,
|
|
26
26
|
format: "geojson",
|
|
27
27
|
response: "light"
|
|
28
28
|
});
|
|
29
29
|
if (res == null) return null;
|
|
30
|
-
return (0, $
|
|
30
|
+
return (0, $eaw9D$macrostrathyper)((0, $eaw9D$FeatureLayer), {
|
|
31
31
|
useCanvas: false,
|
|
32
32
|
style: style,
|
|
33
33
|
features: res.features.filter((d)=>d.properties.unit_id != null)
|
|
@@ -36,7 +36,7 @@ function $347c34ac01fb689b$export$2254347cd20e6080(props) {
|
|
|
36
36
|
function $347c34ac01fb689b$export$4ad66a3119e1afaa(res) {
|
|
37
37
|
try {
|
|
38
38
|
const { data: data } = res.success;
|
|
39
|
-
const { features: f } = (0, $
|
|
39
|
+
const { features: f } = (0, $eaw9D$feature)(data, data.objects.output);
|
|
40
40
|
return f;
|
|
41
41
|
} catch (err) {
|
|
42
42
|
console.error(err);
|
|
@@ -45,8 +45,8 @@ function $347c34ac01fb689b$export$4ad66a3119e1afaa(res) {
|
|
|
45
45
|
}
|
|
46
46
|
function $347c34ac01fb689b$export$f177ff57c101017a(props) {
|
|
47
47
|
const { features: features, onClick: onClick, color: color = "rgba(150,150,150, 1)", singleFeature: singleFeature = true } = props;
|
|
48
|
-
const c = (0, $
|
|
49
|
-
return (0, $
|
|
48
|
+
const c = (0, $eaw9D$chromajs)(color);
|
|
49
|
+
return (0, $eaw9D$macrostrathyper)((0, $eaw9D$FeatureLayer), {
|
|
50
50
|
className: "columns",
|
|
51
51
|
useCanvas: onClick == null,
|
|
52
52
|
style: {
|
|
@@ -54,7 +54,7 @@ function $347c34ac01fb689b$export$f177ff57c101017a(props) {
|
|
|
54
54
|
stroke: c.alpha(0.4).css()
|
|
55
55
|
}
|
|
56
56
|
}, features.map((f)=>{
|
|
57
|
-
return (0, $
|
|
57
|
+
return (0, $eaw9D$macrostrathyper)((0, $eaw9D$Feature), {
|
|
58
58
|
id: f.id ?? f.properties.col_id,
|
|
59
59
|
onClick: onClick,
|
|
60
60
|
feature: f
|
|
@@ -72,8 +72,8 @@ function $347c34ac01fb689b$var$normalize(angle) {
|
|
|
72
72
|
}
|
|
73
73
|
function $347c34ac01fb689b$var$buildTriangulation(features) {
|
|
74
74
|
console.log("Computing triangulation");
|
|
75
|
-
const centroids = features.map((0, $
|
|
76
|
-
const tri = (0, $
|
|
75
|
+
const centroids = features.map((0, $eaw9D$geoCentroid));
|
|
76
|
+
const tri = (0, $eaw9D$geoVoronoi)(centroids);
|
|
77
77
|
return {
|
|
78
78
|
centroids: centroids,
|
|
79
79
|
tri: tri
|
|
@@ -107,24 +107,24 @@ function $347c34ac01fb689b$var$buildKeyMapping(neighbors, centroids, currentInde
|
|
|
107
107
|
}
|
|
108
108
|
function $347c34ac01fb689b$export$8c41dd563753848(props) {
|
|
109
109
|
/** Keyboard navigation of columns using a Delaunay triangulation */ const { features: features = [], col_id: col_id = null, onChange: onChange, showLayers: showLayers = false, ...projectArgs } = props;
|
|
110
|
-
const { projection: projection } = (0, $
|
|
111
|
-
const { centroids: centroids, tri: tri } = (0, $
|
|
110
|
+
const { projection: projection } = (0, $eaw9D$useContext)((0, $eaw9D$MapContext));
|
|
111
|
+
const { centroids: centroids, tri: tri } = (0, $eaw9D$useMemo)(()=>$347c34ac01fb689b$var$buildTriangulation(features), [
|
|
112
112
|
features
|
|
113
113
|
]);
|
|
114
|
-
const currentIndex = (0, $
|
|
114
|
+
const currentIndex = (0, $eaw9D$useMemo)(()=>{
|
|
115
115
|
return features.findIndex((d)=>d.properties.col_id == col_id);
|
|
116
116
|
}, [
|
|
117
117
|
features,
|
|
118
118
|
col_id
|
|
119
119
|
]);
|
|
120
120
|
const neighbors = tri.delaunay.neighbors[currentIndex];
|
|
121
|
-
const keyMapping = (0, $
|
|
121
|
+
const keyMapping = (0, $eaw9D$useMemo)(()=>{
|
|
122
122
|
return $347c34ac01fb689b$var$buildKeyMapping(neighbors, centroids, currentIndex, projection);
|
|
123
123
|
}, [
|
|
124
124
|
neighbors,
|
|
125
125
|
currentIndex
|
|
126
126
|
]);
|
|
127
|
-
(0, $
|
|
127
|
+
(0, $eaw9D$useKeyHandler)((event)=>{
|
|
128
128
|
const nextColumnIx = keyMapping[event.keyCode];
|
|
129
129
|
if (nextColumnIx == null) return;
|
|
130
130
|
const { col_id: col_id } = features[nextColumnIx].properties;
|
|
@@ -138,8 +138,8 @@ function $347c34ac01fb689b$export$8c41dd563753848(props) {
|
|
|
138
138
|
]);
|
|
139
139
|
if (neighbors == null) return null;
|
|
140
140
|
const neighborFeatures = neighbors.map((d)=>features[d]);
|
|
141
|
-
return (0, $
|
|
142
|
-
(0, $
|
|
141
|
+
return (0, $eaw9D$macrostrathyper).if(showLayers)([
|
|
142
|
+
(0, $eaw9D$macrostrathyper)((0, $eaw9D$FeatureLayer), {
|
|
143
143
|
features: tri.links().features,
|
|
144
144
|
useCanvas: false,
|
|
145
145
|
style: {
|
|
@@ -147,7 +147,7 @@ function $347c34ac01fb689b$export$8c41dd563753848(props) {
|
|
|
147
147
|
fill: "transparent"
|
|
148
148
|
}
|
|
149
149
|
}),
|
|
150
|
-
(0, $
|
|
150
|
+
(0, $eaw9D$macrostrathyper)((0, $eaw9D$FeatureLayer), {
|
|
151
151
|
features: neighborFeatures,
|
|
152
152
|
useCanvas: false,
|
|
153
153
|
style: {
|
|
@@ -173,7 +173,7 @@ function $347c34ac01fb689b$export$6b70218db02fa4ce({ apiRoute: apiRoute = "/colu
|
|
|
173
173
|
let all = undefined;
|
|
174
174
|
if (status_code == null && project_id == null) all = true;
|
|
175
175
|
const processor = $347c34ac01fb689b$var$processors[format];
|
|
176
|
-
return (0, $
|
|
176
|
+
return (0, $eaw9D$useAPIResult)(apiRoute, {
|
|
177
177
|
format: format,
|
|
178
178
|
all: all,
|
|
179
179
|
status_code: status_code,
|
|
@@ -190,8 +190,8 @@ const $347c34ac01fb689b$export$f02cc02ad0e0bba3 = (props)=>{
|
|
|
190
190
|
});
|
|
191
191
|
if (features == null) return null;
|
|
192
192
|
if (filterColumns != null) features = features.filter(filterColumns);
|
|
193
|
-
return (0, $
|
|
194
|
-
(0, $
|
|
193
|
+
return (0, $eaw9D$macrostrathyper)([
|
|
194
|
+
(0, $eaw9D$macrostrathyper)($347c34ac01fb689b$export$8c41dd563753848, {
|
|
195
195
|
features: features,
|
|
196
196
|
col_id: col_id,
|
|
197
197
|
onChange: onChange,
|
|
@@ -199,7 +199,7 @@ const $347c34ac01fb689b$export$f02cc02ad0e0bba3 = (props)=>{
|
|
|
199
199
|
project_id: project_id,
|
|
200
200
|
showLayers: showDebugLayers
|
|
201
201
|
}),
|
|
202
|
-
(0, $
|
|
202
|
+
(0, $eaw9D$macrostrathyper)($347c34ac01fb689b$export$f177ff57c101017a, {
|
|
203
203
|
features: features,
|
|
204
204
|
onClick: onChange,
|
|
205
205
|
color: color
|
|
@@ -207,14 +207,14 @@ const $347c34ac01fb689b$export$f02cc02ad0e0bba3 = (props)=>{
|
|
|
207
207
|
]);
|
|
208
208
|
};
|
|
209
209
|
const $347c34ac01fb689b$export$4d8f6e6df85d9012 = (props)=>{
|
|
210
|
-
return (0, $
|
|
210
|
+
return (0, $eaw9D$macrostrathyper)($347c34ac01fb689b$export$f02cc02ad0e0bba3, {
|
|
211
211
|
apiRoute: "/defs/columns",
|
|
212
212
|
...props
|
|
213
213
|
});
|
|
214
214
|
};
|
|
215
215
|
const $347c34ac01fb689b$export$b9d912252344e099 = (props)=>{
|
|
216
216
|
const { feature: feature } = props;
|
|
217
|
-
return (0, $
|
|
217
|
+
return (0, $eaw9D$macrostrathyper)((0, $eaw9D$FeatureLayer), {
|
|
218
218
|
features: [
|
|
219
219
|
feature
|
|
220
220
|
],
|
|
@@ -228,4 +228,4 @@ const $347c34ac01fb689b$export$b9d912252344e099 = (props)=>{
|
|
|
228
228
|
|
|
229
229
|
|
|
230
230
|
export {$347c34ac01fb689b$export$2254347cd20e6080 as MeasurementsLayer, $347c34ac01fb689b$export$4ad66a3119e1afaa as processTopoJSON, $347c34ac01fb689b$export$f177ff57c101017a as ColumnFeatures, $347c34ac01fb689b$export$8c41dd563753848 as ColumnKeyboardNavigation, $347c34ac01fb689b$export$6b70218db02fa4ce as useColumnData, $347c34ac01fb689b$export$f02cc02ad0e0bba3 as Columns, $347c34ac01fb689b$export$4d8f6e6df85d9012 as ColumnCenters, $347c34ac01fb689b$export$b9d912252344e099 as CurrentColumn};
|
|
231
|
-
//# sourceMappingURL=layers.
|
|
231
|
+
//# sourceMappingURL=layers.ad5fd25d.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;AAcA,MAAM,qCAAe;IACnB,MAAM;IACN,QAAQ;AACV;AAEO,SAAS,0CAAkB,KAAK;IACrC,MAAM,SAAE,QAAQ,oCAAc,GAAG,QAAQ,GAAG;IAC5C,MAAM,MAAW,CAAA,GAAA,mBAAW,EAAE,iBAAiB;QAC7C,GAAG,MAAM;QACT,QAAQ;QACR,UAAU;IACZ;IACA,IAAI,OAAO,MAAM,OAAO;IAExB,OAAO,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,mBAAW,GAAG;QACrB,WAAW;eACX;QACA,UAAU,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAM,EAAE,UAAU,CAAC,OAAO,IAAI;IAC/D;AACF;AAMA,SAAS,0CAAgB,GAAG;IAC1B,IAAI;QACF,MAAM,QAAE,IAAI,EAAE,GAAG,IAAI,OAAO;QAC5B,MAAM,EAAE,UAAU,CAAC,EAAE,GAAG,CAAA,GAAA,cAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM;QACzD,OAAO;IACT,EAAE,OAAO,KAAK;QACZ,QAAQ,KAAK,CAAC;QACd,OAAO,EAAE;IACX;AACF;AACA,SAAS,0CAAe,KAAK;IAC3B,MAAM,YACJ,QAAQ,WACR,OAAO,SACP,QAAQ,uCACR,gBAAgB,MACjB,GAAG;IAEJ,MAAM,IAAI,CAAA,GAAA,eAAK,EAAE;IAEjB,OAAO,CAAA,GAAA,sBAAA,EACL,CAAA,GAAA,mBAAW,GACX;QACE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;QACP,CAAA,GAAA,sBAAA,EAAE,0CAA0B;sBAC1B;oBACA;sBACA;yBACA;wBACA;YACA,YAAY;QACd;QACA,CAAA,GAAA,sBAAA,EAAE,2CAAgB;sBAAE;YAAU,SAAS;mBAAU;QAAM;KACxD;AACH;AAEA,MAAM,4CAAgB,CAAC;IACrB,OAAO,CAAA,GAAA,sBAAA,EAAE,2CAAS;QAAE,UAAU;QAAiB,GAAG,KAAK;IAAC;AAC1D;AAEA,MAAM,4CAAgB,CAAC;IACrB,MAAM,WAAE,OAAO,EAAE,GAAG;IACpB,OAAO,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,mBAAW,GAAG;QACrB,UAAU;YAAC;SAAQ;QACnB,OAAO;YACL,MAAM;YACN,QAAQ;YACR,aAAa;QACf;IACF;AACF","sources":["packages/column-views/src/map/layers.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n Feature,\n FeatureLayer,\n MapContext,\n} from \"@macrostrat/svg-map-components\";\nimport { useAPIResult, useKeyHandler } from \"@macrostrat/ui-components\";\nimport chroma from \"chroma-js\";\nimport { ExtendedFeature, geoCentroid } from \"d3-geo\";\nimport { geoVoronoi } from \"d3-geo-voronoi\";\nimport { FeatureCollection, GeometryCollection, Polygon } from \"geojson\";\nimport { useContext, useEffect, useMemo } from \"react\";\nimport { feature } from \"topojson-client\";\n\nconst defaultStyle = {\n fill: \"rgb(239, 180, 249)\",\n stroke: \"magenta\",\n};\n\nexport function MeasurementsLayer(props) {\n const { style = defaultStyle, ...params } = props;\n const res: any = useAPIResult(\"/measurements\", {\n ...params,\n format: \"geojson\",\n response: \"light\",\n });\n if (res == null) return null;\n\n return h(FeatureLayer, {\n useCanvas: false,\n style,\n features: res.features.filter((d) => d.properties.unit_id != null),\n });\n}\n\ntype ColumnProps = { col_id: number };\n\ntype ColumnFeature = ExtendedFeature<Polygon, ColumnProps>;\n\nfunction processTopoJSON(res) {\n try {\n const { data } = res.success;\n const { features: f } = feature(data, data.objects.output) as any;\n return f;\n } catch (err) {\n console.error(err);\n return [];\n }\n}\nfunction ColumnFeatures(props) {\n const {\n features,\n onClick,\n color = \"rgba(150,150,150, 1)\",\n singleFeature = true,\n } = props;\n\n const c = chroma(color);\n\n return h(\n FeatureLayer,\n {\n className: \"columns\",\n useCanvas: onClick == null,\n style: {\n fill: c.alpha(0.2).css(),\n stroke: c.alpha(0.4).css(),\n },\n },\n features.map((f) => {\n return h(Feature, {\n id: f.id ?? f.properties.col_id,\n onClick,\n feature: f,\n });\n })\n );\n}\n\nenum MacrostratStatusCode {\n InProcess = \"in process\",\n}\n\ninterface ColumnNavProps {\n col_id: number;\n status_code?: MacrostratStatusCode;\n project_id?: number;\n onChange(col_id: number): void;\n}\n\ninterface KeyboardNavProps extends ColumnNavProps {\n features: ColumnFeature[];\n showLayers: boolean;\n}\n\nfunction normalize(angle) {\n if (angle > Math.PI) {\n angle -= 2 * Math.PI;\n } else if (angle <= -Math.PI) {\n angle += 2 * Math.PI;\n }\n return angle;\n}\n\nfunction buildTriangulation(features) {\n console.log(\"Computing triangulation\");\n const centroids = features.map(geoCentroid);\n const tri = geoVoronoi(centroids);\n return { centroids, tri };\n}\n\nfunction buildKeyMapping(neighbors, centroids, currentIndex, projection) {\n if (neighbors == null) return;\n\n const currentCentroid = projection(centroids[currentIndex]);\n\n let edgeAngles = neighbors.map((index) => {\n const centroid = projection(centroids[index]);\n const dx = centroid[0] - currentCentroid[0];\n const dy = centroid[1] - currentCentroid[1];\n return { col_index: index, angle: Math.atan2(dy, dx) };\n });\n\n edgeAngles.sort((d) => d.angle);\n\n function closestAngle(num) {\n // Find closest angle in array of neighbors\n let curr = edgeAngles[0];\n for (let next of edgeAngles) {\n if (\n Math.abs(normalize(num - next.angle)) <\n Math.abs(normalize(num - curr.angle))\n ) {\n curr = next;\n }\n }\n return curr.col_index;\n }\n\n return {\n 37: closestAngle(Math.PI), // left\n 38: closestAngle((3 * Math.PI) / 2), // up\n 39: closestAngle(0), // right\n 40: closestAngle(Math.PI / 2), // down\n };\n}\n\nfunction ColumnKeyboardNavigation(props: KeyboardNavProps) {\n /** Keyboard navigation of columns using a Delaunay triangulation */\n const {\n features = [],\n col_id = null,\n onChange,\n showLayers = false,\n ...projectArgs\n } = props;\n const { projection } = useContext(MapContext);\n const { centroids, tri } = useMemo(\n () => buildTriangulation(features),\n [features]\n );\n\n const currentIndex = useMemo(() => {\n return features.findIndex((d) => d.properties.col_id == col_id);\n }, [features, col_id]);\n\n const neighbors = tri.delaunay.neighbors[currentIndex];\n\n const keyMapping = useMemo(() => {\n return buildKeyMapping(neighbors, centroids, currentIndex, projection);\n }, [neighbors, currentIndex]);\n\n useKeyHandler(\n (event) => {\n const nextColumnIx = keyMapping[event.keyCode];\n if (nextColumnIx == null) return;\n const { col_id } = features[nextColumnIx].properties;\n\n // @ts-ignore\n onChange({ col_id, ...projectArgs });\n },\n [keyMapping]\n );\n\n if (neighbors == null) return null;\n const neighborFeatures = neighbors.map((d) => features[d]);\n\n return h.if(showLayers)([\n h(FeatureLayer, {\n features: tri.links().features,\n useCanvas: false,\n style: {\n stroke: \"purple\",\n fill: \"transparent\",\n },\n }),\n h(FeatureLayer, {\n features: neighborFeatures,\n useCanvas: false,\n style: {\n stroke: \"rgb(93, 101, 212)\",\n strokeWidth: 3,\n fill: \"rgba(93, 101, 212, 0.5)\",\n },\n }),\n\n //h(FeatureLayer, {features: tri.centers, useCanvas: false})\n ]);\n}\n\nfunction processGeoJSON(res) {\n return processGeoJSONBare(res?.success?.data);\n}\n\nfunction processGeoJSONBare(res) {\n return res?.features;\n}\n\nconst processors = {\n topojson: processTopoJSON,\n geojson: processGeoJSON,\n geojson_bare: processGeoJSONBare,\n};\n\nfunction useColumnData({\n apiRoute = \"/columns\",\n status_code,\n project_id,\n format = \"topojson\",\n}) {\n let all: boolean = undefined;\n if (status_code == null && project_id == null) {\n all = true;\n }\n\n const processor = processors[format];\n\n return useAPIResult(\n apiRoute,\n { format, all, status_code, project_id },\n processor\n );\n}\n\ninterface ColumnExtraInfo {\n apiRoute?: string;\n color?: string;\n filterColumns?(d: ColumnFeature): boolean;\n showDebugLayers?: boolean;\n format?: \"topojson\" | \"geojson\";\n}\n\nconst Columns = (props: ColumnNavProps & ColumnExtraInfo) => {\n const {\n apiRoute = \"/columns\",\n onChange,\n col_id = null,\n status_code,\n project_id,\n color,\n filterColumns,\n showDebugLayers = false,\n format = \"topojson\",\n } = props;\n\n let features: any[] = useColumnData({\n apiRoute,\n status_code,\n project_id,\n format,\n }) as any;\n\n if (features == null) return null;\n\n if (filterColumns != null) {\n features = features.filter(filterColumns);\n }\n\n return h([\n h(ColumnKeyboardNavigation, {\n features,\n col_id,\n onChange,\n status_code,\n project_id,\n showLayers: showDebugLayers,\n }),\n h(ColumnFeatures, { features, onClick: onChange, color }),\n ]);\n};\n\nconst ColumnCenters = (props: ColumnNavProps) => {\n return h(Columns, { apiRoute: \"/defs/columns\", ...props });\n};\n\nconst CurrentColumn = (props) => {\n const { feature } = props;\n return h(FeatureLayer, {\n features: [feature],\n style: {\n fill: \"rgba(255,0,0,0.4)\",\n stroke: \"rgba(255,0,0,0.6)\",\n strokeWidth: 2,\n },\n });\n};\n\nexport {\n Columns,\n CurrentColumn,\n processTopoJSON,\n ColumnCenters,\n ColumnFeatures,\n ColumnKeyboardNavigation,\n useColumnData,\n};\n"],"names":[],"version":3,"file":"layers.946aaa37.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;AAcA,MAAM,qCAAe;IACnB,MAAM;IACN,QAAQ;AACV;AAEO,SAAS,0CAAkB,KAAK;IACrC,MAAM,SAAE,QAAQ,oCAAc,GAAG,QAAQ,GAAG;IAC5C,MAAM,MAAW,CAAA,GAAA,mBAAW,EAAE,iBAAiB;QAC7C,GAAG,MAAM;QACT,QAAQ;QACR,UAAU;IACZ;IACA,IAAI,OAAO,MAAM,OAAO;IAExB,OAAO,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,mBAAW,GAAG;QACrB,WAA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AS,0CAAc,YACrB,WAAW,yBACX,WAAW,cACX,UAAU,UACV,SAAS,YACV;IACC,IAAI,MAAe;IACnB,IAAI,eAAe,QAAQ,cAAc,MACvC,MAAM;IAGR,MAAM,YAAY,gCAAU,CAAC,OAAO;IAEpC,OAAO,CAAA,GAAA,mBAAW,EAChB,UACA;gBAAE;aAAQ;qBAAK;oBAAa;IAAW,GACvC;AAEJ;AAUA,MAAM,4CAAU,CAAC;IACf,MAAM,YACJ,WAAW,sBACX,QAAQ,UACR,SAAS,mBACT,WAAW,cACX,UAAU,SACV,KAAK,iBACL,aAAa,mBACb,kBAAkB,eAClB,SAAS,YACV,GAAG;IAEJ,IAAI,WAAkB,0CAAc;kBAClC;qBACA;oBACA;gBACA;IACF;IAEA,IAAI,YAAY,MAAM,OAAO;IAE7B,IAAI,iBAAiB,MACnB,WAAW,SAAS,MAAM,CAAC;IAG7B,OAAO,CAAA,GAAA,sBAAA,EAAE;QACP,CAAA,GAAA,sBAAA,EAAE,0CAA0B;sBAC1B;oBACA;sBACA;yBACA;wBACA;YACA,YAAY;QACd;QACA,CAAA,GAAA,sBAAA,EAAE,2CAAgB;sBAAE;YAAU,SAAS;mBAAU;QAAM;KACxD;AACH;AAEA,MAAM,4CAAgB,CAAC;IACrB,OAAO,CAAA,GAAA,sBAAA,EAAE,2CAAS;QAAE,UAAU;QAAiB,GAAG,KAAK;IAAC;AAC1D;AAEA,MAAM,4CAAgB,CAAC;IACrB,MAAM,WAAE,OAAO,EAAE,GAAG;IACpB,OAAO,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,mBAAW,GAAG;QACrB,UAAU;YAAC;SAAQ;QACnB,OAAO;YACL,MAAM;YACN,QAAQ;YACR,aAAa;QACf;IACF;AACF","sources":["packages/column-views/src/map/layers.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n Feature,\n FeatureLayer,\n MapContext,\n} from \"@macrostrat/svg-map-components\";\nimport { useAPIResult, useKeyHandler } from \"@macrostrat/ui-components\";\nimport chroma from \"chroma-js\";\nimport { ExtendedFeature, geoCentroid } from \"d3-geo\";\nimport { geoVoronoi } from \"d3-geo-voronoi\";\nimport { FeatureCollection, GeometryCollection, Polygon } from \"geojson\";\nimport { useContext, useEffect, useMemo } from \"react\";\nimport { feature } from \"topojson-client\";\n\nconst defaultStyle = {\n fill: \"rgb(239, 180, 249)\",\n stroke: \"magenta\",\n};\n\nexport function MeasurementsLayer(props) {\n const { style = defaultStyle, ...params } = props;\n const res: any = useAPIResult(\"/measurements\", {\n ...params,\n format: \"geojson\",\n response: \"light\",\n });\n if (res == null) return null;\n\n return h(FeatureLayer, {\n useCanvas: false,\n style,\n features: res.features.filter((d) => d.properties.unit_id != null),\n });\n}\n\ntype ColumnProps = { col_id: number };\n\ntype ColumnFeature = ExtendedFeature<Polygon, ColumnProps>;\n\nfunction processTopoJSON(res) {\n try {\n const { data } = res.success;\n const { features: f } = feature(data, data.objects.output) as any;\n return f;\n } catch (err) {\n console.error(err);\n return [];\n }\n}\nfunction ColumnFeatures(props) {\n const {\n features,\n onClick,\n color = \"rgba(150,150,150, 1)\",\n singleFeature = true,\n } = props;\n\n const c = chroma(color);\n\n return h(\n FeatureLayer,\n {\n className: \"columns\",\n useCanvas: onClick == null,\n style: {\n fill: c.alpha(0.2).css(),\n stroke: c.alpha(0.4).css(),\n },\n },\n features.map((f) => {\n return h(Feature, {\n id: f.id ?? f.properties.col_id,\n onClick,\n feature: f,\n });\n })\n );\n}\n\nenum MacrostratStatusCode {\n InProcess = \"in process\",\n}\n\ninterface ColumnNavProps {\n col_id: number;\n status_code?: MacrostratStatusCode;\n project_id?: number;\n onChange(col_id: number): void;\n}\n\ninterface KeyboardNavProps extends ColumnNavProps {\n features: ColumnFeature[];\n showLayers: boolean;\n}\n\nfunction normalize(angle) {\n if (angle > Math.PI) {\n angle -= 2 * Math.PI;\n } else if (angle <= -Math.PI) {\n angle += 2 * Math.PI;\n }\n return angle;\n}\n\nfunction buildTriangulation(features) {\n console.log(\"Computing triangulation\");\n const centroids = features.map(geoCentroid);\n const tri = geoVoronoi(centroids);\n return { centroids, tri };\n}\n\nfunction buildKeyMapping(neighbors, centroids, currentIndex, projection) {\n if (neighbors == null) return;\n\n const currentCentroid = projection(centroids[currentIndex]);\n\n let edgeAngles = neighbors.map((index) => {\n const centroid = projection(centroids[index]);\n const dx = centroid[0] - currentCentroid[0];\n const dy = centroid[1] - currentCentroid[1];\n return { col_index: index, angle: Math.atan2(dy, dx) };\n });\n\n edgeAngles.sort((d) => d.angle);\n\n function closestAngle(num) {\n // Find closest angle in array of neighbors\n let curr = edgeAngles[0];\n for (let next of edgeAngles) {\n if (\n Math.abs(normalize(num - next.angle)) <\n Math.abs(normalize(num - curr.angle))\n ) {\n curr = next;\n }\n }\n return curr.col_index;\n }\n\n return {\n 37: closestAngle(Math.PI), // left\n 38: closestAngle((3 * Math.PI) / 2), // up\n 39: closestAngle(0), // right\n 40: closestAngle(Math.PI / 2), // down\n };\n}\n\nfunction ColumnKeyboardNavigation(props: KeyboardNavProps) {\n /** Keyboard navigation of columns using a Delaunay triangulation */\n const {\n features = [],\n col_id = null,\n onChange,\n showLayers = false,\n ...projectArgs\n } = props;\n const { projection } = useContext(MapContext);\n const { centroids, tri } = useMemo(\n () => buildTriangulation(features),\n [features]\n );\n\n const currentIndex = useMemo(() => {\n return features.findIndex((d) => d.properties.col_id == col_id);\n }, [features, col_id]);\n\n const neighbors = tri.delaunay.neighbors[currentIndex];\n\n const keyMapping = useMemo(() => {\n return buildKeyMapping(neighbors, centroids, currentIndex, projection);\n }, [neighbors, currentIndex]);\n\n useKeyHandler(\n (event) => {\n const nextColumnIx = keyMapping[event.keyCode];\n if (nextColumnIx == null) return;\n const { col_id } = features[nextColumnIx].properties;\n\n // @ts-ignore\n onChange({ col_id, ...projectArgs });\n },\n [keyMapping]\n );\n\n if (neighbors == null) return null;\n const neighborFeatures = neighbors.map((d) => features[d]);\n\n return h.if(showLayers)([\n h(FeatureLayer, {\n features: tri.links().features,\n useCanvas: false,\n style: {\n stroke: \"purple\",\n fill: \"transparent\",\n },\n }),\n h(FeatureLayer, {\n features: neighborFeatures,\n useCanvas: false,\n style: {\n stroke: \"rgb(93, 101, 212)\",\n strokeWidth: 3,\n fill: \"rgba(93, 101, 212, 0.5)\",\n },\n }),\n\n //h(FeatureLayer, {features: tri.centers, useCanvas: false})\n ]);\n}\n\nfunction processGeoJSON(res) {\n return processGeoJSONBare(res?.success?.data);\n}\n\nfunction processGeoJSONBare(res) {\n return res?.features;\n}\n\nconst processors = {\n topojson: processTopoJSON,\n geojson: processGeoJSON,\n geojson_bare: processGeoJSONBare,\n};\n\nfunction useColumnData({\n apiRoute = \"/columns\",\n status_code,\n project_id,\n format = \"topojson\",\n}) {\n let all: boolean = undefined;\n if (status_code == null && project_id == null) {\n all = true;\n }\n\n const processor = processors[format];\n\n return useAPIResult(\n apiRoute,\n { format, all, status_code, project_id },\n processor\n );\n}\n\ninterface ColumnExtraInfo {\n apiRoute?: string;\n color?: string;\n filterColumns?(d: ColumnFeature): boolean;\n showDebugLayers?: boolean;\n format?: \"topojson\" | \"geojson\";\n}\n\nconst Columns = (props: ColumnNavProps & ColumnExtraInfo) => {\n const {\n apiRoute = \"/columns\",\n onChange,\n col_id = null,\n status_code,\n project_id,\n color,\n filterColumns,\n showDebugLayers = false,\n format = \"topojson\",\n } = props;\n\n let features: any[] = useColumnData({\n apiRoute,\n status_code,\n project_id,\n format,\n }) as any;\n\n if (features == null) return null;\n\n if (filterColumns != null) {\n features = features.filter(filterColumns);\n }\n\n return h([\n h(ColumnKeyboardNavigation, {\n features,\n col_id,\n onChange,\n status_code,\n project_id,\n showLayers: showDebugLayers,\n }),\n h(ColumnFeatures, { features, onClick: onChange, color }),\n ]);\n};\n\nconst ColumnCenters = (props: ColumnNavProps) => {\n return h(Columns, { apiRoute: \"/defs/columns\", ...props });\n};\n\nconst CurrentColumn = (props) => {\n const { feature } = props;\n return h(FeatureLayer, {\n features: [feature],\n style: {\n fill: \"rgba(255,0,0,0.4)\",\n stroke: \"rgba(255,0,0,0.6)\",\n strokeWidth: 2,\n },\n });\n};\n\nexport {\n Columns,\n CurrentColumn,\n processTopoJSON,\n ColumnCenters,\n ColumnFeatures,\n ColumnKeyboardNavigation,\n useColumnData,\n};\n"],"names":[],"version":3,"file":"layers.ad5fd25d.js.map"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {Columns as $347c34ac01fb689b$export$f02cc02ad0e0bba3, CurrentColumn as $347c34ac01fb689b$export$b9d912252344e099, MeasurementsLayer as $347c34ac01fb689b$export$2254347cd20e6080, processTopoJSON as $347c34ac01fb689b$export$4ad66a3119e1afaa, ColumnFeatures as $347c34ac01fb689b$export$f177ff57c101017a, ColumnKeyboardNavigation as $347c34ac01fb689b$export$8c41dd563753848, useColumnData as $347c34ac01fb689b$export$6b70218db02fa4ce, ColumnCenters as $347c34ac01fb689b$export$4d8f6e6df85d9012} from "./layers.
|
|
2
|
-
import {useRef as $
|
|
3
|
-
import $
|
|
4
|
-
import {Globe as $
|
|
5
|
-
import {geoCentroid as $
|
|
6
|
-
import {useElementSize as $
|
|
1
|
+
import {Columns as $347c34ac01fb689b$export$f02cc02ad0e0bba3, CurrentColumn as $347c34ac01fb689b$export$b9d912252344e099, MeasurementsLayer as $347c34ac01fb689b$export$2254347cd20e6080, processTopoJSON as $347c34ac01fb689b$export$4ad66a3119e1afaa, ColumnFeatures as $347c34ac01fb689b$export$f177ff57c101017a, ColumnKeyboardNavigation as $347c34ac01fb689b$export$8c41dd563753848, useColumnData as $347c34ac01fb689b$export$6b70218db02fa4ce, ColumnCenters as $347c34ac01fb689b$export$4d8f6e6df85d9012} from "./layers.ad5fd25d.js";
|
|
2
|
+
import {useRef as $kMgW8$useRef} from "react";
|
|
3
|
+
import $kMgW8$macrostrathyper from "@macrostrat/hyper";
|
|
4
|
+
import {Globe as $kMgW8$Globe, LandLayer as $kMgW8$LandLayer} from "@macrostrat/svg-map-components";
|
|
5
|
+
import {geoCentroid as $kMgW8$geoCentroid} from "d3-geo";
|
|
6
|
+
import {useElementSize as $kMgW8$useElementSize} from "@macrostrat/ui-components";
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -14,8 +14,8 @@ import {useElementSize as $dvC2Q$useElementSize} from "@macrostrat/ui-components
|
|
|
14
14
|
function $157bdadaa2bcfcf5$export$c4313db718750a5a(props) {
|
|
15
15
|
const { center: center, children: children, style: style, margin: margin, className: className, allowZoom: allowZoom, ...rest } = props;
|
|
16
16
|
let { scale: scale } = props;
|
|
17
|
-
const ref = (0, $
|
|
18
|
-
const sz = (0, $
|
|
17
|
+
const ref = (0, $kMgW8$useRef)(null);
|
|
18
|
+
const sz = (0, $kMgW8$useElementSize)(ref);
|
|
19
19
|
const { width: width, height: height } = sz ?? {
|
|
20
20
|
width: 0,
|
|
21
21
|
height: 0
|
|
@@ -26,12 +26,12 @@ function $157bdadaa2bcfcf5$export$c4313db718750a5a(props) {
|
|
|
26
26
|
0.1 * Math.min(width, height),
|
|
27
27
|
2 * Math.max(width, height)
|
|
28
28
|
];
|
|
29
|
-
return (0, $
|
|
29
|
+
return (0, $kMgW8$macrostrathyper)("div.map-area", {
|
|
30
30
|
ref: ref,
|
|
31
31
|
style: style,
|
|
32
32
|
className: className
|
|
33
33
|
}, [
|
|
34
|
-
(0, $
|
|
34
|
+
(0, $kMgW8$macrostrathyper)((0, $kMgW8$Globe), {
|
|
35
35
|
width: width,
|
|
36
36
|
height: height,
|
|
37
37
|
margin: margin,
|
|
@@ -43,15 +43,15 @@ function $157bdadaa2bcfcf5$export$c4313db718750a5a(props) {
|
|
|
43
43
|
...rest,
|
|
44
44
|
scale: scale
|
|
45
45
|
}, [
|
|
46
|
-
(0, $
|
|
46
|
+
(0, $kMgW8$macrostrathyper)((0, $kMgW8$LandLayer)),
|
|
47
47
|
children
|
|
48
48
|
])
|
|
49
49
|
]);
|
|
50
50
|
}
|
|
51
51
|
const $157bdadaa2bcfcf5$export$d9144ecbc6b090c5 = (props)=>{
|
|
52
52
|
const { currentColumn: currentColumn, setCurrentColumn: setCurrentColumn, children: children, style: style, margin: margin = 10, scale: scale, className: className, showInProcessColumns: showInProcessColumns = false, ...rest } = props;
|
|
53
|
-
const columnCenter = (0, $
|
|
54
|
-
return (0, $
|
|
53
|
+
const columnCenter = (0, $kMgW8$geoCentroid)(currentColumn);
|
|
54
|
+
return (0, $kMgW8$macrostrathyper)($157bdadaa2bcfcf5$export$c4313db718750a5a, {
|
|
55
55
|
center: columnCenter,
|
|
56
56
|
style: style,
|
|
57
57
|
margin: margin,
|
|
@@ -59,19 +59,19 @@ const $157bdadaa2bcfcf5$export$d9144ecbc6b090c5 = (props)=>{
|
|
|
59
59
|
className: className
|
|
60
60
|
}, [
|
|
61
61
|
children,
|
|
62
|
-
(0, $
|
|
62
|
+
(0, $kMgW8$macrostrathyper)((0, $347c34ac01fb689b$export$f02cc02ad0e0bba3), {
|
|
63
63
|
onChange: setCurrentColumn,
|
|
64
64
|
col_id: currentColumn?.properties.col_id,
|
|
65
65
|
...rest
|
|
66
66
|
}),
|
|
67
|
-
(0, $
|
|
67
|
+
(0, $kMgW8$macrostrathyper).if(showInProcessColumns)((0, $347c34ac01fb689b$export$f02cc02ad0e0bba3), {
|
|
68
68
|
onChange: setCurrentColumn,
|
|
69
69
|
col_id: currentColumn?.properties.col_id,
|
|
70
70
|
status_code: "in process",
|
|
71
71
|
color: "rgba(200,150,150, 0.5)",
|
|
72
72
|
...rest
|
|
73
73
|
}),
|
|
74
|
-
(0, $
|
|
74
|
+
(0, $kMgW8$macrostrathyper).if(currentColumn != null)((0, $347c34ac01fb689b$export$b9d912252344e099), {
|
|
75
75
|
feature: currentColumn
|
|
76
76
|
})
|
|
77
77
|
]);
|
|
@@ -79,4 +79,4 @@ const $157bdadaa2bcfcf5$export$d9144ecbc6b090c5 = (props)=>{
|
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
export {$157bdadaa2bcfcf5$export$c4313db718750a5a as ResizableMapFrame, $157bdadaa2bcfcf5$export$d9144ecbc6b090c5 as ColumnNavigatorMap, $347c34ac01fb689b$export$2254347cd20e6080 as MeasurementsLayer, $347c34ac01fb689b$export$4ad66a3119e1afaa as processTopoJSON, $347c34ac01fb689b$export$f177ff57c101017a as ColumnFeatures, $347c34ac01fb689b$export$8c41dd563753848 as ColumnKeyboardNavigation, $347c34ac01fb689b$export$6b70218db02fa4ce as useColumnData, $347c34ac01fb689b$export$f02cc02ad0e0bba3 as Columns, $347c34ac01fb689b$export$4d8f6e6df85d9012 as ColumnCenters, $347c34ac01fb689b$export$b9d912252344e099 as CurrentColumn};
|
|
82
|
-
//# sourceMappingURL=map.
|
|
82
|
+
//# sourceMappingURL=map.7aa26f17.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AAOA,SAAS,0CAAkB,KAAK;IAC9B,MAAM,UAAE,MAAM,YAAE,QAAQ,SAAE,KAAK,UAAE,MAAM,aAAE,SAAS,aAAE,SAAS,EAAE,GAAG,MAAM,GACtE;IACF,IAAI,SAAE,KAAK,EAAE,GAAG;IAChB,MAAM,MAAM,CAAA,GAAA,aAAK,EAAE;IACnB,MAAM,KAAK,CAAA,GAAA,qBAAa,EAAE;IAC1B,MAAM,SAAE,KAAK,UAAE,MAAM,EAAE,GAAG,MAAM;QAAE,OAAO;QAAG,QAAQ;IAAE;IACtD,IAAI,SAAS,MACX,QAAQ,KAAK,GAAG,CAAC,OAAO,UAAU,IAAI;IAGxC,IAAI,kBAAkB;IAEtB,IAAI,WACF,kBAAkB;QAChB,MAAM,KAAK,GAAG,CAAC,OAAO;QACtB,IAAI,KAAK,GAAG,CAAC,OAAO;KACrB;IAGH,OAAO,CAAA,GAAA,sBAAA,EAAE,gBAAgB;aAAE;eAAK;mBAAO;IAAU,GAAG;QAClD,CAAA,GAAA,sBAAA,EACE,CAAA,GAAA,YAAI,GACJ;mBACE;oBACA;oBACA;oBACA;YACA,WAAW;uBACX;YACA,aAAa;6BACb;YACA,GAAG,IAAI;mBACP;QACF,GACA;YAAC,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,gBAAQ;YAAI;SAAS;KAE3B;AACH;AAEA,MAAM,4CAAqB,CAAC;IAC1B,MAAM,iBACJ,aAAa,oBACb,gBAAgB,YAChB,QAAQ,SACR,KAAK,UACL,SAAS,WACT,KAAK,aACL,SAAS,wBACT,uBAAuB,OACvB,GAAG,MACJ,GAAG;IAEJ,MAAM,eAAe,CAAA,GAAA,kBAAU,EAAE;IAEjC,OAAO,CAAA,GAAA,sBAAA,EACL,2CACA;QAAE,QAAQ;eAAc;gBAAO;eAAQ;mBAAO;IAAU,GACxD;QACE;QACA,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,yCAAM,GAAG;YACT,UAAU;YACV,QAAQ,eAAe,WAAW;YAClC,GAAG,IAAI;QACT;QACA,CAAA,GAAA,sBAAA,EAAE,EAAE,CAAC,sBAAsB,CAAA,GAAA,yCAAM,GAAG;YAClC,UAAU;YACV,QAAQ,eAAe,WAAW;YAClC,aAAa;YACb,OAAO;YACP,GAAG,IAAI;QACT;QACA,CAAA,GAAA,sBAAA,EAAE,EAAE,CAAC,iBAAiB,MAAM,CAAA,GAAA,yCAAY,GAAG;YAAE,SAAS;QAAc;KACrE;AAEL","sources":["packages/column-views/src/map/index.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport h from \"@macrostrat/hyper\";\nimport { Globe, LandLayer } from \"@macrostrat/svg-map-components\";\nimport { geoCentroid } from \"d3-geo\";\nimport { useElementSize } from \"@macrostrat/ui-components\";\nimport { Columns, CurrentColumn } from \"./layers\";\n\nfunction ResizableMapFrame(props) {\n const { center, children, style, margin, className, allowZoom, ...rest } =\n props;\n let { scale } = props;\n const ref = useRef(null);\n const sz = useElementSize(ref);\n const { width, height } = sz ?? { width: 0, height: 0 };\n if (scale == null) {\n scale = Math.min(width, height) + 2 * margin;\n }\n\n let zoomScaleExtent = null;\n\n if (allowZoom) {\n zoomScaleExtent = [\n 0.1 * Math.min(width, height),\n 2 * Math.max(width, height),\n ];\n }\n\n return h(\"div.map-area\", { ref, style, className }, [\n h(\n Globe,\n {\n width,\n height,\n margin,\n center,\n allowDrag: true,\n allowZoom,\n keepNorthUp: true,\n zoomScaleExtent,\n ...rest,\n scale,\n },\n [h(LandLayer), children]\n ),\n ]);\n}\n\nconst ColumnNavigatorMap = (props) => {\n const {\n currentColumn,\n setCurrentColumn,\n children,\n style,\n margin = 10,\n scale,\n className,\n showInProcessColumns = false,\n ...rest\n } = props;\n\n const columnCenter = geoCentroid(currentColumn);\n\n return h(\n ResizableMapFrame,\n { center: columnCenter, style, margin, scale, className },\n [\n children,\n h(Columns, {\n onChange: setCurrentColumn,\n col_id: currentColumn?.properties.col_id,\n ...rest,\n }),\n h.if(showInProcessColumns)(Columns, {\n onChange: setCurrentColumn,\n col_id: currentColumn?.properties.col_id,\n status_code: \"in process\",\n color: \"rgba(200,150,150, 0.5)\",\n ...rest,\n }),\n h.if(currentColumn != null)(CurrentColumn, { feature: currentColumn }),\n ]\n );\n};\n\nexport * from \"./layers\";\nexport { ColumnNavigatorMap, ResizableMapFrame };\n"],"names":[],"version":3,"file":"map.
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AAOA,SAAS,0CAAkB,KAAK;IAC9B,MAAM,UAAE,MAAM,YAAE,QAAQ,SAAE,KAAK,UAAE,MAAM,aAAE,SAAS,aAAE,SAAS,EAAE,GAAG,MAAM,GACtE;IACF,IAAI,SAAE,KAAK,EAAE,GAAG;IAChB,MAAM,MAAM,CAAA,GAAA,aAAK,EAAE;IACnB,MAAM,KAAK,CAAA,GAAA,qBAAa,EAAE;IAC1B,MAAM,SAAE,KAAK,UAAE,MAAM,EAAE,GAAG,MAAM;QAAE,OAAO;QAAG,QAAQ;IAAE;IACtD,IAAI,SAAS,MACX,QAAQ,KAAK,GAAG,CAAC,OAAO,UAAU,IAAI;IAGxC,IAAI,kBAAkB;IAEtB,IAAI,WACF,kBAAkB;QAChB,MAAM,KAAK,GAAG,CAAC,OAAO;QACtB,IAAI,KAAK,GAAG,CAAC,OAAO;KACrB;IAGH,OAAO,CAAA,GAAA,sBAAA,EAAE,gBAAgB;aAAE;eAAK;mBAAO;IAAU,GAAG;QAClD,CAAA,GAAA,sBAAA,EACE,CAAA,GAAA,YAAI,GACJ;mBACE;oBACA;oBACA;oBACA;YACA,WAAW;uBACX;YACA,aAAa;6BACb;YACA,GAAG,IAAI;mBACP;QACF,GACA;YAAC,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,gBAAQ;YAAI;SAAS;KAE3B;AACH;AAEA,MAAM,4CAAqB,CAAC;IAC1B,MAAM,iBACJ,aAAa,oBACb,gBAAgB,YAChB,QAAQ,SACR,KAAK,UACL,SAAS,WACT,KAAK,aACL,SAAS,wBACT,uBAAuB,OACvB,GAAG,MACJ,GAAG;IAEJ,MAAM,eAAe,CAAA,GAAA,kBAAU,EAAE;IAEjC,OAAO,CAAA,GAAA,sBAAA,EACL,2CACA;QAAE,QAAQ;eAAc;gBAAO;eAAQ;mBAAO;IAAU,GACxD;QACE;QACA,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,yCAAM,GAAG;YACT,UAAU;YACV,QAAQ,eAAe,WAAW;YAClC,GAAG,IAAI;QACT;QACA,CAAA,GAAA,sBAAA,EAAE,EAAE,CAAC,sBAAsB,CAAA,GAAA,yCAAM,GAAG;YAClC,UAAU;YACV,QAAQ,eAAe,WAAW;YAClC,aAAa;YACb,OAAO;YACP,GAAG,IAAI;QACT;QACA,CAAA,GAAA,sBAAA,EAAE,EAAE,CAAC,iBAAiB,MAAM,CAAA,GAAA,yCAAY,GAAG;YAAE,SAAS;QAAc;KACrE;AAEL","sources":["packages/column-views/src/map/index.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport h from \"@macrostrat/hyper\";\nimport { Globe, LandLayer } from \"@macrostrat/svg-map-components\";\nimport { geoCentroid } from \"d3-geo\";\nimport { useElementSize } from \"@macrostrat/ui-components\";\nimport { Columns, CurrentColumn } from \"./layers\";\n\nfunction ResizableMapFrame(props) {\n const { center, children, style, margin, className, allowZoom, ...rest } =\n props;\n let { scale } = props;\n const ref = useRef(null);\n const sz = useElementSize(ref);\n const { width, height } = sz ?? { width: 0, height: 0 };\n if (scale == null) {\n scale = Math.min(width, height) + 2 * margin;\n }\n\n let zoomScaleExtent = null;\n\n if (allowZoom) {\n zoomScaleExtent = [\n 0.1 * Math.min(width, height),\n 2 * Math.max(width, height),\n ];\n }\n\n return h(\"div.map-area\", { ref, style, className }, [\n h(\n Globe,\n {\n width,\n height,\n margin,\n center,\n allowDrag: true,\n allowZoom,\n keepNorthUp: true,\n zoomScaleExtent,\n ...rest,\n scale,\n },\n [h(LandLayer), children]\n ),\n ]);\n}\n\nconst ColumnNavigatorMap = (props) => {\n const {\n currentColumn,\n setCurrentColumn,\n children,\n style,\n margin = 10,\n scale,\n className,\n showInProcessColumns = false,\n ...rest\n } = props;\n\n const columnCenter = geoCentroid(currentColumn);\n\n return h(\n ResizableMapFrame,\n { center: columnCenter, style, margin, scale, className },\n [\n children,\n h(Columns, {\n onChange: setCurrentColumn,\n col_id: currentColumn?.properties.col_id,\n ...rest,\n }),\n h.if(showInProcessColumns)(Columns, {\n onChange: setCurrentColumn,\n col_id: currentColumn?.properties.col_id,\n status_code: \"in process\",\n color: \"rgba(200,150,150, 0.5)\",\n ...rest,\n }),\n h.if(currentColumn != null)(CurrentColumn, { feature: currentColumn }),\n ]\n );\n};\n\nexport * from \"./layers\";\nexport { ColumnNavigatorMap, ResizableMapFrame };\n"],"names":[],"version":3,"file":"map.7aa26f17.js.map"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {transformAxisType as $faf1eba02aecac6a$export$ab2a19f8a72df19b} from "./types.
|
|
2
|
-
import $
|
|
3
|
-
import $
|
|
4
|
-
import {ColumnContext as $
|
|
1
|
+
import {transformAxisType as $faf1eba02aecac6a$export$ab2a19f8a72df19b} from "./types.f016e032.js";
|
|
2
|
+
import $5ZBll$macrostrathyper from "@macrostrat/hyper";
|
|
3
|
+
import $5ZBll$react, {useContext as $5ZBll$useContext, useCallback as $5ZBll$useCallback} from "react";
|
|
4
|
+
import {ColumnContext as $5ZBll$ColumnContext, NotesColumn as $5ZBll$NotesColumn} from "@macrostrat/column-components";
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -21,10 +21,10 @@ const $bc17276da4abb183$export$c9757aeb43a67df0 = (div)=>{
|
|
|
21
21
|
return div.unit_name.replace("Mbr", "Member").replace("Fm", "Formation").replace("Gp", "Group");
|
|
22
22
|
};
|
|
23
23
|
function $bc17276da4abb183$var$UnitDataColumn_(props) {
|
|
24
|
-
const ctx = (0, $
|
|
24
|
+
const ctx = (0, $5ZBll$useContext)((0, $5ZBll$ColumnContext));
|
|
25
25
|
const { left: left, noteComponent: noteComponent, shouldRenderNote: shouldRenderNote = (note, i)=>true, minimumHeight: minimumHeight = 0, divisions: divisions = ctx?.divisions, ...rest } = props;
|
|
26
26
|
const { scale: scale } = ctx;
|
|
27
|
-
const minimumHeightFilter = (0, $
|
|
27
|
+
const minimumHeightFilter = (0, $5ZBll$useCallback)((d)=>{
|
|
28
28
|
if (minimumHeight == 0) return true;
|
|
29
29
|
const dy = Math.abs(scale(d.top_height) - scale(d.height));
|
|
30
30
|
return dy > minimumHeight;
|
|
@@ -36,7 +36,7 @@ function $bc17276da4abb183$var$UnitDataColumn_(props) {
|
|
|
36
36
|
const notes = divisions.filter(shouldRenderNote).map((d)=>$bc17276da4abb183$export$2f2e65a797f8fc1e(d, {
|
|
37
37
|
axisType: ctx.axisType
|
|
38
38
|
})).filter(minimumHeightFilter);
|
|
39
|
-
return (0, $
|
|
39
|
+
return (0, $5ZBll$macrostrathyper)((0, $5ZBll$NotesColumn), {
|
|
40
40
|
transform: `translate(${left || 0})`,
|
|
41
41
|
editable: false,
|
|
42
42
|
noteComponent: noteComponent,
|
|
@@ -47,14 +47,14 @@ function $bc17276da4abb183$var$UnitDataColumn_(props) {
|
|
|
47
47
|
...rest
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
const $bc17276da4abb183$export$6316e673796ccb55 = (0, $
|
|
50
|
+
const $bc17276da4abb183$export$6316e673796ccb55 = (0, $5ZBll$react).memo($bc17276da4abb183$var$UnitDataColumn_);
|
|
51
51
|
function $bc17276da4abb183$export$594d19cdd88f8c16(props) {
|
|
52
52
|
const { nameForDivision: nameForDivision = $bc17276da4abb183$export$c9757aeb43a67df0, noteComponent: noteComponent, ...rest } = props;
|
|
53
53
|
const NoteComponent = (props)=>{
|
|
54
54
|
const { note: note } = props;
|
|
55
|
-
return (0, $
|
|
55
|
+
return (0, $5ZBll$macrostrathyper)("p.col-note-label", nameForDivision(note.data));
|
|
56
56
|
};
|
|
57
|
-
return (0, $
|
|
57
|
+
return (0, $5ZBll$macrostrathyper)($bc17276da4abb183$export$6316e673796ccb55, {
|
|
58
58
|
noteComponent: noteComponent ?? NoteComponent,
|
|
59
59
|
...rest
|
|
60
60
|
});
|
|
@@ -62,4 +62,4 @@ function $bc17276da4abb183$export$594d19cdd88f8c16(props) {
|
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
export {$bc17276da4abb183$export$2f2e65a797f8fc1e as noteForDivision, $bc17276da4abb183$export$c9757aeb43a67df0 as defaultNameFunction, $bc17276da4abb183$export$6316e673796ccb55 as UnitDataColumn, $bc17276da4abb183$export$594d19cdd88f8c16 as UnitNamesColumn};
|
|
65
|
-
//# sourceMappingURL=names.
|
|
65
|
+
//# sourceMappingURL=names.f6a4e9a4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AA4BA,SAAS,0CACP,GAAU,EACV,IAAkC;IAElC,MAAM,YAAE,QAAQ,EAAE,GAAG;IAErB,MAAM,MAAM,CAAA,GAAA,yCAAgB,EAAE;IAC9B,OAAO;QACL,QAAQ,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC;QACvB,YA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AM,QAAE,IAAI,EAAE,GAAG;QACjB,OAAO,CAAA,GAAA,sBAAA,EAAE,oBAAoB,gBAAgB,KAAK,IAAI;IACxD;IAEA,OAAO,CAAA,GAAA,sBAAA,EAAE,2CAAgB;QACvB,eAAe,iBAAiB;QAChC,GAAG,IAAI;IACT;AACF","sources":["packages/column-views/src/units/names.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport { useContext, useCallback } from \"react\";\nimport {\n ColumnContext,\n ColumnAxisType,\n NotesColumn,\n NotesColumnProps,\n} from \"@macrostrat/column-components\";\nimport type { ColumnDivision } from \"@macrostrat/column-components\";\nimport { IUnit, transformAxisType } from \"./types\";\nimport React from \"react\";\n\ninterface UnitDataProps extends NotesColumnProps {\n left?: number;\n transform?: string;\n noteComponent?: React.ComponentType<any>;\n shouldRenderNote?(div: ColumnDivision | IUnit, index: number): boolean;\n divisions?: IUnit[];\n minimumHeight?: number;\n}\n\ntype UnitNote = {\n height: number;\n top_height: number;\n data: IUnit;\n id: number;\n};\n\nfunction noteForDivision(\n div: IUnit,\n opts: { axisType: ColumnAxisType }\n): UnitNote {\n const { axisType } = opts;\n\n const key = transformAxisType(axisType);\n return {\n height: div[`b_${key}`],\n top_height: div[`t_${key}`],\n data: div,\n id: div.unit_id,\n };\n}\n\nconst defaultNameFunction = (div) => {\n return div.unit_name\n .replace(\"Mbr\", \"Member\")\n .replace(\"Fm\", \"Formation\")\n .replace(\"Gp\", \"Group\");\n};\n\nfunction UnitDataColumn_(props: UnitDataProps) {\n const ctx = useContext(ColumnContext);\n const {\n left,\n noteComponent,\n shouldRenderNote = (note: ColumnDivision | IUnit, i: number) => true,\n minimumHeight = 0,\n divisions = ctx?.divisions,\n ...rest\n } = props;\n\n const { scale } = ctx;\n\n const minimumHeightFilter = useCallback(\n (d) => {\n if (minimumHeight == 0) return true;\n const dy = Math.abs(scale(d.top_height) - scale(d.height));\n return dy > minimumHeight;\n },\n [scale, minimumHeight]\n );\n\n if (divisions == null) return null;\n const notes: UnitNote[] = divisions\n .filter(shouldRenderNote)\n .map((d: IUnit) => noteForDivision(d, { axisType: ctx.axisType }))\n .filter(minimumHeightFilter);\n\n return h(NotesColumn, {\n transform: `translate(${left || 0})`,\n editable: false,\n noteComponent,\n notes,\n forceOptions: {\n nodeSpacing: 1,\n },\n ...rest,\n });\n}\n\nconst UnitDataColumn = React.memo(UnitDataColumn_);\n\ninterface UnitNamesProps extends UnitDataProps {\n nameForDivision?(obj: IUnit): string;\n paddingLeft?: number;\n width: number;\n}\n\nexport function UnitNamesColumn(props: UnitNamesProps) {\n const {\n nameForDivision = defaultNameFunction,\n noteComponent,\n ...rest\n } = props;\n\n const NoteComponent = (props) => {\n const { note } = props;\n return h(\"p.col-note-label\", nameForDivision(note.data));\n };\n\n return h(UnitDataColumn, {\n noteComponent: noteComponent ?? NoteComponent,\n ...rest,\n });\n}\n\nexport type { UnitNamesProps };\nexport { defaultNameFunction, noteForDivision, UnitDataColumn };\n"],"names":[],"version":3,"file":"names.
|
|
1
|
+
{"mappings":";;;;;;;;;AA4BA,SAAS,0CACP,GAAU,EACV,IAAkC;IAElC,MAAM,YAAE,QAAQ,EAAE,GAAG;IAErB,MAAM,MAAM,CAAA,GAAA,yCAAgB,EAAE;IAC9B,OAAO;QACL,QAAQ,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC;QACvB,YAAY,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC;QAC3B,MAAM;QACN,IAAI,IAAI,OAAO;IACjB;AACF;AAEA,MAAM,4CAAsB,CAAC;IAC3B,OAAO,IAAI,SAAS,CACjB,OAAO,CAAC,OAAO,UACf,OAAO,CAAC,MAAM,aACd,OAAO,CAAC,MAAM;AACnB;AAEA,SAAS,sCAAgB,KAAoB;IAC3C,MAAM,MAAM,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,oBAAY;IACnC,MAAM,QACJ,IAAI,iBACJ,aAAa,oBACb,mBAAmB,CAAC,MAA8B,IAAc,qBAChE,gBAAgB,cAChB,YAAY,KAAK,WACjB,GAAG,MACJ,GAAG;IAEJ,MAAM,SAAE,KAAK,EAAE,GAAG;IAElB,MAAM,sBAAsB,CAAA,GAAA,kBAAU,EACpC,CAAC;QACC,IAAI,iBAAiB,GAAG,OAAO;QAC/B,MAAM,KAAK,KAAK,GAAG,CAAC,MAAM,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM;QACxD,OAAO,KAAK;IACd,GACA;QAAC;QAAO;KAAc;IAGxB,IAAI,aAAa,MAAM,OAAO;IAC9B,MAAM,QAAoB,UACvB,MAAM,CAAC,kBACP,GAAG,CAAC,CAAC,IAAa,0CAAgB,GAAG;YAAE,UAAU,IAAI,QAAQ;QAAC,IAC9D,MAAM,CAAC;IAEV,OAAO,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,kBAAU,GAAG;QACpB,WAAW,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;QACpC,UAAU;uBACV;eACA;QACA,cAAc;YACZ,aAAa;QACf;QACA,GAAG,IAAI;IACT;AACF;AAEA,MAAM,4CAAiB,CAAA,GAAA,YAAI,EAAE,IAAI,CAAC;AAQ3B,SAAS,0CAAgB,KAAqB;IACnD,MAAM,mBACJ,kBAAkB,0DAClB,aAAa,EACb,GAAG,MACJ,GAAG;IAEJ,MAAM,gBAAgB,CAAC;QACrB,MAAM,QAAE,IAAI,EAAE,GAAG;QACjB,OAAO,CAAA,GAAA,sBAAA,EAAE,oBAAoB,gBAAgB,KAAK,IAAI;IACxD;IAEA,OAAO,CAAA,GAAA,sBAAA,EAAE,2CAAgB;QACvB,eAAe,iBAAiB;QAChC,GAAG,IAAI;IACT;AACF","sources":["packages/column-views/src/units/names.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport { useContext, useCallback } from \"react\";\nimport {\n ColumnContext,\n ColumnAxisType,\n NotesColumn,\n NotesColumnProps,\n} from \"@macrostrat/column-components\";\nimport type { ColumnDivision } from \"@macrostrat/column-components\";\nimport { IUnit, transformAxisType } from \"./types\";\nimport React from \"react\";\n\ninterface UnitDataProps extends NotesColumnProps {\n left?: number;\n transform?: string;\n noteComponent?: React.ComponentType<any>;\n shouldRenderNote?(div: ColumnDivision | IUnit, index: number): boolean;\n divisions?: IUnit[];\n minimumHeight?: number;\n}\n\ntype UnitNote = {\n height: number;\n top_height: number;\n data: IUnit;\n id: number;\n};\n\nfunction noteForDivision(\n div: IUnit,\n opts: { axisType: ColumnAxisType }\n): UnitNote {\n const { axisType } = opts;\n\n const key = transformAxisType(axisType);\n return {\n height: div[`b_${key}`],\n top_height: div[`t_${key}`],\n data: div,\n id: div.unit_id,\n };\n}\n\nconst defaultNameFunction = (div) => {\n return div.unit_name\n .replace(\"Mbr\", \"Member\")\n .replace(\"Fm\", \"Formation\")\n .replace(\"Gp\", \"Group\");\n};\n\nfunction UnitDataColumn_(props: UnitDataProps) {\n const ctx = useContext(ColumnContext);\n const {\n left,\n noteComponent,\n shouldRenderNote = (note: ColumnDivision | IUnit, i: number) => true,\n minimumHeight = 0,\n divisions = ctx?.divisions,\n ...rest\n } = props;\n\n const { scale } = ctx;\n\n const minimumHeightFilter = useCallback(\n (d) => {\n if (minimumHeight == 0) return true;\n const dy = Math.abs(scale(d.top_height) - scale(d.height));\n return dy > minimumHeight;\n },\n [scale, minimumHeight]\n );\n\n if (divisions == null) return null;\n const notes: UnitNote[] = divisions\n .filter(shouldRenderNote)\n .map((d: IUnit) => noteForDivision(d, { axisType: ctx.axisType }))\n .filter(minimumHeightFilter);\n\n return h(NotesColumn, {\n transform: `translate(${left || 0})`,\n editable: false,\n noteComponent,\n notes,\n forceOptions: {\n nodeSpacing: 1,\n },\n ...rest,\n });\n}\n\nconst UnitDataColumn = React.memo(UnitDataColumn_);\n\ninterface UnitNamesProps extends UnitDataProps {\n nameForDivision?(obj: IUnit): string;\n paddingLeft?: number;\n width: number;\n}\n\nexport function UnitNamesColumn(props: UnitNamesProps) {\n const {\n nameForDivision = defaultNameFunction,\n noteComponent,\n ...rest\n } = props;\n\n const NoteComponent = (props) => {\n const { note } = props;\n return h(\"p.col-note-label\", nameForDivision(note.data));\n };\n\n return h(UnitDataColumn, {\n noteComponent: noteComponent ?? NoteComponent,\n ...rest,\n });\n}\n\nexport type { UnitNamesProps };\nexport { defaultNameFunction, noteForDivision, UnitDataColumn };\n"],"names":[],"version":3,"file":"names.f6a4e9a4.js.map"}
|