UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

129 lines (117 loc) 5.1 kB
import {RaisedSelect as $741ee768ea1c82a7$export$ee7a0846eb965877} from "./column-components.52669521.js"; import {GeologicPatternContext as $77hts$GeologicPatternContext, symbolIndex as $0508e0a480a27a2d$export$c6d9e109da1a726e} from "./column-components.0e408d58.js"; import {LithologyContext as $77hts$LithologyContext} from "./column-components.fa405a9f.js"; import $77hts$columncomponents44a49d18js from "./column-components.44a49d18.js"; import "./column-components.92b8a25a.css"; import {useContext as $77hts$useContext, useState as $77hts$useState} from "react"; import $77hts$macrostrathyper from "@macrostrat/hyper"; import {Button as $77hts$Button, Intent as $77hts$Intent} from "@blueprintjs/core"; function $parcel$interopDefault(a) { return a && a.__esModule ? a.default : a; } const $4ea89d238878baf5$var$h = (0, $77hts$macrostrathyper).styled((0, ($parcel$interopDefault($77hts$columncomponents44a49d18js)))); const $4ea89d238878baf5$var$LithologySwatch = function({ symbolID: symbolID, style: style, ...rest }) { const { resolvePattern: resolvePattern } = (0, $77hts$useContext)((0, $77hts$GeologicPatternContext)); const src = resolvePattern(symbolID); if (style == null) style = {}; style.backgroundImage = `url(\"${src}\")`; return $4ea89d238878baf5$var$h("div.lithology-swatch", { style: style, ...rest }); }; const $4ea89d238878baf5$var$LithologyItem = function(props) { const { symbol: symbol, lithology: lithology } = props; return $4ea89d238878baf5$var$h("span.facies-picker-row", [ $4ea89d238878baf5$var$h($4ea89d238878baf5$var$LithologySwatch, { symbolID: symbol }), $4ea89d238878baf5$var$h("span.facies-picker-name", lithology) ]); }; const $4ea89d238878baf5$export$a685fa91ddfa1b86 = (props)=>{ const { interval: interval, onChange: onChange } = props; const { lithologies: lithologies } = (0, $77hts$useContext)((0, $77hts$LithologyContext)); console.log("lithologies", lithologies, interval); let options = []; for (let item of lithologies){ const { id: id, pattern: pattern } = item; const symbol = (0, $0508e0a480a27a2d$export$c6d9e109da1a726e)[pattern]; // if (symbol == null) { // continue; // } options.push({ value: id, label: $4ea89d238878baf5$var$h($4ea89d238878baf5$var$LithologyItem, { lithology: id, symbol: symbol }) }); } let value = options.find((d)=>d.value === interval.lithology_id); return $4ea89d238878baf5$var$h((0, $741ee768ea1c82a7$export$ee7a0846eb965877), { id: "lithology-select", options: options, value: value, isClearable: true, onChange (res) { const f = res != null ? res.value : null; return onChange(f); } }); }; const $4ea89d238878baf5$var$SymbolPickerInner = function(props) { let symbol; const { interval: interval, onClose: onClose, style: style } = props; let isUserSet = false; let text = "No pattern set"; if (interval.pattern != null) { symbol = interval.pattern; isUserSet = true; text = `Symbol ${symbol}`; } if (interval.lithology != null) { symbol = (0, $0508e0a480a27a2d$export$c6d9e109da1a726e)[interval.lithology]; text = "Default for lithology"; } return $4ea89d238878baf5$var$h("div.lithology-symbol-picker-inner", { style: style }, [ $4ea89d238878baf5$var$h.if(symbol != null)($4ea89d238878baf5$var$LithologySwatch, { symbolID: symbol }), $4ea89d238878baf5$var$h("div.picker-label.text", text), $4ea89d238878baf5$var$h.if(onClose != null)((0, $77hts$Button), { small: true, icon: "cross", intent: (0, $77hts$Intent).DANGER, minimal: true, onClick: onClose }, "Clear override") ]); }; const $4ea89d238878baf5$export$e882965600ccf2f4 = function(props) { const { interval: interval, updatePattern: updatePattern } = props; const [isExpanded, setIsExpanded] = (0, $77hts$useState)(false); const className = isExpanded ? "expanded" : "hidden"; return $4ea89d238878baf5$var$h("div.lithology-symbol-picker", { className: className }, [ $4ea89d238878baf5$var$h((0, $77hts$Button), { className: "expand-button", onClick () { setIsExpanded(true); }, minimal: true, small: true, intent: (0, $77hts$Intent).WARNING }, "Override lithology pattern"), $4ea89d238878baf5$var$h($4ea89d238878baf5$var$SymbolPickerInner, { interval: interval, onClose: ()=>setIsExpanded(false), updatePattern: updatePattern }) ]); }; export {$4ea89d238878baf5$export$a685fa91ddfa1b86 as LithologyPicker, $4ea89d238878baf5$export$e882965600ccf2f4 as LithologySymbolPicker}; //# sourceMappingURL=column-components.42b1dd6c.js.map