UNPKG

@3mo/number-fields

Version:

A set of number field web components.

44 lines (42 loc) 1.36 kB
var FieldCurrency_1; import { __decorate } from "tslib"; import { component, css, html, property } from '@a11d/lit'; import { Currency } from '@3mo/localization'; import { FieldNumber } from './FieldNumber.js'; /** * @element mo-field-currency * * @attr currency - The currency of the field. */ let FieldCurrency = FieldCurrency_1 = class FieldCurrency extends FieldNumber { constructor() { super(...arguments); this.currency = FieldCurrency_1.defaultCurrency; this.format = (value) => value.formatAsCurrency(undefined); } static get styles() { return css ` ${super.styles} span[slot=end] { font-size: x-large; color: var(--mo-color-gray); user-select: none; } `; } get endSlotTemplate() { var _a; return html ` <span slot='end' @click=${() => this.focus()}>${(_a = this.currency) === null || _a === void 0 ? void 0 : _a.symbol}</span> ${super.endSlotTemplate} `; } }; FieldCurrency.currencyConverter = (value) => !value ? undefined : value instanceof Currency ? value : new Currency(value); __decorate([ property({ type: Object, converter: FieldCurrency.currencyConverter }) ], FieldCurrency.prototype, "currency", void 0); FieldCurrency = FieldCurrency_1 = __decorate([ component('mo-field-currency') ], FieldCurrency); export { FieldCurrency };