UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

78 lines (77 loc) 2.29 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const h = require("@macrostrat/hyper"); const React = require("react"); const uiComponents = require("@macrostrat/ui-components"); const classNames = require("classnames"); const column = require("../context/column.cjs"); const _interopDefault = (e) => e && e.__esModule ? e : { default: e }; const h__default = /* @__PURE__ */ _interopDefault(h); const classNames__default = /* @__PURE__ */ _interopDefault(classNames); const SVGNamespaces = { xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink" }; const SVG = React.forwardRef( (props, ref) => { const { children, innerRef, ...props1 } = props; const { style, ...rest } = uiComponents.expandInnerSize(props1); const { paddingLeft, paddingTop } = uiComponents.extractPadding(props); const margin = uiComponents.extractMargin(props); const realRest = uiComponents.removeMargin(uiComponents.removePadding(rest)); return h__default.default( "svg", { ref, style: { ...margin, ...style }, ...realRest, ...SVGNamespaces }, h__default.default( "g", { transform: `translate(${paddingLeft},${paddingTop})` }, children ) ); } ); const ForeignObject = (props) => React.createElement("foreignObject", props); const ColumnSVG = function(props) { const { children, className, innerRef, style, ...rest } = props; const { pixelHeight } = column.useColumn(); const nextProps = uiComponents.expandInnerSize({ innerHeight: pixelHeight, ...rest }); const { paddingLeft, paddingTop, innerHeight, innerWidth, height, width, ...remainingProps } = nextProps; return h__default.default( SVG, { className: classNames__default.default(className, "section"), height, width, innerRef, ...remainingProps, style }, h__default.default( "g.backdrop", { transform: `translate(${paddingLeft},${paddingTop})` }, children ) ); }; exports.ColumnSVG = ColumnSVG; exports.ForeignObject = ForeignObject; exports.SVG = SVG; exports.SVGNamespaces = SVGNamespaces; //# sourceMappingURL=index.cjs.map