UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

63 lines (54 loc) 3.02 kB
import $f5b828bbb980a05d$export$2e2bcd8739ae039 from "./column-components.de2f942b.js"; import {NoteLayoutContext as $00c4b971e86fe1d8$export$20c7bffdb69233c9} from "./column-components.fea107a9.js"; import {HeightRangeAnnotation as $dfac63f354e170ff$export$664019b81938583} from "./column-components.ccf8b5bf.js"; import {ForeignObject as $039e0fecf5651a2f$export$86f236f5872f181} from "./column-components.b2db531d.js"; import {forwardRef as $i0jeQ$forwardRef, useContext as $i0jeQ$useContext} from "react"; const $dd4ef284e468ce5f$export$ae56508882661985 = (0, $i0jeQ$forwardRef)(function(props, ref) { let { offsetY: offsetY, noteHeight: noteHeight, onClick: onClick, children: children } = props; const { width: width, paddingLeft: paddingLeft } = (0, $i0jeQ$useContext)((0, $00c4b971e86fe1d8$export$20c7bffdb69233c9)); if (noteHeight == null) noteHeight = 0; const outerPad = 5; let y = offsetY - noteHeight / 2 - outerPad; return (0, $f5b828bbb980a05d$export$2e2bcd8739ae039)((0, $039e0fecf5651a2f$export$86f236f5872f181), { width: width - paddingLeft + 2 * outerPad, x: paddingLeft - outerPad, y: y, height: noteHeight + 2 * outerPad, overflow: "visible", style: { overflowY: "visible" } }, [ (0, $f5b828bbb980a05d$export$2e2bcd8739ae039)("div.note-inner", { ref: ref, onClick: onClick }, children) ]); }); const $dd4ef284e468ce5f$var$findIndex = function(note) { const { notes: notes } = (0, $i0jeQ$useContext)((0, $00c4b971e86fe1d8$export$20c7bffdb69233c9)); return notes.indexOf(note); }; const $dd4ef284e468ce5f$export$a05ee380fe56e446 = function(props) { let { note: note, node: node, deltaConnectorAttachment: deltaConnectorAttachment, index: index } = props; // Try to avoid scanning for index if we can if (index == null) index = $dd4ef284e468ce5f$var$findIndex(note); const { nodes: nodes, columnIndex: columnIndex, generatePath: generatePath } = (0, $i0jeQ$useContext)((0, $00c4b971e86fe1d8$export$20c7bffdb69233c9)); const { height: height, top_height: top_height } = note; if (node == null) node = nodes[note.id]; if (node != null && deltaConnectorAttachment != null) node.currentPos += deltaConnectorAttachment; const offsetX = (columnIndex[index] || 0) * 5; return (0, $f5b828bbb980a05d$export$2e2bcd8739ae039)([ (0, $f5b828bbb980a05d$export$2e2bcd8739ae039)((0, $dfac63f354e170ff$export$664019b81938583), { offsetX: offsetX, height: height, top_height: top_height }), (0, $f5b828bbb980a05d$export$2e2bcd8739ae039)("path.link.col-note-link", { d: generatePath(node, offsetX), transform: `translate(${offsetX})` }) ]); }; export {$dd4ef284e468ce5f$export$ae56508882661985 as NotePositioner, $dd4ef284e468ce5f$export$a05ee380fe56e446 as NoteConnector}; //# sourceMappingURL=column-components.97c1913a.js.map