@macrostrat/column-components
Version:
React rendering primitives for stratigraphic columns
3 lines (2 loc) • 2.76 kB
JavaScript
import"./column-components.b2a20dc1.js";import"./column-components.e7f1a130.js";import{Component as e,createContext as t,useRef as r,useContext as n,createElement as i}from"react";import l from"@macrostrat/hyper";import{path as o}from"d3-path";var a=globalThis,s={},f={},c=a.parcelRequirea149;null==c&&((c=function(e){if(e in s)return s[e].exports;if(e in f){var t=f[e];delete f[e];var r={id:e,exports:{}};return s[e]=r,t.call(r.exports,r,r.exports),r.exports}var n=Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}).register=function(e,t){f[e]=t},a.parcelRequirea149=c),c.register;var u=c("aVUB5"),d=c("fwzVu");let m=0;function p(){let e=`uuid-${m}`;return m+=1,e}class h extends e{constructor(e){super(e),this.UUID=p()}}let $=t(null),b=function(){let e=n($);return null==e?r(p()).current:e};function g({children:e}){let t=r(p());return l($.Provider,{value:t.current,children:e})}function x(e){let{pixelHeight:t,width:r}=n(u.ColumnLayoutContext),{id:i,className:o}=e;return i.startsWith("#")&&(i=i.slice(1)),l("rect",{id:i,x:0,y:0,width:r,height:t,className:o})}function C(e){let{id:t,zigZagBottom:r=!1,zigZagTop:n=!1}=e,{scale:i,divisions:a,grainsizeScale:s}=(0,u.useColumnLayout)();if(t.startsWith("#")&&(t=t.slice(1)),0===a.length)return null;let[f,c]=i.domain(),m=function(e){let{top:t}=e;return t>c&&(t=c),i(t)},p=function(e){let{bottom:t}=e;return t<f&&(t=f),i(t)},h=Array.from(a).filter(function(e){return!(e.top<=f)&&!(e.bottom>c)}),$=o(),b="m",g=0;for(let e of h){if(0===g){let t=p(e);$.moveTo(0,t)}null!=e.grainsize&&(b=e.grainsize);let t=s(b);0===g&&r?(0,d.drawZigZagAtConstantHeight)($,0,t,p(e)):$.lineTo(t,p(e)),$.lineTo(t,p(e)),$.lineTo(t,m(e)),g===h.length-1&&(n?(0,d.drawZigZagAtConstantHeight)($,t,0,m(e)):$.lineTo(0,m(e))),g++}return $.closePath(),l("path",{id:t,key:t,d:$.toString()})}let U=function(e){let{id:t,children:r,...n}=e;return t.startsWith("#")&&(t=t.slice(1)),i("clipPath",{id:t,key:t,...n},r)},v=function(e){let{id:t,...r}=e;return l("use.frame",{xlinkHref:t,fill:"transparent",key:"frame",...r})},y=function(e,t){let r={};for(let n of Array.from(t))r[n+"ID"]=`#${e}-${n}`;return r};function D(e){let{left:t=0,shiftY:r=0,className:n,onClick:i,children:o,frame:a=x,clip:s=!0}=e,{frameID:f,clipID:c}=y(b(),["frame","clip"]),u=null;null!=t&&(u=`translate(${t} ${r})`);let d="clip-frame column-clip-frame",m=l(a,{id:f,className:d}),p=null,h=null;return s&&(p=l("defs",{key:"defs"},[m,l(U,{id:c},l(v,{id:f}))]),h=`url(${c})`,m=l(v,{id:f,className:d})),l("g",{className:n,transform:u,onClick:i},[p,l("g.inner",{clipPath:h},o),m])}export{h as UUIDComponent,b as useUUID,g as UUIDProvider,x as SimpleFrame,C as GrainsizeFrame,U as ClipPath,D as ClippingFrame};
//# sourceMappingURL=column-components.218afc30.js.map