@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
115 lines (114 loc) • 6.96 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 { observer } from 'mobx-react';
import { computed } from 'mobx';
import { get, isUndefined } from 'lodash';
import { InputNumber } from '@qn-pandora/pandora-component';
import errorBoundary from '../../../../hocs/errorBoundary';
import BasicComponent from '../../../Base/BasicComponent';
import { Form, SolidRadioGroup } from '../../../Common';
import { SolidRadioItem, TitleItem } from '../../../Base';
import { OtherLocale } from '../../../../constants/language/other/type';
import { SingleLocale } from '../../../../constants/language/single/type';
import { BaseLocale } from '../../../../constants/language/base/type';
import SwitchNumberEditor from '../../Metrics/component/SwitchNumberEditor';
import { formatString } from '../../../../services';
import bind from '../../../../utils/bind';
import { singleColorModeOptions, switchOptions } from '../../constants';
var Item = Form.Item, Field = Form.Field;
var StyleElement = /** @class */ (function (_super) {
__extends(StyleElement, _super);
function StyleElement() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(StyleElement.prototype, "contentFontStyle", {
get: function () {
var _a = this.props, themeOption = _a.themeOption, chartStyleService = _a.chartStyleService;
var contentFontSize = chartStyleService.contentFontSize, contentColor = chartStyleService.contentColor;
var statusPanel = get(themeOption, 'statusPanel');
var color = contentColor || get(statusPanel, ['itemStyle', 'fontColor']);
var fontSize = contentFontSize || get(statusPanel, ['itemStyle', 'fontSize']);
return { color: color, fontSize: fontSize };
},
enumerable: false,
configurable: true
});
Object.defineProperty(StyleElement.prototype, "showMetricName", {
get: function () {
var showMetricName = this.props.chartStyleService.showMetricName;
return isUndefined(showMetricName) ? true : showMetricName;
},
enumerable: false,
configurable: true
});
StyleElement.prototype.handleChange = function (font) {
var _a = this.props.chartStyleService, setContentFontSize = _a.setContentFontSize, setContentColor = _a.setContentColor;
setContentFontSize(font.fontSize);
setContentColor(font.color);
};
StyleElement.prototype.render = function () {
var _a = this.props.chartStyleService, pageSize = _a.pageSize, autoplaySpeed = _a.autoplaySpeed;
return (React.createElement(React.Fragment, null,
React.createElement(Item, { label: SingleLocale.color, field: "colorMode" },
React.createElement(SolidRadioGroup, { options: singleColorModeOptions })),
React.createElement(Item, { label: OtherLocale.status.panel_width, field: "width" },
React.createElement(InputNumber, { addonAfter: "px" })),
React.createElement(Item, { label: OtherLocale.status.panel_height, field: "height" },
React.createElement(InputNumber, { addonAfter: "px" })),
React.createElement(Item, { label: BaseLocale.title.font_size, field: "titleFontSize" },
React.createElement(InputNumber, { addonAfter: "px" })),
React.createElement(TitleItem, { label: OtherLocale.status.content, value: this.contentFontStyle, onChange: this.handleChange, getPopupContainer: this.getRootDOM }),
React.createElement(SolidRadioItem, { label: OtherLocale.status.show_metric_name, field: "showMetricName", options: switchOptions, value: this.showMetricName }),
React.createElement(Field, { field: "pageSize" },
React.createElement(SwitchNumberEditor, { switchLabel: OtherLocale.status.page_size, inputLabel: OtherLocale.status.page_number, value: pageSize, switchEnableValue: 20, switchDisableValue: 0, inputUnit: formatString(OtherLocale.status.unit) })),
pageSize > 0 && (React.createElement(Field, { field: "autoplaySpeed" },
React.createElement(SwitchNumberEditor, { switchLabel: OtherLocale.status.autoplay, inputLabel: OtherLocale.status.speed, value: autoplaySpeed, switchEnableValue: 3, switchDisableValue: 0, inputUnit: formatString(OtherLocale.status.s) }))),
React.createElement(Item, { field: "panelAutoSort", label: OtherLocale.status.plane_order, explain: OtherLocale.status.plane_order_title },
React.createElement(SolidRadioGroup, { options: switchOptions })),
React.createElement(Item, { field: "metricAutoSort", label: OtherLocale.status.metric, explain: OtherLocale.status.metric_title },
React.createElement(SolidRadioGroup, { options: switchOptions }))));
};
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], StyleElement.prototype, "contentFontStyle", null);
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], StyleElement.prototype, "showMetricName", null);
__decorate([
bind,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], StyleElement.prototype, "handleChange", null);
StyleElement = __decorate([
observer
], StyleElement);
return StyleElement;
}(BasicComponent));
export { StyleElement };
export default errorBoundary(StyleElement);