linkmore-design
Version:
🌈 🚀lm组件库。🚀
45 lines • 1.66 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["dataSource", "onResize", "width", "dataIndex", "onResizeStop"];
import React from 'react';
import { Resizable } from 'react-resizable';
/** 排序的表头 */
var ResizableHeight = function ResizableHeight(props) {
var dataSource = props.dataSource,
_props$onResize = props.onResize,
onResize = _props$onResize === void 0 ? function () {} : _props$onResize,
width = props.width,
dataIndex = props.dataIndex,
onResizeStop = props.onResizeStop,
restProps = _objectWithoutProperties(props, _excluded);
var style = (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) === 0 ? {
width: "".concat(width, "px"),
position: 'relative',
left: 'auto',
right: 'auto'
} : {};
if (!width) {
return /*#__PURE__*/React.createElement("th", restProps);
}
return /*#__PURE__*/React.createElement(Resizable, {
width: width,
height: 0,
handle: /*#__PURE__*/React.createElement("span", {
className: "react-resizable-handle",
onClick: function onClick(e) {
e.stopPropagation();
}
}),
axis: "x",
minConstraints: [10, 10],
onResize: onResize,
onResizeStop: onResizeStop,
draggableOpts: {
enableUserSelectHack: false
}
}, /*#__PURE__*/React.createElement("th", _extends({}, restProps, {
style: _objectSpread(_objectSpread({}, restProps.style), style)
})));
};
export default ResizableHeight;