@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
57 lines (56 loc) • 2.79 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__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 === "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 __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import React from 'react';
import { CopyToClipboard as BaseCopyToClipboard } from 'react-copy-to-clipboard';
import bind from '../../../utils/bind';
import toaster from '../../../services/base/toaster';
var CopyToClipboard = /** @class */ (function (_super) {
__extends(CopyToClipboard, _super);
function CopyToClipboard() {
return _super !== null && _super.apply(this, arguments) || this;
}
CopyToClipboard.prototype.onCopy = function (text, success) {
var _a = this.props, successMessage = _a.successMessage, errorMessage = _a.errorMessage, onCopy = _a.onCopy;
if (success && successMessage) {
toaster.success(successMessage);
}
if (!success && errorMessage) {
toaster.warning(errorMessage);
}
if (onCopy) {
onCopy(text, success);
}
};
CopyToClipboard.prototype.render = function () {
var _a = this.props, text = _a.text, options = _a.options;
return (React.createElement(BaseCopyToClipboard, { text: text, options: options, onCopy: this.onCopy }, this.props.children));
};
__decorate([
bind,
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, Boolean]),
__metadata("design:returntype", void 0)
], CopyToClipboard.prototype, "onCopy", null);
return CopyToClipboard;
}(React.Component));
export default CopyToClipboard;