UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

140 lines (116 loc) 4.59 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectSpread from "@babel/runtime/helpers/objectSpread2"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _inherits from "@babel/runtime/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; function _createSuper(Derived) { function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } return function () { var Super = _getPrototypeOf(Derived), result; if (isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } // @ts-nocheck import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { defaultClassPrefix, getUnhandledProps, prefix } from './utils'; import TableContext from './TableContext'; var propTypes = { fixed: PropTypes.oneOf(['left', 'right']), width: PropTypes.number, height: PropTypes.number, left: PropTypes.number, style: PropTypes.object, className: PropTypes.string, classPrefix: PropTypes.string, rowDraggable: PropTypes.bool, snapshot: PropTypes.object, provided: PropTypes.object }; var CellGroup = /*#__PURE__*/ function (_React$PureComponent) { _inherits(CellGroup, _React$PureComponent); var _super = _createSuper(CellGroup); function CellGroup() { var _this; _classCallCheck(this, CellGroup); _this = _super.apply(this, arguments); _this.addPrefix = function (name) { return prefix(_this.props.classPrefix)(name); }; return _this; } _createClass(CellGroup, [{ key: "render", value: function render() { var _classNames; var _this$props = this.props, fixed = _this$props.fixed, width = _this$props.width, left = _this$props.left, height = _this$props.height, style = _this$props.style, classPrefix = _this$props.classPrefix, className = _this$props.className, children = _this$props.children, rowDraggable = _this$props.rowDraggable, provided = _this$props.provided, snapshot = _this$props.snapshot, rest = _objectWithoutProperties(_this$props, ["fixed", "width", "left", "height", "style", "classPrefix", "className", "children", "rowDraggable", "provided", "snapshot"]); var classes = classNames(classPrefix, className, (_classNames = {}, _defineProperty(_classNames, this.addPrefix("fixed-".concat(fixed || '')), fixed), _defineProperty(_classNames, this.addPrefix('scroll'), !fixed), _classNames)); var styles = _objectSpread({ width: width, height: height }, style); var unhandledProps = getUnhandledProps(propTypes, rest); var childArr = []; if (rowDraggable) { React.Children.forEach(children, function (child) { childArr.push(React.cloneElement(child, { provided: provided, isDragging: snapshot ? snapshot.isDragging : false })); }); } var cloneChildren = rowDraggable ? childArr : children; return React.createElement(TableContext.Consumer, null, function (_ref) { var translateDOMPositionXY = _ref.translateDOMPositionXY; translateDOMPositionXY === null || translateDOMPositionXY === void 0 ? void 0 : translateDOMPositionXY(styles, left, 0); return React.createElement("div", _extends({}, unhandledProps, { className: classes, style: styles }), cloneChildren); }); } }]); return CellGroup; }(React.PureComponent); CellGroup.propTypes = propTypes; CellGroup.defaultProps = { classPrefix: defaultClassPrefix('performance-table-cell-group') }; export default CellGroup; //# sourceMappingURL=CellGroup.js.map