UNPKG

shopperman

Version:

shopping cart ui for shopify stores

52 lines 2.35 kB
"use strict"; 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; }; Object.defineProperty(exports, "__esModule", { value: true }); var mobx_1 = require("mobx"); var crnc_1 = require("crnc"); /** * Facility for exchanging and displaying monetary values * - observable user display currency can be changed */ var CurrencyControl = /** @class */ (function () { function CurrencyControl(options) { Object.assign(this, options); } /** * Switch the current currency being displayed to the user */ CurrencyControl.prototype.setUserDisplayCurrency = function (currency) { this.userDisplayCurrency = currency; }; /** * Perform currency conversion and format into a nice price tag * - optionally provide a precision override */ CurrencyControl.prototype.convertAndFormat = function (value, precisionOverride) { var _a = this, locale = _a.locale, standardPrecision = _a.precision, exchangeRates = _a.exchangeRates, inputCurrency = _a.storeBaseCurrency, outputCurrency = _a.userDisplayCurrency; var precision = (precisionOverride !== null && precisionOverride !== undefined) ? precisionOverride : standardPrecision; return crnc_1.convertAndFormatCurrency({ value: value, locale: locale, precision: precision, inputCurrency: inputCurrency, exchangeRates: exchangeRates, outputCurrency: outputCurrency }); }; __decorate([ mobx_1.observable ], CurrencyControl.prototype, "userDisplayCurrency", void 0); __decorate([ mobx_1.action ], CurrencyControl.prototype, "setUserDisplayCurrency", null); return CurrencyControl; }()); exports.CurrencyControl = CurrencyControl; //# sourceMappingURL=currency-control.js.map