@macrostrat/column-components
Version:
React rendering primitives for stratigraphic columns
3 lines (2 loc) • 2.06 kB
JavaScript
import{useContext as t,forwardRef as e,createRef as n,Component as i}from"react";var o=globalThis,r={},s={},d=o.parcelRequire94c2;null==d&&((d=function(t){if(t in r)return r[t].exports;if(t in s){var e=s[t];delete s[t];var n={id:t,exports:{}};return r[t]=n,e.call(n.exports,n,n.exports),n.exports}var i=Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}).register=function(t,e){s[t]=e},o.parcelRequire94c2=d),d.register;var a=d("4bJ9d"),l={};l=d("daZiC").getBundleURL("j0dCO")+"layout.a0997bea.js";var h={};h=d("daZiC").getBundleURL("j0dCO")+"editor.ffa16e31.js";var u=d("7LSYr");let p=function(e){let{note:n}=e,{setEditingNote:i,editingNote:o}=t(h.NoteEditorContext),{noteComponent:r}=t(l.NoteLayoutContext),s=o===n;return(0,a.default)(r,{visibility:s?"hidden":"inherit",note:n,onClick:()=>i(n)})},c=e(function(e,n){let{note:i,offsetY:o,noteHeight:r}=e,{editingNote:s}=t(h.NoteEditorContext);return s===i?null:(0,a.default)("g.note",[(0,a.default)(u.NoteConnector,{note:i}),(0,a.default)(u.NotePositioner,{offsetY:o,noteHeight:r,ref:n},[(0,a.default)(p,{note:i})])])});class f extends i{static #t=this.contextType=l.NoteLayoutContext;constructor(t){super(t),this.updateHeight=this.updateHeight.bind(this),this.componentDidMount=this.componentDidMount.bind(this),this.componentDidUpdate=this.componentDidUpdate.bind(this),this.element=n(),this.state={height:null}}render(){let{style:t,note:e,editHandler:n,editable:i}=this.props,{scale:o,nodes:r,columnIndex:s,width:d,paddingLeft:l}=this.context,h=r[e.id],u=o(e.height);null!=h&&(u=h.currentPos);let p=this.state.height||0;return(0,a.default)(c,{offsetY:u,note:e,noteHeight:p,ref:this.element})}updateHeight(t){let e=this.element.current;if(null==e)return;let n=e.offsetHeight;if(null!=n&&(null==t||t.note!==this.props.note))return this.setState({height:n}),this.context.registerHeight(this.props.note.id,n)}componentDidMount(){return this.updateHeight.apply(this,arguments)}componentDidUpdate(){return this.updateHeight.apply(this,arguments)}}
//# sourceMappingURL=note.88f0297b.js.map