@shoelace-style/shoelace
Version:
A forward-thinking library of web components.
74 lines (71 loc) • 2.36 kB
JavaScript
import {
LocalizeController
} from "./chunk.WLV3FVBR.js";
import {
ShoelaceElement
} from "./chunk.UYAO2JRR.js";
import {
__decorateClass
} from "./chunk.B3BW2AY6.js";
// src/components/format-number/format-number.component.ts
import { property } from "lit/decorators.js";
var SlFormatNumber = class extends ShoelaceElement {
constructor() {
super(...arguments);
this.localize = new LocalizeController(this);
this.value = 0;
this.type = "decimal";
this.noGrouping = false;
this.currency = "USD";
this.currencyDisplay = "symbol";
}
render() {
if (isNaN(this.value)) {
return "";
}
return this.localize.number(this.value, {
style: this.type,
currency: this.currency,
currencyDisplay: this.currencyDisplay,
useGrouping: !this.noGrouping,
minimumIntegerDigits: this.minimumIntegerDigits,
minimumFractionDigits: this.minimumFractionDigits,
maximumFractionDigits: this.maximumFractionDigits,
minimumSignificantDigits: this.minimumSignificantDigits,
maximumSignificantDigits: this.maximumSignificantDigits
});
}
};
__decorateClass([
property({ type: Number })
], SlFormatNumber.prototype, "value", 2);
__decorateClass([
property()
], SlFormatNumber.prototype, "type", 2);
__decorateClass([
property({ attribute: "no-grouping", type: Boolean })
], SlFormatNumber.prototype, "noGrouping", 2);
__decorateClass([
property()
], SlFormatNumber.prototype, "currency", 2);
__decorateClass([
property({ attribute: "currency-display" })
], SlFormatNumber.prototype, "currencyDisplay", 2);
__decorateClass([
property({ attribute: "minimum-integer-digits", type: Number })
], SlFormatNumber.prototype, "minimumIntegerDigits", 2);
__decorateClass([
property({ attribute: "minimum-fraction-digits", type: Number })
], SlFormatNumber.prototype, "minimumFractionDigits", 2);
__decorateClass([
property({ attribute: "maximum-fraction-digits", type: Number })
], SlFormatNumber.prototype, "maximumFractionDigits", 2);
__decorateClass([
property({ attribute: "minimum-significant-digits", type: Number })
], SlFormatNumber.prototype, "minimumSignificantDigits", 2);
__decorateClass([
property({ attribute: "maximum-significant-digits", type: Number })
], SlFormatNumber.prototype, "maximumSignificantDigits", 2);
export {
SlFormatNumber
};