UNPKG

@visactor/openinula-vtable

Version:

The openinula version of VTable

35 lines (32 loc) 1.56 kB
var __rest = this && this.__rest || function(s, e) { var t = {}; for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]); if (null != s && "function" == typeof Object.getOwnPropertySymbols) { var i = 0; for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]); } return t; }; import Inula, { useRef, useState, useLayoutEffect } from "openinula"; const React = Inula; export default function withContainer(Comp, name = "TableContainer", getProps) { const Cls = Inula.forwardRef(((props, ref) => { const container = useRef(), [inited, setInited] = useState(!1), {className: className, style: style, width: width} = props, options = __rest(props, [ "className", "style", "width" ]); return useLayoutEffect((() => { setInited(!0); }), []), React.createElement("div", { ref: container, className: className, style: Object.assign({ position: "relative", height: props.height || "100%", width: props.width || "100%" }, style) }, inited ? React.createElement(Comp, Object.assign({ ref: ref, container: container.current }, getProps ? getProps(options) : options)) : React.createElement(React.Fragment, null)); })); return Cls.displayName = name || Comp.name, Cls; } //# sourceMappingURL=withContainer.js.map