UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

71 lines (65 loc) 2.33 kB
import $jLAV7$macrostrathyper from "@macrostrat/hyper"; import $jLAV7$classnames from "classnames"; import {Component as $jLAV7$Component} from "react"; /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns * DS206: Consider reworking classes to avoid initClass * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ class $1c0e7fb0f1cf36ed$export$e587c41f8a2e48c5 extends (0, $jLAV7$Component) { constructor(props){ super(props); this.onUpdate = this.onUpdate.bind(this); } static{ this.defaultProps = { states: [ { label: "State 1", value: "state1" }, { label: "State 2", value: "state2" } ], vertical: true, isNullable: false }; } render() { const { states: states, activeState: activeState, vertical: vertical } = this.props; let className = (0, $jLAV7$classnames)("bp5-button-group", "bp5-fill", { "bp5-vertical": vertical, "bp5-align-left": vertical }); return (0, $jLAV7$macrostrathyper)("div.picker-control", [ (0, $jLAV7$macrostrathyper)("div", { className: className }, states.map((d)=>{ className = (0, $jLAV7$classnames)("bp5-button", { "bp5-active": this.props.activeState === d.value }); return (0, $jLAV7$macrostrathyper)("button", { type: "button", className: className, onClick: this.onUpdate(d.value) }, d.label); })) ]); } onUpdate(value) { return ()=>{ if (value === this.props.activeState) { if (!this.props.isNullable) return; value = null; } if (this.props.onUpdate == null) return; return this.props.onUpdate(value); }; } } export {$1c0e7fb0f1cf36ed$export$e587c41f8a2e48c5 as PickerControl}; //# sourceMappingURL=column-components.52f88505.js.map