choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
105 lines (85 loc) • 2.89 kB
JavaScript
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
function _createSuper(Derived) {
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
return function () {
var Super = _getPrototypeOf(Derived),
result;
if (isNativeReflectConstruct()) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
import { __decorate } from "tslib";
import { observer } from 'mobx-react';
import isNumber from 'lodash/isNumber';
import { NumberField } from '../number-field/NumberField';
import { FieldType } from '../data-set/enum';
import formatCurrency from '../formatter/formatCurrency';
var Currency =
/*#__PURE__*/
function (_NumberField) {
_inherits(Currency, _NumberField);
var _super = _createSuper(Currency);
function Currency() {
_classCallCheck(this, Currency);
return _super.apply(this, arguments);
}
_createClass(Currency, [{
key: "getFieldType",
value: function getFieldType() {
return FieldType.currency;
}
}, {
key: "getFormatter",
value: function getFormatter() {
return formatCurrency;
}
}, {
key: "getFormatOptions",
value: function getFormatOptions() {
var formatterOptions = this.getProp('formatterOptions') || {};
var lang = formatterOptions.lang || this.lang;
var options = _objectSpread({
currency: this.getProp('currency')
}, formatterOptions.options);
var precision = this.getProp('precision');
var numberGrouping = this.getProp('numberGrouping');
if (isNumber(precision)) {
options.minimumFractionDigits = precision;
options.maximumFractionDigits = precision;
}
if (numberGrouping === false) {
options.useGrouping = false;
}
return {
lang: lang,
options: options
};
}
}]);
return Currency;
}(NumberField);
Currency.displayName = 'Currency';
Currency.format = formatCurrency;
Currency = __decorate([observer], Currency);
export default Currency;
//# sourceMappingURL=Currency.js.map