UNPKG

2.39 kBJavaScriptView Raw
1import {
2 LocalizeController
3} from "./chunk.6WMYSCDC.js";
4import {
5 e,
6 n
7} from "./chunk.VKNZYXSO.js";
8import {
9 s
10} from "./chunk.WWAD5WF4.js";
11import {
12 __decorateClass
13} from "./chunk.K2NRSETB.js";
14
15// src/components/format-number/format-number.ts
16var SlFormatNumber = class extends s {
17 constructor() {
18 super(...arguments);
19 this.localize = new LocalizeController(this);
20 this.value = 0;
21 this.type = "decimal";
22 this.noGrouping = false;
23 this.currency = "USD";
24 this.currencyDisplay = "symbol";
25 }
26 render() {
27 if (isNaN(this.value)) {
28 return "";
29 }
30 return this.localize.number(this.value, {
31 style: this.type,
32 currency: this.currency,
33 currencyDisplay: this.currencyDisplay,
34 useGrouping: !this.noGrouping,
35 minimumIntegerDigits: this.minimumIntegerDigits,
36 minimumFractionDigits: this.minimumFractionDigits,
37 maximumFractionDigits: this.maximumFractionDigits,
38 minimumSignificantDigits: this.minimumSignificantDigits,
39 maximumSignificantDigits: this.maximumSignificantDigits
40 });
41 }
42};
43__decorateClass([
44 e({ type: Number })
45], SlFormatNumber.prototype, "value", 2);
46__decorateClass([
47 e()
48], SlFormatNumber.prototype, "lang", 2);
49__decorateClass([
50 e()
51], SlFormatNumber.prototype, "type", 2);
52__decorateClass([
53 e({ attribute: "no-grouping", type: Boolean })
54], SlFormatNumber.prototype, "noGrouping", 2);
55__decorateClass([
56 e()
57], SlFormatNumber.prototype, "currency", 2);
58__decorateClass([
59 e({ attribute: "currency-display" })
60], SlFormatNumber.prototype, "currencyDisplay", 2);
61__decorateClass([
62 e({ attribute: "minimum-integer-digits", type: Number })
63], SlFormatNumber.prototype, "minimumIntegerDigits", 2);
64__decorateClass([
65 e({ attribute: "minimum-fraction-digits", type: Number })
66], SlFormatNumber.prototype, "minimumFractionDigits", 2);
67__decorateClass([
68 e({ attribute: "maximum-fraction-digits", type: Number })
69], SlFormatNumber.prototype, "maximumFractionDigits", 2);
70__decorateClass([
71 e({ attribute: "minimum-significant-digits", type: Number })
72], SlFormatNumber.prototype, "minimumSignificantDigits", 2);
73__decorateClass([
74 e({ attribute: "maximum-significant-digits", type: Number })
75], SlFormatNumber.prototype, "maximumSignificantDigits", 2);
76SlFormatNumber = __decorateClass([
77 n("sl-format-number")
78], SlFormatNumber);
79
80export {
81 SlFormatNumber
82};