UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

3 lines (2 loc) 979 B
import t from"@macrostrat/hyper";import e from"classnames";import{Component as a}from"react";Object.defineProperty({},"PickerControl",{get:()=>r,set:void 0,enumerable:!0,configurable:!0});class r extends a{constructor(t){super(t),this.onUpdate=this.onUpdate.bind(this)}static #t=this.defaultProps={states:[{label:"State 1",value:"state1"},{label:"State 2",value:"state2"}],vertical:!0,isNullable:!1};render(){let{states:a,activeState:r,vertical:s}=this.props,o=e("bp5-button-group","bp5-fill",{"bp5-vertical":s,"bp5-align-left":s});return t("div.picker-control",[t("div",{className:o},a.map(a=>t("button",{type:"button",className:o=e("bp5-button",{"bp5-active":this.props.activeState===a.value}),onClick:this.onUpdate(a.value)},a.label)))])}onUpdate(t){return()=>{if(t===this.props.activeState){if(!this.props.isNullable)return;t=null}if(null!=this.props.onUpdate)return this.props.onUpdate(t)}}}export{r as PickerControl}; //# sourceMappingURL=column-components.f332569f.js.map