@visactor/openinula-vtable
Version:
The openinula version of VTable
64 lines (59 loc) • 2.74 kB
JavaScript
;
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
void 0 === k2 && (k2 = k);
var desc = Object.getOwnPropertyDescriptor(m, k);
desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
enumerable: !0,
get: function() {
return m[k];
}
}), Object.defineProperty(o, k2, desc);
} : function(o, m, k, k2) {
void 0 === k2 && (k2 = k), o[k2] = m[k];
}), __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function(o, v) {
Object.defineProperty(o, "default", {
enumerable: !0,
value: v
});
} : function(o, v) {
o.default = v;
}), __importStar = this && this.__importStar || function(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (null != mod) for (var k in mod) "default" !== k && Object.prototype.hasOwnProperty.call(mod, k) && __createBinding(result, mod, k);
return __setModuleDefault(result, mod), result;
}, __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;
};
Object.defineProperty(exports, "__esModule", {
value: !0
});
const openinula_1 = __importStar(require("openinula")), React = openinula_1.default;
function withContainer(Comp, name = "TableContainer", getProps) {
const Cls = openinula_1.default.forwardRef(((props, ref) => {
const container = (0, openinula_1.useRef)(), [inited, setInited] = (0, openinula_1.useState)(!1), {className: className, style: style, width: width} = props, options = __rest(props, [ "className", "style", "width" ]);
return (0, openinula_1.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;
}
exports.default = withContainer;
//# sourceMappingURL=withContainer.js.map