@macrostrat/column-components
Version:
React rendering primitives for stratigraphic columns
302 lines (290 loc) • 13.5 kB
JavaScript
import {ClippingFrame as $78cda86e161567e8$export$708d3f2ecf132c6c, GrainsizeFrame as $78cda86e161567e8$export$686c342f9382ceb9, SimpleFrame as $78cda86e161567e8$export$5e9808bef3bd64be, UUIDComponent as $78cda86e161567e8$export$748c8bb116429550} from "./column-components.e19a4b4d.js";
import {ColumnContext as $dGVJT$ColumnContext, ColumnLayoutContext as $dGVJT$ColumnLayoutContext, ColumnLayoutProvider as $dGVJT$ColumnLayoutProvider, FaciesContext as $dGVJT$FaciesContext} from "./column-components.fa405a9f.js";
import {GeologicPattern as $de566d6021709f60$export$9e9c2df1189db669, GeologicPatternContext as $de566d6021709f60$export$f8a3ff1b6bcec62, GeologicPatternProvider as $de566d6021709f60$export$2926ceaa6d8d8b07, PatternType as $de566d6021709f60$export$3d750f4e9f4d0fc8} from "./column-components.944fb3f5.js";
import {PatternDefsProvider as $c6b2352da1928794$export$2162bbed7004f389, useGeologicPattern as $c6b2352da1928794$export$85aacc253e576bcf} from "./column-components.725513d9.js";
import {useContext as $dGVJT$useContext} from "react";
import $dGVJT$macrostrathyper from "@macrostrat/hyper";
import $dGVJT$classnames from "classnames";
import $dGVJT$reactsvgtextures from "react-svg-textures";
const $0508e0a480a27a2d$var$Lines = (0, $dGVJT$reactsvgtextures).Lines;
const $0508e0a480a27a2d$export$c6d9e109da1a726e = {
"dolomite-limestone": 641,
lime_mudstone: 627,
sandstone: 607,
siltstone: 616,
"dolomitic siltstone": 616,
shale: 620,
limestone: 627,
dolomite: 642,
conglomerate: 602,
"dolomite-mudstone": 642,
mudstone: 620,
"sandy-dolomite": 645,
quartzite: 702
};
const $0508e0a480a27a2d$var$isCarbonateSymbol = function(d) {
/*
Does this FGDC pattern correspond to a carbonate rock?
*/ if (d < 627) return false;
if (d > 648) return false;
return true;
};
const $0508e0a480a27a2d$export$fa3dcfced41a86d7 = function(d) {
// Changed pattern to lithology
if (d == null) return null;
const pat = d.fgdc_pattern ?? $0508e0a480a27a2d$export$c6d9e109da1a726e[d.pattern] ?? d.pattern;
if (pat == null) return null;
return `${pat}`;
};
const $0508e0a480a27a2d$var$carbonateResolveID = function(d) {
// Just whether a carbonate or not
const v = $0508e0a480a27a2d$export$fa3dcfced41a86d7(d);
if (v == null) return v;
if ($0508e0a480a27a2d$var$isCarbonateSymbol(v)) return 627;
else return -1;
};
const $0508e0a480a27a2d$var$__divisionSize = function(d) {
let { bottom: bottom, top: top } = d;
if (top < bottom) [top, bottom] = [
bottom,
top
];
return [
bottom,
top
];
};
function $0508e0a480a27a2d$export$bd00a5f0bbdae1c6(props) {
let { division: d, padWidth: padWidth = false, key: key, width: width, ...rest } = props;
const scale = (0, $dGVJT$useContext)((0, $dGVJT$ColumnContext)).scale;
const [bottom, top] = $0508e0a480a27a2d$var$__divisionSize(d);
const y = scale(top);
let x = 0;
if (padWidth) {
x -= 5;
width += 10;
}
const height = scale(bottom) - y;
if (key == null) key = d.id;
return (0, $dGVJT$macrostrathyper)("rect", {
x: x,
y: y,
width: width,
height: height,
key: key,
...rest
});
}
const $0508e0a480a27a2d$export$4467ea85d9c25b6a = function(divisions, key) {
const __ = [
{
...divisions[0]
}
];
for (let d of Array.from(divisions)){
const ix = __.length - 1;
const shouldSkip = d[key] == null || d[key] === __[ix][key];
if (shouldSkip) __[ix].top = d.top;
else __.push({
...d
});
}
return __;
};
function $0508e0a480a27a2d$export$3562b58415e0fc33(props) {
const { divisions: divisions, width: width } = (0, $dGVJT$useContext)((0, $dGVJT$ColumnLayoutContext));
const { padWidth: padWidth, parameter: key, fillForInterval: fillForInterval } = props;
const newDivisions = $0508e0a480a27a2d$export$4467ea85d9c25b6a(divisions, key);
if (newDivisions.length === 1) return null;
return (0, $dGVJT$macrostrathyper)("g", {
className: key
}, newDivisions.map((div)=>(0, $dGVJT$macrostrathyper)($0508e0a480a27a2d$export$bd00a5f0bbdae1c6, {
className: (0, $dGVJT$classnames)(key, div.id),
division: div,
padWidth: padWidth,
fill: fillForInterval(div[key], div),
width: width
})));
}
const $0508e0a480a27a2d$export$dce262ef2f9848fe = function(props) {
const { getFaciesColor: getFaciesColor } = (0, $dGVJT$useContext)((0, $dGVJT$FaciesContext));
return (0, $dGVJT$macrostrathyper)($0508e0a480a27a2d$export$3562b58415e0fc33, {
parameter: "facies",
fillForInterval (param, division) {
const { facies: facies, facies_color: facies_color } = division;
return getFaciesColor(facies) || facies_color;
},
...props
});
};
const $0508e0a480a27a2d$export$31f11f8940a4f84f = $0508e0a480a27a2d$export$dce262ef2f9848fe;
class $0508e0a480a27a2d$export$4bda6a249c917193 extends (0, $78cda86e161567e8$export$748c8bb116429550) {
static{
this.contextType = (0, $dGVJT$ColumnLayoutContext);
}
render() {
const { divisions: divisions, width: width } = this.context;
const fill = `url(#${this.UUID}-covered)`;
const coveredDivs = divisions.filter((d)=>d.covered);
return (0, $dGVJT$macrostrathyper)("g.covered-overlay", {}, [
(0, $dGVJT$macrostrathyper)("defs", [
(0, $dGVJT$macrostrathyper)($0508e0a480a27a2d$var$Lines, {
id: `${this.UUID}-covered`,
size: 9,
strokeWidth: 3,
stroke: "rgba(0,0,0,0.5)"
})
]),
(0, $dGVJT$macrostrathyper)("g.main", coveredDivs.map((d)=>{
return (0, $dGVJT$macrostrathyper)($0508e0a480a27a2d$export$bd00a5f0bbdae1c6, {
division: d,
width: width,
fill: fill
});
}))
]);
}
}
const $0508e0a480a27a2d$export$32b4d00c1c066ab2 = function(props) {
let { resolveID: resolveID, divisions: divisions, UUID: UUID, scalePattern: scalePattern } = props;
if (scalePattern == null) scalePattern = ()=>1;
if (divisions == null) ({ divisions: divisions } = (0, $dGVJT$useContext)((0, $dGVJT$ColumnContext)));
const __ = divisions.map((d)=>resolveID(d)).filter((x, i, arr)=>arr.indexOf(x) === i);
return (0, $dGVJT$macrostrathyper)("defs", __.map(function(id, i) {
if (id === -1) return null;
let sz = 100;
if (scalePattern != null) {
const scalar = scalePattern(id);
sz *= scalar;
}
return (0, $dGVJT$macrostrathyper)((0, $de566d6021709f60$export$9e9c2df1189db669), {
key: i,
prefix: UUID,
id: id,
width: sz,
height: sz
});
}));
};
class $0508e0a480a27a2d$export$82967efe79c38663 extends (0, $78cda86e161567e8$export$748c8bb116429550) {
static{
this.contextType = (0, $dGVJT$ColumnLayoutContext);
}
static{
this.defaultProps = {
resolveID: $0508e0a480a27a2d$export$fa3dcfced41a86d7,
minimumHeight: 0
};
}
constructor(props){
super(props);
this.constructLithologyDivisions = this.constructLithologyDivisions.bind(this);
this.renderEach = this.renderEach.bind(this);
}
constructLithologyDivisions() {
let d, patternID;
const { divisions: divisions } = this.context;
const { resolveID: resolveID, minimumHeight: minimumHeight } = this.props;
const __ = [];
for (d of Array.from(divisions)){
const ix = __.length - 1;
patternID = resolveID(d);
if (ix === -1) {
__.push({
...d,
patternID: patternID
});
continue;
}
const sameAsLast = patternID === resolveID(__[ix]);
const shouldSkip = patternID == null || sameAsLast;
if (shouldSkip) __[ix].top = d.top;
else __.push({
...d,
patternID: patternID
});
}
// Allow removing of items by minimum height
if (minimumHeight > 0) {
const nextVals = [];
for(let i = 0; i < __.length; i++){
d = __[i];
const heightTooSmall = d.top - d.bottom < minimumHeight;
if (heightTooSmall && __[i + 1] != null) {
var name;
__[i + 1].bottom = d.bottom;
if (__[name = i + 1].patternID == null) __[name].patternID = resolveID(d);
} else nextVals.push(d);
}
return nextVals;
}
return __;
}
renderEach(d) {
const { width: width } = this.context;
const className = (0, $dGVJT$classnames)({
definite: d.definite_boundary,
covered: d.covered
}, "lithology");
let fill = `url(#${this.UUID}-${d.patternID})`;
if (d.patternID === -1) fill = "transparent";
return (0, $dGVJT$macrostrathyper)($0508e0a480a27a2d$export$bd00a5f0bbdae1c6, {
width: width,
division: d,
className: className,
fill: fill
});
}
render() {
const divisions = this.constructLithologyDivisions();
const { resolveID: resolveID } = this.props;
return (0, $dGVJT$macrostrathyper)("g.lithology", [
(0, $dGVJT$macrostrathyper)($0508e0a480a27a2d$export$32b4d00c1c066ab2, {
divisions: divisions,
resolveID: resolveID,
UUID: this.UUID
}),
(0, $dGVJT$macrostrathyper)("g", divisions.map(this.renderEach))
]);
}
}
const $0508e0a480a27a2d$export$c3fb128eae742d73 = $0508e0a480a27a2d$export$82967efe79c38663;
function $0508e0a480a27a2d$export$dad64b06365c0af9(props) {
const { left: left = 0, shiftY: shiftY = 0, width: width, children: children, clipToFrame: clipToFrame = true } = props;
return (0, $dGVJT$macrostrathyper)((0, $dGVJT$ColumnLayoutProvider), {
width: width
}, (0, $dGVJT$macrostrathyper)((0, $78cda86e161567e8$export$708d3f2ecf132c6c), {
className: "lithology-column",
left: left,
shiftY: shiftY,
frame: (0, $78cda86e161567e8$export$5e9808bef3bd64be),
clip: clipToFrame
}, children));
}
const $0508e0a480a27a2d$var$simplifiedResolveID = function(d) {
const p = $0508e0a480a27a2d$export$c6d9e109da1a726e[d.fill_pattern];
if (p != null) return p;
const fp = d.fill_pattern;
// Special case for shales since we probably want to emphasize lithology
if (parseInt(fp) === 624) return $0508e0a480a27a2d$export$fa3dcfced41a86d7(d);
else return fp;
};
const $0508e0a480a27a2d$export$2d6d4af5ce24705c = (props)=>(0, $dGVJT$macrostrathyper)($0508e0a480a27a2d$export$c3fb128eae742d73, {
resolveID: $0508e0a480a27a2d$var$simplifiedResolveID,
...props
});
const $0508e0a480a27a2d$export$1d4e21d441ba0238 = function(props) {
let { children: children, frame: frame, ...rest } = props;
if (frame == null) frame = (0, $78cda86e161567e8$export$686c342f9382ceb9);
return (0, $dGVJT$macrostrathyper)((0, $78cda86e161567e8$export$708d3f2ecf132c6c), {
className: "lithology-column",
frame: frame,
...rest
}, children);
};
const $0508e0a480a27a2d$export$dbe74d60a4075ab1 = (props)=>(0, $dGVJT$macrostrathyper)($0508e0a480a27a2d$export$c3fb128eae742d73, {
resolveID: $0508e0a480a27a2d$var$carbonateResolveID,
...props
});
export {$0508e0a480a27a2d$export$c6d9e109da1a726e as symbolIndex, $0508e0a480a27a2d$export$fa3dcfced41a86d7 as defaultResolveID, $0508e0a480a27a2d$export$bd00a5f0bbdae1c6 as ColumnRect, $0508e0a480a27a2d$export$4467ea85d9c25b6a as expandDivisionsByKey, $0508e0a480a27a2d$export$3562b58415e0fc33 as ParameterIntervals, $0508e0a480a27a2d$export$dce262ef2f9848fe as FaciesIntervals, $0508e0a480a27a2d$export$31f11f8940a4f84f as FaciesColumnInner, $0508e0a480a27a2d$export$4bda6a249c917193 as CoveredOverlay, $0508e0a480a27a2d$export$32b4d00c1c066ab2 as LithologySymbolDefs, $0508e0a480a27a2d$export$82967efe79c38663 as LithologyBoxes, $0508e0a480a27a2d$export$c3fb128eae742d73 as LithologyColumnInner, $0508e0a480a27a2d$export$dad64b06365c0af9 as LithologyColumn, $0508e0a480a27a2d$export$2d6d4af5ce24705c as SimplifiedLithologyColumn, $0508e0a480a27a2d$export$1d4e21d441ba0238 as GeneralizedSectionColumn, $0508e0a480a27a2d$export$dbe74d60a4075ab1 as CarbonateDivisions, $78cda86e161567e8$export$5e9808bef3bd64be as SimpleFrame, $78cda86e161567e8$export$686c342f9382ceb9 as GrainsizeFrame, $de566d6021709f60$export$f8a3ff1b6bcec62 as GeologicPatternContext, $de566d6021709f60$export$2926ceaa6d8d8b07 as GeologicPatternProvider, $de566d6021709f60$export$3d750f4e9f4d0fc8 as PatternType, $de566d6021709f60$export$9e9c2df1189db669 as GeologicPattern, $c6b2352da1928794$export$2162bbed7004f389 as PatternDefsProvider, $c6b2352da1928794$export$85aacc253e576bcf as useGeologicPattern};
//# sourceMappingURL=column-components.0e408d58.js.map