UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

114 lines (113 loc) 7.16 kB
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 __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; 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 } from 'lodash'; import { InputNumber } from '@qn-pandora/pandora-component'; import errorBoundary from '../../../../hocs/errorBoundary'; import BasicComponent from '../../../Base/BasicComponent'; import { Form } from '../../../Common'; import { SolidRadioItem, TitleItem } from '../../../Base'; import { OtherLocale } from '../../../../constants/language/other/type'; import { SingleLocale } from '../../../../constants/language/single/type'; import bind from '../../../../utils/bind'; import { formatString } from '../../../../services'; import SwitchNumberEditor from '../../Metrics/component/SwitchNumberEditor'; import MetricStyle from '../../Metrics/component/MetricStyle'; import { singleColorModeOptions } from '../../constants'; import { Arrangements, formItemLayout } from './conatsnts'; import TitleIcon from './TitleIcon'; 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, "titleFontStyle", { get: function () { var _a = this.props, themeOption = _a.themeOption, chartStyleService = _a.chartStyleService; var titleFontSize = chartStyleService.titleFontSize, titleFontColor = chartStyleService.titleFontColor; var statusPanel = get(themeOption, 'statusPanel'); var color = titleFontColor || get(statusPanel, ['itemStyle', 'fontColor']); var fontSize = titleFontSize || get(statusPanel, ['itemStyle', 'fontSize']); return { color: color, fontSize: fontSize }; }, enumerable: false, configurable: true }); StyleElement.prototype.handleChange = function (font) { var _a = this.props.chartStyleService, setTitleFontSize = _a.setTitleFontSize, setTitleFontColor = _a.setTitleFontColor; setTitleFontSize(font.fontSize); setTitleFontColor(font.color); }; StyleElement.prototype.render = function () { var _a = this.props, themeOption = _a.themeOption, chartStyleService = _a.chartStyleService, dataset = _a.dataset, getPopupContainer = _a.getPopupContainer; var metricStyles = chartStyleService.metricStyles, setMetricStyles = chartStyleService.setMetricStyles, pageSize = chartStyleService.pageSize, autoplaySpeed = chartStyleService.autoplaySpeed; return (React.createElement(React.Fragment, null, React.createElement(SolidRadioItem, __assign({ options: singleColorModeOptions, label: SingleLocale.color, field: "colorMode" }, formItemLayout)), React.createElement(Item, __assign({ label: OtherLocale.status.panel_width, field: "width" }, formItemLayout), React.createElement(InputNumber, { addonAfter: "px" })), React.createElement(Item, __assign({ label: OtherLocale.status.panel_height, field: "height" }, formItemLayout), React.createElement(InputNumber, { addonAfter: "px" })), React.createElement(TitleItem, __assign({ label: OtherLocale.metric.title, value: this.titleFontStyle, onChange: this.handleChange }, formItemLayout)), React.createElement(SolidRadioItem, __assign({ options: Arrangements, field: "arrangement", label: OtherLocale.status.arrangement }, formItemLayout)), React.createElement(TitleIcon, { getPopupContainer: getPopupContainer, chartStyleService: chartStyleService, dataset: dataset }), React.createElement(Field, { field: "pageSize" }, React.createElement(SwitchNumberEditor, __assign({ switchLabel: OtherLocale.status.page_size, inputLabel: OtherLocale.status.page_number, value: pageSize, switchEnableValue: 20, switchDisableValue: 0, inputUnit: formatString(OtherLocale.status.unit) }, formItemLayout))), pageSize > 0 && (React.createElement(Field, { field: "autoplaySpeed" }, React.createElement(SwitchNumberEditor, __assign({ switchLabel: OtherLocale.status.autoplay, inputLabel: OtherLocale.status.speed, value: autoplaySpeed, switchEnableValue: 3, switchDisableValue: 0, inputUnit: formatString(OtherLocale.status.s) }, formItemLayout)))), metricStyles && metricStyles.length > 0 && (React.createElement(React.Fragment, null, React.createElement(Item, __assign({ label: OtherLocale.metric.metric_style }, formItemLayout)), React.createElement(Item, { wrapperCol: { span: 24 } }, React.createElement(MetricStyle, { getPopupContainer: getPopupContainer, styles: metricStyles, themeOption: themeOption, onChange: setMetricStyles })))))); }; __decorate([ computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], StyleElement.prototype, "titleFontStyle", 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);