UNPKG

@atlaskit/renderer

Version:
90 lines (89 loc) 4.56 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _react = _interopRequireDefault(require("react")); var _utils = require("@atlaskit/editor-common/utils"); var _types = require("@atlaskit/editor-common/types"); var _consts = require("../../consts"); function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } // Ignored via go/ees005 // eslint-disable-next-line @repo/internal/react/no-class-components var TableRow = exports.default = /*#__PURE__*/function (_React$Component) { function TableRow() { var _this; (0, _classCallCheck2.default)(this, TableRow); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _callSuper(this, TableRow, [].concat(args)); (0, _defineProperty2.default)(_this, "state", { colGroupWidths: [] }); (0, _defineProperty2.default)(_this, "addSortableColumn", function (childrenArray) { var _this$props = _this.props, allowColumnSorting = _this$props.allowColumnSorting, rowIndex = _this$props.index; var isHeaderRow = !rowIndex; if (allowColumnSorting && isHeaderRow) { childrenArray = childrenArray.map(function (child, index) { if ( /*#__PURE__*/_react.default.isValidElement(child)) { var tableOrderStatus = _this.props.tableOrderStatus; var sortOrdered = _types.SortOrder.NO_ORDER; if (tableOrderStatus) { sortOrdered = index === tableOrderStatus.columnIndex ? tableOrderStatus.order : _types.SortOrder.NO_ORDER; } return /*#__PURE__*/_react.default.cloneElement(child, { columnIndex: index, onSorting: _this.props.onSorting, sortOrdered: sortOrdered, isHeaderRow: isHeaderRow }); } }); } return childrenArray; }); (0, _defineProperty2.default)(_this, "addColGroupWidth", function (childrenArray) { var _this$state$colGroupW; if ((_this$state$colGroupW = _this.state.colGroupWidths) !== null && _this$state$colGroupW !== void 0 && _this$state$colGroupW.length) { childrenArray = childrenArray.map(function (child, index) { if ( /*#__PURE__*/_react.default.isValidElement(child)) { return /*#__PURE__*/_react.default.cloneElement(child, { colGroupWidth: _this.state.colGroupWidths[index] }); } }); } return childrenArray; }); return _this; } (0, _inherits2.default)(TableRow, _React$Component); return (0, _createClass2.default)(TableRow, [{ key: "render", value: function render() { var _this$props2 = this.props, children = _this$props2.children, innerRef = _this$props2.innerRef; var childrenArray = _react.default.Children.toArray(children); return /*#__PURE__*/_react.default.createElement("tr", { ref: innerRef }, this.props.isNumberColumnEnabled && /*#__PURE__*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 _react.default.createElement("td", { className: _consts.RendererCssClassName.NUMBER_COLUMN }, this.props.index), (0, _utils.compose)(this.addSortableColumn, this.addColGroupWidth)(childrenArray)); } }]); }(_react.default.Component);