chunk.ZTTW54PZ.js 2.3 KB

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