frc-ui
Version:
React Web UI
134 lines (99 loc) • 6.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _Hoc = require("../common/Hoc");
var _loading = _interopRequireDefault(require("../../loading"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
var __decorate = void 0 && (void 0).__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
}
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var LoadMore = /*#__PURE__*/function (_React$PureComponent) {
_inherits(LoadMore, _React$PureComponent);
var _super = _createSuper(LoadMore);
function LoadMore() {
var _this;
_classCallCheck(this, LoadMore);
_this = _super.apply(this, arguments);
_this.handleClick = function (event) {
event.stopPropagation();
var _this$props = _this.props,
loading = _this$props.loading,
total = _this$props.total,
start = _this$props.start,
startDate = _this$props.startDate,
pageSize = _this$props.pageSize,
channel = _this$props.channel,
emit = _this$props.emit,
showAllHistory = _this$props.showAllHistory;
if (!emit) return;
if (loading || total <= start + pageSize) {
return;
}
var payload = {
chatRoomCode: channel,
startDate: startDate,
startIndex: start
};
if (!showAllHistory) {
payload.pageSize = pageSize;
}
emit('chatMessage.history', payload);
};
return _this;
}
_createClass(LoadMore, [{
key: "render",
value: function render() {
var _this$props2 = this.props,
prefix = _this$props2.prefix,
loading = _this$props2.loading,
locale = _this$props2.locale,
total = _this$props2.total,
start = _this$props2.start,
pageSize = _this$props2.pageSize,
showAllHistory = _this$props2.showAllHistory;
var child = locale && locale.loadMore;
if (loading) {
child = /*#__PURE__*/_react["default"].createElement(_loading["default"], {
size: 20
});
} else if (total <= start) {
child = locale && locale.noLoadMore;
}
var className = (0, _classnames["default"])("".concat(prefix, "-load-more"), _defineProperty({}, "".concat(prefix, "-load-no-more"), total <= start + pageSize));
return /*#__PURE__*/_react["default"].createElement("div", {
className: className,
onClick: this.handleClick,
style: {
display: showAllHistory ? 'none' : 'flex'
}
}, child);
}
}]);
return LoadMore;
}(_react["default"].PureComponent);
LoadMore = __decorate([(0, _Hoc.Consumer)()], LoadMore);
var _default = LoadMore;
exports["default"] = _default;