@nvidia-elements/core 2.18.1 → 2.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/accordion/accordion2.js +4 -4
  3. package/dist/alert/alert-group2.js +1 -1
  4. package/dist/alert/alert2.js +1 -1
  5. package/dist/avatar/avatar-group2.js +1 -1
  6. package/dist/avatar/avatar2.js +1 -1
  7. package/dist/badge/badge2.js +1 -1
  8. package/dist/breadcrumb/breadcrumb2.js +1 -1
  9. package/dist/bundles/index.d.ts +3 -3
  10. package/dist/bundles/index.js +9 -9
  11. package/dist/button/button2.js +1 -1
  12. package/dist/button-group/button-group.d.ts +1 -1
  13. package/dist/button-group/button-group2.js +4 -2
  14. package/dist/button-group/button-group2.js.map +1 -1
  15. package/dist/card/card2.js +7 -9
  16. package/dist/card/card2.js.map +1 -1
  17. package/dist/chat-message/chat-message2.js +1 -1
  18. package/dist/checkbox/checkbox-group2.js +1 -1
  19. package/dist/checkbox/checkbox2.js +1 -1
  20. package/dist/color/color2.js +1 -1
  21. package/dist/combobox/combobox2.js +1 -1
  22. package/dist/copy-button/copy-button2.js +1 -1
  23. package/dist/custom-elements-jsx.d.ts +5 -5
  24. package/dist/custom-elements-vue.d.ts +5 -5
  25. package/dist/custom-elements.json +28 -50
  26. package/dist/data.html.json +3 -3
  27. package/dist/data.snippets.json +27 -27
  28. package/dist/date/date2.js +1 -1
  29. package/dist/datetime/datetime2.js +1 -1
  30. package/dist/dialog/dialog-footer2.js +8 -11
  31. package/dist/dialog/dialog-footer2.js.map +1 -1
  32. package/dist/dialog/dialog-header2.js +8 -11
  33. package/dist/dialog/dialog-header2.js.map +1 -1
  34. package/dist/dialog/dialog2.js +1 -1
  35. package/dist/divider/divider2.js +1 -1
  36. package/dist/dot/dot2.js +1 -1
  37. package/dist/drag-handle/drag-handle2.js +1 -1
  38. package/dist/drawer/drawer-content2.js +8 -11
  39. package/dist/drawer/drawer-content2.js.map +1 -1
  40. package/dist/drawer/drawer-footer2.js +8 -11
  41. package/dist/drawer/drawer-footer2.js.map +1 -1
  42. package/dist/drawer/drawer-header2.js +8 -11
  43. package/dist/drawer/drawer-header2.js.map +1 -1
  44. package/dist/drawer/drawer2.js +1 -1
  45. package/dist/dropdown/dropdown-footer2.js +8 -11
  46. package/dist/dropdown/dropdown-footer2.js.map +1 -1
  47. package/dist/dropdown/dropdown-header2.js +8 -11
  48. package/dist/dropdown/dropdown-header2.js.map +1 -1
  49. package/dist/dropdown/dropdown2.js +1 -1
  50. package/dist/dropdown-group/dropdown-group.js +1 -1
  51. package/dist/dropzone/dropzone2.js +1 -1
  52. package/dist/file/file2.js +1 -1
  53. package/dist/format-bytes/format-bytes2.js +49 -54
  54. package/dist/format-bytes/format-bytes2.js.map +1 -1
  55. package/dist/format-datetime/format-datetime2.js +26 -27
  56. package/dist/format-datetime/format-datetime2.js.map +1 -1
  57. package/dist/format-number/format-number.d.ts +2 -2
  58. package/dist/format-number/format-number2.js +37 -38
  59. package/dist/format-number/format-number2.js.map +1 -1
  60. package/dist/format-relative-time/format-relative-time2.js +27 -28
  61. package/dist/format-relative-time/format-relative-time2.js.map +1 -1
  62. package/dist/format-truncate/format-truncate2.js +1 -1
  63. package/dist/forms/control/control2.js +1 -1
  64. package/dist/forms/control-group/control-group2.js +1 -1
  65. package/dist/forms/control-message/control-message2.js +1 -1
  66. package/dist/gauge/gauge2.js +1 -1
  67. package/dist/grid/cell/cell2.js +1 -1
  68. package/dist/grid/column/column2.js +1 -1
  69. package/dist/grid/footer/footer2.js +1 -1
  70. package/dist/grid/grid2.js +1 -1
  71. package/dist/grid/header/header2.js +7 -7
  72. package/dist/grid/placeholder/placeholder2.js +1 -1
  73. package/dist/grid/row/row2.js +1 -1
  74. package/dist/icon/icon2.js +2 -2
  75. package/dist/icon-button/icon-button2.js +1 -1
  76. package/dist/iframe/iframe2.js +1 -1
  77. package/dist/index.js +1 -1
  78. package/dist/input/input-group2.js +1 -1
  79. package/dist/input/input2.js +1 -1
  80. package/dist/internal/controllers/audit.controller.d.ts +0 -2
  81. package/dist/internal/controllers/audit.controller.js +42 -52
  82. package/dist/internal/controllers/audit.controller.js.map +1 -1
  83. package/dist/internal/controllers/keynav-grid.controller.js +11 -11
  84. package/dist/internal/index.js +28 -28
  85. package/dist/internal/services/global.service.js +1 -1
  86. package/dist/internal/utils/audit-logs.d.ts +1 -1
  87. package/dist/internal/utils/audit-logs.js +3 -3
  88. package/dist/internal/utils/audit-logs.js.map +1 -1
  89. package/dist/internal/utils/audit.d.ts +0 -8
  90. package/dist/internal/utils/audit.js +1 -5
  91. package/dist/internal/utils/audit.js.map +1 -1
  92. package/dist/logo/logo2.js +1 -1
  93. package/dist/menu/menu-group2.js +1 -1
  94. package/dist/menu/menu-item2.js +1 -1
  95. package/dist/menu/menu2.js +1 -1
  96. package/dist/month/month2.js +1 -1
  97. package/dist/notification/notification-group2.js +1 -1
  98. package/dist/notification/notification2.js +1 -1
  99. package/dist/page/page-panel/page-panel-content2.js +1 -1
  100. package/dist/page/page-panel/page-panel-footer2.js +1 -1
  101. package/dist/page/page-panel/page-panel-header2.js +1 -1
  102. package/dist/page/page-panel/page-panel2.js +19 -20
  103. package/dist/page/page-panel/page-panel2.js.map +1 -1
  104. package/dist/page/page2.js +2 -2
  105. package/dist/page/page2.js.map +1 -1
  106. package/dist/page-header/page-header2.js +1 -1
  107. package/dist/page-loader/page-loader2.js +1 -1
  108. package/dist/pagination/pagination2.js +1 -1
  109. package/dist/panel/panel2.js +4 -4
  110. package/dist/password/password2.js +1 -1
  111. package/dist/preferences-input/preferences-input2.js +1 -1
  112. package/dist/progress-bar/progress-bar2.js +1 -1
  113. package/dist/progress-dot/progress-dot2.js +1 -1
  114. package/dist/progress-ring/progress-ring2.js +1 -1
  115. package/dist/progressive-filter-chip/progressive-filter-chip2.js +1 -1
  116. package/dist/pulse/pulse2.js +1 -1
  117. package/dist/radio/radio-group2.js +1 -1
  118. package/dist/radio/radio2.js +1 -1
  119. package/dist/range/range2.js +1 -1
  120. package/dist/resize-handle/resize-handle2.js +1 -1
  121. package/dist/search/search2.js +1 -1
  122. package/dist/select/select2.js +1 -1
  123. package/dist/skeleton/skeleton2.js +1 -1
  124. package/dist/sort-button/sort-button2.js +1 -1
  125. package/dist/sparkline/sparkline2.js +1 -1
  126. package/dist/star-rating/star-rating2.js +1 -1
  127. package/dist/steps/steps2.js +2 -2
  128. package/dist/switch/switch-group2.js +1 -1
  129. package/dist/switch/switch2.js +1 -1
  130. package/dist/tabs/tabs-group2.js +1 -1
  131. package/dist/tabs/tabs-item-group2.js +1 -1
  132. package/dist/tabs/tabs2.js +2 -2
  133. package/dist/tag/tag2.js +1 -1
  134. package/dist/textarea/textarea2.js +1 -1
  135. package/dist/time/time2.js +1 -1
  136. package/dist/toast/toast2.js +1 -1
  137. package/dist/toggletip/toggletip-footer2.js +8 -11
  138. package/dist/toggletip/toggletip-footer2.js.map +1 -1
  139. package/dist/toggletip/toggletip-header2.js +8 -11
  140. package/dist/toggletip/toggletip-header2.js.map +1 -1
  141. package/dist/toggletip/toggletip2.js +1 -1
  142. package/dist/toolbar/toolbar2.js +1 -1
  143. package/dist/tooltip/tooltip2.js +1 -1
  144. package/dist/tree/tree-node2.js +1 -1
  145. package/dist/tree/tree.examples.js.map +1 -1
  146. package/dist/tree/tree2.js +1 -1
  147. package/dist/week/week2.js +1 -1
  148. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"format-bytes2.js","names":[],"sources":["../../src/format-bytes/format-bytes.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { LogService, typeSSR, useStyles } from '@nvidia-elements/core/internal';\nimport styles from './format-bytes.css?inline';\n\nexport type FormatBytesDisplay = 'decimal' | 'binary';\nexport type FormatBytesUnit = 'b' | 'kb' | 'mb' | 'gb' | 'tb' | 'pb';\nexport type FormatBytesUnitDisplay = 'short' | 'long';\n\ninterface UnitLabels {\n short: string;\n singular: string;\n plural: string;\n}\n\nconst UNITS: readonly FormatBytesUnit[] = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];\nconst DISPLAYS: readonly FormatBytesDisplay[] = ['decimal', 'binary'];\nconst UNIT_DISPLAYS: readonly FormatBytesUnitDisplay[] = ['short', 'long'];\n\nconst DECIMAL_LABELS: Record<FormatBytesUnit, UnitLabels> = {\n b: { short: 'B', singular: 'byte', plural: 'bytes' },\n kb: { short: 'kB', singular: 'kilobyte', plural: 'kilobytes' },\n mb: { short: 'MB', singular: 'megabyte', plural: 'megabytes' },\n gb: { short: 'GB', singular: 'gigabyte', plural: 'gigabytes' },\n tb: { short: 'TB', singular: 'terabyte', plural: 'terabytes' },\n pb: { short: 'PB', singular: 'petabyte', plural: 'petabytes' }\n};\n\nconst BINARY_LABELS: Record<FormatBytesUnit, UnitLabels> = {\n b: { short: 'B', singular: 'byte', plural: 'bytes' },\n kb: { short: 'KiB', singular: 'kibibyte', plural: 'kibibytes' },\n mb: { short: 'MiB', singular: 'mebibyte', plural: 'mebibytes' },\n gb: { short: 'GiB', singular: 'gibibyte', plural: 'gibibytes' },\n tb: { short: 'TiB', singular: 'tebibyte', plural: 'tebibytes' },\n pb: { short: 'PiB', singular: 'pebibyte', plural: 'pebibytes' }\n};\n\nfunction isDisplay(value: unknown): value is FormatBytesDisplay {\n return DISPLAYS.some(display => display === value);\n}\n\nfunction isUnit(value: unknown): value is FormatBytesUnit {\n return UNITS.some(unit => unit === value);\n}\n\nfunction isUnitDisplay(value: unknown): value is FormatBytesUnitDisplay {\n return UNIT_DISPLAYS.some(unitDisplay => unitDisplay === value);\n}\n\n/**\n * @element nve-format-bytes\n * @description Formats a byte count as localized, human-readable decimal or binary units.\n * @documentation https://nvidia.github.io/elements/docs/elements/format-bytes/\n * @since 0.0.0\n * @entrypoint \\@nvidia-elements/core/format-bytes\n * @slot - Numeric byte count to format (such as 1048576). Serves as fallback before hydration.\n * @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/data\n */\n@typeSSR()\nexport class FormatBytes extends LitElement {\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-format-bytes',\n version: '0.0.0'\n };\n\n /**\n * Optional byte count for values supplied by JavaScript or bound data.\n * By default, the component formats the element's text content, which also serves as the SSR fallback.\n * When both are present, this property takes precedence.\n */\n @property({ type: Number }) value?: number;\n\n /**\n * Unit system: 'decimal' uses powers of 1000 and 'binary' uses powers of 1024.\n */\n @property({ type: String }) display: FormatBytesDisplay = 'decimal';\n\n /**\n * Optional unit magnitude. When omitted, the component selects a unit from the byte count.\n */\n @property({ type: String }) unit?: FormatBytesUnit;\n\n /**\n * Unit label length: 'short' renders labels such as 'MB'; 'long' renders labels such as 'megabytes'.\n */\n @property({ type: String, attribute: 'unit-display' }) unitDisplay: FormatBytesUnitDisplay = 'short';\n\n /**\n * Language tag (such as en-US or de-DE) used to format the number.\n * Defaults to document.documentElement.lang or the runtime default.\n */\n @property({ type: String }) locale?: string;\n\n /**\n * Pad fraction output to at least this many digits.\n */\n @property({ type: Number, attribute: 'minimum-fraction-digits' }) minimumFractionDigits?: number;\n\n /**\n * Round fraction output to at most this many digits. Defaults to two effective digits after the decimal point.\n */\n @property({ type: Number, attribute: 'maximum-fraction-digits' }) maximumFractionDigits?: number;\n\n get #rawValue(): string {\n const value = Number.isNaN(this.value) ? (this.getAttribute('value') ?? this.value) : this.value;\n return String(value ?? this.textContent?.trim() ?? '');\n }\n\n get #resolvedLocale(): string | undefined {\n return this.locale ?? (globalThis.document?.documentElement?.lang || undefined);\n }\n\n get #parsedValue(): number | null {\n const rawValue = this.#rawValue;\n if (!rawValue) return null;\n\n const numericValue = Number(rawValue);\n if (Number.isFinite(numericValue)) return numericValue;\n\n LogService.warn(`format-bytes: invalid numeric value \"${rawValue}\"`);\n return null;\n }\n\n #resolveAutoUnit(value: number, display: FormatBytesDisplay): FormatBytesUnit {\n const base = display === 'binary' ? 1024 : 1000;\n const absoluteValue = Math.abs(value);\n\n for (let index = UNITS.length - 1; index > 0; index--) {\n const unit = UNITS[index];\n if (unit && absoluteValue >= base ** index) return unit;\n }\n\n return 'b';\n }\n\n #formatLabel(unit: FormatBytesUnit, convertedValue: number): string {\n const labels = this.display === 'binary' ? BINARY_LABELS[unit] : DECIMAL_LABELS[unit];\n if (this.unitDisplay === 'short') return labels.short;\n return Math.abs(convertedValue) === 1 ? labels.singular : labels.plural;\n }\n\n #warnInvalidOption(name: string, value: unknown): void {\n LogService.warn(`format-bytes: invalid ${name} value \"${String(value)}\"`);\n }\n\n #hasValidConfiguration(): boolean {\n if (!isDisplay(this.display)) {\n this.#warnInvalidOption('display', this.display);\n return false;\n }\n if (!isUnitDisplay(this.unitDisplay)) {\n this.#warnInvalidOption('unit-display', this.unitDisplay);\n return false;\n }\n if (this.unit !== undefined && !isUnit(this.unit)) {\n this.#warnInvalidOption('unit', this.unit);\n return false;\n }\n return true;\n }\n\n get #numberFormatOptions(): Intl.NumberFormatOptions {\n const effectiveMaximumFractionDigits = this.maximumFractionDigits ?? Math.max(this.minimumFractionDigits ?? 0, 2);\n return {\n minimumFractionDigits: this.minimumFractionDigits,\n maximumFractionDigits: effectiveMaximumFractionDigits\n };\n }\n\n #roundNumber(value: number): number {\n return Number(\n new Intl.NumberFormat('en-US-u-nu-latn', {\n ...this.#numberFormatOptions,\n useGrouping: false\n }).format(value)\n );\n }\n\n #formatNumber(value: number): string {\n return new Intl.NumberFormat(this.#resolvedLocale, this.#numberFormatOptions).format(value);\n }\n\n get #formattedBytes(): string {\n const rawValue = this.#rawValue;\n if (!rawValue) return '';\n\n const numericValue = this.#parsedValue;\n if (numericValue === null) return rawValue;\n if (!this.#hasValidConfiguration()) return rawValue;\n\n const resolvedUnit = this.unit ?? this.#resolveAutoUnit(numericValue, this.display);\n const unitIndex = UNITS.indexOf(resolvedUnit);\n const base = this.display === 'binary' ? 1024 : 1000;\n const convertedValue = numericValue / base ** unitIndex;\n\n try {\n const roundedValue = this.#roundNumber(convertedValue);\n return `${this.#formatNumber(roundedValue)} ${this.#formatLabel(resolvedUnit, roundedValue)}`;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n LogService.warn(`format-bytes: ${message}`);\n return rawValue;\n }\n }\n\n render() {\n return html`<data internal-host value=${this.#rawValue}>${this.#formattedBytes}<slot @slotchange=${this.#onSlotChange} hidden></slot></data>`;\n }\n\n #onSlotChange() {\n this.requestUpdate();\n }\n}\n"],"mappings":";;;;;;;;AAkBA,IAAM,IAAoC;CAAC;CAAK;CAAM;CAAM;CAAM;CAAM;AAAI,GACtE,IAA0C,CAAC,WAAW,QAAQ,GAC9D,IAAmD,CAAC,SAAS,MAAM,GAEnE,IAAsD;CAC1D,GAAG;EAAE,OAAO;EAAK,UAAU;EAAQ,QAAQ;CAAQ;CACnD,IAAI;EAAE,OAAO;EAAM,UAAU;EAAY,QAAQ;CAAY;CAC7D,IAAI;EAAE,OAAO;EAAM,UAAU;EAAY,QAAQ;CAAY;CAC7D,IAAI;EAAE,OAAO;EAAM,UAAU;EAAY,QAAQ;CAAY;CAC7D,IAAI;EAAE,OAAO;EAAM,UAAU;EAAY,QAAQ;CAAY;CAC7D,IAAI;EAAE,OAAO;EAAM,UAAU;EAAY,QAAQ;CAAY;AAC/D,GAEM,IAAqD;CACzD,GAAG;EAAE,OAAO;EAAK,UAAU;EAAQ,QAAQ;CAAQ;CACnD,IAAI;EAAE,OAAO;EAAO,UAAU;EAAY,QAAQ;CAAY;CAC9D,IAAI;EAAE,OAAO;EAAO,UAAU;EAAY,QAAQ;CAAY;CAC9D,IAAI;EAAE,OAAO;EAAO,UAAU;EAAY,QAAQ;CAAY;CAC9D,IAAI;EAAE,OAAO;EAAO,UAAU;EAAY,QAAQ;CAAY;CAC9D,IAAI;EAAE,OAAO;EAAO,UAAU;EAAY,Q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GAAa,GAAc,CAAY;EAC5F,SAAS,GAAO;GACd,IAAM,IAAU,aAAiB,QAAQ,EAAM,UAAU,OAAO,CAAK;GAErE,OADA,EAAW,KAAK,iBAAiB,GAAS,GACnC;EACT;CACF;CAEA,SAAS;EACP,OAAO,CAAI,8BAA6B,KAAK,GAAU,IAAG,KAAK,GAAgB,qBAAoB,KAAK,GAAc;CACxH;CAEA,KAAgB;EACd,KAAK,cAAc;CACrB;AACF;AA9IG,EAAA,CAAA,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,SAAA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,WAAA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAe,CAAC,CAAA,GAAA,EAAA,WAAA,eAAA,KAAA,CAAA,GAMpD,EAAA,CAAA,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,UAAA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAA0B,CAAC,CAAA,GAAA,EAAA,WAAA,yBAAA,KAAA,CAAA,GAK/D,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAA0B,CAAC,CAAA,GAAA,EAAA,WAAA,yBAAA,KAAA,CAAA,GA7CjE,IAAA,EAAA,CAAA,EAAQ,CAAA,GAAA,CAAA"}
1
+ {"version":3,"file":"format-bytes2.js","names":[],"sources":["../../src/format-bytes/format-bytes.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { typeSSR, useStyles } from '@nvidia-elements/core/internal';\nimport styles from './format-bytes.css?inline';\n\nexport type FormatBytesDisplay = 'decimal' | 'binary';\nexport type FormatBytesUnit = 'b' | 'kb' | 'mb' | 'gb' | 'tb' | 'pb';\nexport type FormatBytesUnitDisplay = 'short' | 'long';\n\ninterface UnitLabels {\n short: string;\n singular: string;\n plural: string;\n}\n\nconst UNITS: readonly FormatBytesUnit[] = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];\nconst DISPLAYS: readonly FormatBytesDisplay[] = ['decimal', 'binary'];\nconst UNIT_DISPLAYS: readonly FormatBytesUnitDisplay[] = ['short', 'long'];\n\nconst DECIMAL_LABELS: Record<FormatBytesUnit, UnitLabels> = {\n b: { short: 'B', singular: 'byte', plural: 'bytes' },\n kb: { short: 'kB', singular: 'kilobyte', plural: 'kilobytes' },\n mb: { short: 'MB', singular: 'megabyte', plural: 'megabytes' },\n gb: { short: 'GB', singular: 'gigabyte', plural: 'gigabytes' },\n tb: { short: 'TB', singular: 'terabyte', plural: 'terabytes' },\n pb: { short: 'PB', singular: 'petabyte', plural: 'petabytes' }\n};\n\nconst BINARY_LABELS: Record<FormatBytesUnit, UnitLabels> = {\n b: { short: 'B', singular: 'byte', plural: 'bytes' },\n kb: { short: 'KiB', singular: 'kibibyte', plural: 'kibibytes' },\n mb: { short: 'MiB', singular: 'mebibyte', plural: 'mebibytes' },\n gb: { short: 'GiB', singular: 'gibibyte', plural: 'gibibytes' },\n tb: { short: 'TiB', singular: 'tebibyte', plural: 'tebibytes' },\n pb: { short: 'PiB', singular: 'pebibyte', plural: 'pebibytes' }\n};\n\nfunction isDisplay(value: unknown): value is FormatBytesDisplay {\n return DISPLAYS.some(display => display === value);\n}\n\nfunction isUnit(value: unknown): value is FormatBytesUnit {\n return UNITS.some(unit => unit === value);\n}\n\nfunction isUnitDisplay(value: unknown): value is FormatBytesUnitDisplay {\n return UNIT_DISPLAYS.some(unitDisplay => unitDisplay === value);\n}\n\n/**\n * @element nve-format-bytes\n * @description Formats a byte count as localized, human-readable decimal or binary units.\n * @documentation https://nvidia.github.io/elements/docs/elements/format-bytes/\n * @since 0.0.0\n * @entrypoint \\@nvidia-elements/core/format-bytes\n * @slot - Numeric byte count to format (such as 1048576). Serves as fallback before hydration.\n * @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/data\n */\n@typeSSR()\nexport class FormatBytes extends LitElement {\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-format-bytes',\n version: '0.0.0'\n };\n\n /**\n * Optional byte count for values supplied by JavaScript or bound data.\n * By default, the component formats the element's text content, which also serves as the SSR fallback.\n * When both are present, this property takes precedence.\n */\n @property({ type: Number }) value?: number;\n\n /**\n * Unit system: 'decimal' uses powers of 1000 and 'binary' uses powers of 1024.\n */\n @property({ type: String }) display: FormatBytesDisplay = 'decimal';\n\n /**\n * Optional unit magnitude. When omitted, the component selects a unit from the byte count.\n */\n @property({ type: String }) unit?: FormatBytesUnit;\n\n /**\n * Unit label length: 'short' renders labels such as 'MB'; 'long' renders labels such as 'megabytes'.\n */\n @property({ type: String, attribute: 'unit-display' }) unitDisplay: FormatBytesUnitDisplay = 'short';\n\n /**\n * Language tag (such as en-US or de-DE) used to format the number.\n * Defaults to document.documentElement.lang or the runtime default.\n */\n @property({ type: String }) locale?: string;\n\n /**\n * Pad fraction output to at least this many digits.\n */\n @property({ type: Number, attribute: 'minimum-fraction-digits' }) minimumFractionDigits?: number;\n\n /**\n * Round fraction output to at most this many digits. Defaults to two effective digits after the decimal point.\n */\n @property({ type: Number, attribute: 'maximum-fraction-digits' }) maximumFractionDigits?: number;\n\n get #rawValue(): string {\n const value = Number.isNaN(this.value) ? (this.getAttribute('value') ?? this.value) : this.value;\n return String(value ?? this.textContent?.trim() ?? '');\n }\n\n get #resolvedLocale(): string | undefined {\n return this.locale ?? (globalThis.document?.documentElement?.lang || undefined);\n }\n\n get #parsedValue(): number | null {\n const rawValue = this.#rawValue;\n if (!rawValue) return null;\n\n const numericValue = Number(rawValue);\n if (Number.isFinite(numericValue)) return numericValue;\n\n return null;\n }\n\n #resolveAutoUnit(value: number, display: FormatBytesDisplay): FormatBytesUnit {\n const base = display === 'binary' ? 1024 : 1000;\n const absoluteValue = Math.abs(value);\n\n for (let index = UNITS.length - 1; index > 0; index--) {\n const unit = UNITS[index];\n if (unit && absoluteValue >= base ** index) return unit;\n }\n\n return 'b';\n }\n\n #formatLabel(unit: FormatBytesUnit, convertedValue: number): string {\n const labels = this.display === 'binary' ? BINARY_LABELS[unit] : DECIMAL_LABELS[unit];\n if (this.unitDisplay === 'short') return labels.short;\n return Math.abs(convertedValue) === 1 ? labels.singular : labels.plural;\n }\n\n #hasValidConfiguration(): boolean {\n return isDisplay(this.display) && isUnitDisplay(this.unitDisplay) && (this.unit === undefined || isUnit(this.unit));\n }\n\n get #numberFormatOptions(): Intl.NumberFormatOptions {\n const effectiveMaximumFractionDigits = this.maximumFractionDigits ?? Math.max(this.minimumFractionDigits ?? 0, 2);\n return {\n minimumFractionDigits: this.minimumFractionDigits,\n maximumFractionDigits: effectiveMaximumFractionDigits\n };\n }\n\n #roundNumber(value: number): number {\n return Number(\n new Intl.NumberFormat('en-US-u-nu-latn', {\n ...this.#numberFormatOptions,\n useGrouping: false\n }).format(value)\n );\n }\n\n #formatNumber(value: number): string {\n return new Intl.NumberFormat(this.#resolvedLocale, this.#numberFormatOptions).format(value);\n }\n\n get #formattedBytes(): string {\n const rawValue = this.#rawValue;\n if (!rawValue) return '';\n\n const numericValue = this.#parsedValue;\n if (numericValue === null) return rawValue;\n if (!this.#hasValidConfiguration()) return rawValue;\n\n const resolvedUnit = this.unit ?? this.#resolveAutoUnit(numericValue, this.display);\n const unitIndex = UNITS.indexOf(resolvedUnit);\n const base = this.display === 'binary' ? 1024 : 1000;\n const convertedValue = numericValue / base ** unitIndex;\n\n try {\n const roundedValue = this.#roundNumber(convertedValue);\n return `${this.#formatNumber(roundedValue)} ${this.#formatLabel(resolvedUnit, roundedValue)}`;\n } catch {\n return rawValue;\n }\n }\n\n render() {\n return html`<data internal-host value=${this.#rawValue}>${this.#formattedBytes}<slot @slotchange=${this.#onSlotChange} hidden></slot></data>`;\n }\n\n #onSlotChange() {\n this.requestUpdate();\n }\n}\n"],"mappings":";;;;;;;AAkBA,IAAM,IAAoC;CAAC;CAAK;CAAM;CAAM;CAAM;CAAM;AAAI,GACtE,IAA0C,CAAC,WAAW,QAAQ,GAC9D,IAAmD,CAAC,SAAS,MAAM,GAEnE,IAAsD;CAC1D,GAAG;EAAE,OAAO;EAAK,UAAU;EAAQ,QAAQ;CAAQ;CACnD,IAAI;EAAE,OAAO;EAAM,UAAU;EAAY,QAAQ;CAAY;CAC7D,IAAI;EAAE,OAAO;EAAM,UAAU;EAAY,QAAQ;CAAY;CAC7D,IAAI;EAAE,OAAO;EAAM,UAAU;EAAY,QAAQ;CAAY;CAC7D,IAAI;EAAE,OAAO;EAAM,UAAU;EAAY,QAAQ;CAAY;CAC7D,IAAI;EAAE,OAAO;EAAM,UAAU;EAAY,QAAQ;CAAY;AAC/D,GAEM,IAAqD;CACzD,GAAG;EAAE,OAAO;EAAK,UAAU;EAAQ,QAAQ;CAAQ;CACnD,IAAI;EAAE,OAAO;EAAO,UAAU;EAAY,QAAQ;CAAY;CAC9D,IAAI;EAAE,OAAO;EAAO,UAAU;EAAY,QAAQ;CAAY;CAC9D,IAAI;EAAE,OAAO;EAAO,UAAU;EAAY,QAAQ;CAAY;CAC9D,IAAI;EAAE,OAAO;EAAO,UAAU;EAAY,QAAQ;CAAY;CAC9D,IAAI;EAAE,OAAO;EAAO,UAAU;EAAY,QAAQ;CAAY;AAChE;AAEA,SAAS,EAAU,GAA6C;CAC9D,OAAO,EAAS,MAAK,MAAW,MAAY,CAAK;AACnD;AAEA,SAAS,EAAO,GAA0C;CACxD,OAAO,EAAM,MAAK,MAAQ,MAAS,CAAK;AAC1C;AAEA,SAAS,EAAc,GAAiD;CACtE,OAAO,EAAc,MAAK,MAA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Q,WAAW;AAAe,CAAC,CAAA,GAAA,EAAA,WAAA,eAAA,KAAA,CAAA,GAMpD,EAAA,CAAA,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,UAAA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAA0B,CAAC,CAAA,GAAA,EAAA,WAAA,yBAAA,KAAA,CAAA,GAK/D,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAA0B,CAAC,CAAA,GAAA,EAAA,WAAA,yBAAA,KAAA,CAAA,GA7CjE,IAAA,EAAA,CAAA,EAAQ,CAAA,GAAA,CAAA"}
@@ -1,19 +1,18 @@
1
- import { LogService as e } from "../internal/services/log.service.js";
2
- import { typeSSR as t } from "../internal/controllers/type-ssr.controller.js";
3
- import { useStyles as n } from "../internal/styles/index.js";
4
- import r from "../_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/decorate.js";
5
- import i from "./format-datetime.js";
6
- import { LitElement as a, html as o } from "lit";
7
- import { property as s } from "lit/decorators/property.js";
1
+ import { typeSSR as e } from "../internal/controllers/type-ssr.controller.js";
2
+ import { useStyles as t } from "../internal/styles/index.js";
3
+ import n from "../_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/decorate.js";
4
+ import r from "./format-datetime.js";
5
+ import { LitElement as i, html as a } from "lit";
6
+ import { property as o } from "lit/decorators/property.js";
8
7
  //#region src/format-datetime/format-datetime.ts
9
- var c = class extends a {
8
+ var s = class extends i {
10
9
  static {
11
- this.styles = n([i]);
10
+ this.styles = t([r]);
12
11
  }
13
12
  static {
14
13
  this.metadata = {
15
14
  tag: "nve-format-datetime",
16
- version: "2.18.1"
15
+ version: "2.18.2"
17
16
  };
18
17
  }
19
18
  get #e() {
@@ -23,14 +22,14 @@ var c = class extends a {
23
22
  return this.locale ?? (globalThis.document?.documentElement?.lang || void 0);
24
23
  }
25
24
  get #n() {
26
- let t = this.#e;
27
- if (!t) return "";
28
- let n = this.#s(t);
29
- if (!n) return t;
25
+ let e = this.#e;
26
+ if (!e) return "";
27
+ let t = this.#s(e);
28
+ if (!t) return e;
30
29
  try {
31
- return new Intl.DateTimeFormat(this.#t, this.#r).format(n);
32
- } catch (n) {
33
- return e.warn(`format-datetime: ${n.message}`), t;
30
+ return new Intl.DateTimeFormat(this.#t, this.#r).format(t);
31
+ } catch {
32
+ return e;
34
33
  }
35
34
  }
36
35
  get #r() {
@@ -47,31 +46,31 @@ var c = class extends a {
47
46
  let e = {};
48
47
  return this.weekday && (e.weekday = this.weekday), this.year && (e.year = this.year), this.month && (e.month = this.month), this.day && (e.day = this.day), this.hour && (e.hour = this.hour), this.minute && (e.minute = this.minute), this.second && (e.second = this.second), this.timeZoneName && (e.timeZoneName = this.timeZoneName), this.timeZone && (e.timeZone = this.timeZone), e;
49
48
  }
50
- #s(t) {
51
- let n = new Date(t);
52
- return isNaN(n.getTime()) ? (e.warn(`format-datetime: invalid date value "${t}"`), null) : n;
49
+ #s(e) {
50
+ let t = new Date(e);
51
+ return isNaN(t.getTime()) ? null : t;
53
52
  }
54
53
  render() {
55
- return o`<time internal-host datetime="${this.#e}">${this.#n}<slot @slotchange="${this.#c}" hidden></slot></time>`;
54
+ return a`<time internal-host datetime="${this.#e}">${this.#n}<slot @slotchange="${this.#c}" hidden></slot></time>`;
56
55
  }
57
56
  #c() {
58
57
  this.requestUpdate();
59
58
  }
60
59
  };
61
- r([s({ type: String })], c.prototype, "date", void 0), r([s({ type: String })], c.prototype, "locale", void 0), r([s({ type: String })], c.prototype, "weekday", void 0), r([s({ type: String })], c.prototype, "year", void 0), r([s({ type: String })], c.prototype, "month", void 0), r([s({ type: String })], c.prototype, "day", void 0), r([s({ type: String })], c.prototype, "hour", void 0), r([s({ type: String })], c.prototype, "minute", void 0), r([s({ type: String })], c.prototype, "second", void 0), r([s({
60
+ n([o({ type: String })], s.prototype, "date", void 0), n([o({ type: String })], s.prototype, "locale", void 0), n([o({ type: String })], s.prototype, "weekday", void 0), n([o({ type: String })], s.prototype, "year", void 0), n([o({ type: String })], s.prototype, "month", void 0), n([o({ type: String })], s.prototype, "day", void 0), n([o({ type: String })], s.prototype, "hour", void 0), n([o({ type: String })], s.prototype, "minute", void 0), n([o({ type: String })], s.prototype, "second", void 0), n([o({
62
61
  type: String,
63
62
  attribute: "date-style"
64
- })], c.prototype, "dateStyle", void 0), r([s({
63
+ })], s.prototype, "dateStyle", void 0), n([o({
65
64
  type: String,
66
65
  attribute: "time-style"
67
- })], c.prototype, "timeStyle", void 0), r([s({
66
+ })], s.prototype, "timeStyle", void 0), n([o({
68
67
  type: String,
69
68
  attribute: "time-zone-name"
70
- })], c.prototype, "timeZoneName", void 0), r([s({
69
+ })], s.prototype, "timeZoneName", void 0), n([o({
71
70
  type: String,
72
71
  attribute: "time-zone"
73
- })], c.prototype, "timeZone", void 0), c = r([t()], c);
72
+ })], s.prototype, "timeZone", void 0), s = n([e()], s);
74
73
  //#endregion
75
- export { c as FormatDatetime };
74
+ export { s as FormatDatetime };
76
75
 
77
76
  //# sourceMappingURL=format-datetime2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-datetime2.js","names":[],"sources":["../../src/format-datetime/format-datetime.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { useStyles, typeSSR, LogService } from '@nvidia-elements/core/internal';\nimport styles from './format-datetime.css?inline';\n\n/**\n * @element nve-format-datetime\n * @description Formats a date/time value as localized text using the Intl.DateTimeFormat API. Renders inside a semantic time element.\n * Granular options (weekday, year, month, day, hour, minute, second) mirror the Intl.DateTimeFormat API. 'numeric' omits zero-padding, '2-digit' zero-pads.\n * @documentation https://nvidia.github.io/elements/docs/elements/format-datetime/\n * @since 0.0.0\n * @entrypoint \\@nvidia-elements/core/format-datetime\n * @slot - Date string to format (such as 2023-07-28T04:20:17.434Z). Serves as fallback before hydration.\n * @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time\n */\n@typeSSR()\nexport class FormatDatetime extends LitElement {\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-format-datetime',\n version: '0.0.0'\n };\n\n /**\n * Optional date string for values supplied by JavaScript or bound data.\n * By default, the component formats the element's text content, which also serves as the SSR fallback.\n * When both are present, this property takes precedence.\n */\n @property({ type: String }) date?: string;\n\n /**\n * Language tag (such as en-US, de-DE). Defaults to document.documentElement.lang or browser default.\n */\n @property({ type: String }) locale?: string;\n\n /**\n * Weekday representation: 'long' | 'short' | 'narrow'.\n */\n @property({ type: String }) weekday?: 'long' | 'short' | 'narrow';\n\n /**\n * Year representation: 'numeric' | '2-digit'.\n */\n @property({ type: String }) year?: 'numeric' | '2-digit';\n\n /**\n * Month representation: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow'.\n */\n @property({ type: String }) month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow';\n\n /**\n * Day representation: 'numeric' | '2-digit'.\n */\n @property({ type: String }) day?: 'numeric' | '2-digit';\n\n /**\n * Hour representation: 'numeric' | '2-digit'.\n */\n @property({ type: String }) hour?: 'numeric' | '2-digit';\n\n /**\n * Minute representation: 'numeric' | '2-digit'.\n */\n @property({ type: String }) minute?: 'numeric' | '2-digit';\n\n /**\n * Second representation: 'numeric' | '2-digit'.\n */\n @property({ type: String }) second?: 'numeric' | '2-digit';\n\n /**\n * Preset date formatting style: 'full' | 'long' | 'medium' | 'short'.\n * Preset styles take precedence over granular date and time part options.\n */\n @property({ type: String, attribute: 'date-style' }) dateStyle?: 'full' | 'long' | 'medium' | 'short';\n\n /**\n * Preset time formatting style: 'full' | 'long' | 'medium' | 'short'.\n * Preset styles take precedence over granular date and time part options.\n */\n @property({ type: String, attribute: 'time-style' }) timeStyle?: 'full' | 'long' | 'medium' | 'short';\n\n /**\n * Time zone name display: 'long' | 'short'. Use it with granular options only; preset styles ignore it.\n */\n @property({ type: String, attribute: 'time-zone-name' }) timeZoneName?: 'long' | 'short';\n\n /**\n * IANA time zone identifier (such as 'America/New_York', 'UTC').\n */\n @property({ type: String, attribute: 'time-zone' }) timeZone?: string;\n\n get #dateValue(): string {\n return this.date ?? this.textContent?.trim() ?? '';\n }\n\n get #resolvedLocale(): string | undefined {\n return this.locale ?? (globalThis.document?.documentElement?.lang || undefined);\n }\n\n get #formattedDate(): string {\n const iso = this.#dateValue;\n if (!iso) return '';\n\n const date = this.#parseDate(iso);\n if (!date) return iso;\n\n try {\n return new Intl.DateTimeFormat(this.#resolvedLocale, this.#formatOptions).format(date);\n } catch (e) {\n LogService.warn(`format-datetime: ${(e as Error).message}`);\n return iso;\n }\n }\n\n get #formatOptions(): Intl.DateTimeFormatOptions {\n return this.#hasPresetStyle ? this.#presetFormatOptions : this.#granularFormatOptions;\n }\n\n get #hasPresetStyle(): boolean {\n return this.dateStyle !== undefined || this.timeStyle !== undefined;\n }\n\n get #presetFormatOptions(): Intl.DateTimeFormatOptions {\n const options: Intl.DateTimeFormatOptions = {};\n\n if (this.dateStyle) options.dateStyle = this.dateStyle;\n if (this.timeStyle) options.timeStyle = this.timeStyle;\n if (this.timeZone) options.timeZone = this.timeZone;\n\n return options;\n }\n\n get #granularFormatOptions(): Intl.DateTimeFormatOptions {\n const options: Intl.DateTimeFormatOptions = {};\n\n if (this.weekday) options.weekday = this.weekday;\n if (this.year) options.year = this.year;\n if (this.month) options.month = this.month;\n if (this.day) options.day = this.day;\n if (this.hour) options.hour = this.hour;\n if (this.minute) options.minute = this.minute;\n if (this.second) options.second = this.second;\n if (this.timeZoneName) options.timeZoneName = this.timeZoneName;\n if (this.timeZone) options.timeZone = this.timeZone;\n\n return options;\n }\n\n #parseDate(iso: string): Date | null {\n const date = new Date(iso);\n if (!isNaN(date.getTime())) return date;\n\n LogService.warn(`format-datetime: invalid date value \"${iso}\"`);\n return null;\n }\n\n render() {\n return html`<time internal-host datetime=${this.#dateValue}>${this.#formattedDate}<slot @slotchange=${this.#onSlotChange} hidden></slot></time>`;\n }\n\n #onSlotChange() {\n this.requestUpdate();\n }\n}\n"],"mappings":";;;;;;;;AAmBO,IAAM,IAAN,cAA6B,EAAW;;EAC7B,KAAA,SAAA,EAAU,CAAC,CAAM,CAAC;;;EAEP,KAAA,WAAA;GACzB,KAAK;GACL,SAAS;EACX;;CAuEA,IAAI,KAAqB;EACvB,OAAO,KAAK,QAAQ,KAAK,aAAa,KAAK,KAAK;CAClD;CAEA,IAAI,KAAsC;EACxC,OAAO,KAAK,WAAW,WAAW,UAAU,iBAAiB,QAAQ,KAAA;CACvE;CAEA,IAAI,KAAyB;EAC3B,IAAM,IAAM,KAAK;EACjB,IAAI,CAAC,GAAK,OAAO;EAEjB,IAAM,IAAO,KAAK,GAAW,CAAG;EAChC,IAAI,CAAC,GAAM,OAAO;EAElB,IAAI;GACF,OAAO,IAAI,KAAK,eAAe,KAAK,IAAiB,KAAK,EAAc,CAAC,CAAC,OAAO,CAAI;EACvF,SAAS,GAAG;GAEV,OADA,EAAW,KAAK,oBAAqB,EAAY,SAAS,GACnD;EACT;CACF;CAEA,IAAI,KAA6C;EAC/C,OAAO,KAAK,KAAkB,KAAK,KAAuB,KAAK;CACjE;CAEA,IAAI,KAA2B;EAC7B,OAAO,KAAK,cAAc,KAAA,KAAa,KAAK,cAAc,KAAA;CAC5D;CAEA,IAAI,KAAmD;EACrD,IAAM,IAAsC,CAAC;EAM7C,OAJI,KAAK,cAAW,EAAQ,YAAY,KAAK,YACzC,KAAK,cAAW,EAAQ,YAAY,KAAK,YACzC,KAAK,aAAU,EAAQ,WAAW,KAAK,WAEpC;CACT;CAEA,IAAI,KAAqD;EACvD,IAAM,IAAsC,CAAC;EAY7C,OAVI,KAAK,YAAS,EAAQ,UAAU,KAAK,UACrC,KAAK,SAAM,EAAQ,OAAO,KAAK,OAC/B,KAAK,UAAO,EAAQ,QAAQ,KAAK,QACjC,KAAK,QAAK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AA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,UAAA,KAAA,CAAA,GAMzB,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAa,CAAC,CAAA,GAAA,EAAA,WAAA,aAAA,KAAA,CAAA,GAMlD,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAa,CAAC,CAAA,GAAA,EAAA,WAAA,aAAA,KAAA,CAAA,GAKlD,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAiB,CAAC,CAAA,GAAA,EAAA,WAAA,gBAAA,KAAA,CAAA,GAKtD,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAY,CAAC,CAAA,GAAA,EAAA,WAAA,YAAA,KAAA,CAAA,GA5EnD,IAAA,EAAA,CAAA,EAAQ,CAAA,GAAA,CAAA"}
1
+ {"version":3,"file":"format-datetime2.js","names":[],"sources":["../../src/format-datetime/format-datetime.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { useStyles, typeSSR } from '@nvidia-elements/core/internal';\nimport styles from './format-datetime.css?inline';\n\n/**\n * @element nve-format-datetime\n * @description Formats a date/time value as localized text using the Intl.DateTimeFormat API. Renders inside a semantic time element.\n * Granular options (weekday, year, month, day, hour, minute, second) mirror the Intl.DateTimeFormat API. 'numeric' omits zero-padding, '2-digit' zero-pads.\n * @documentation https://nvidia.github.io/elements/docs/elements/format-datetime/\n * @since 0.0.0\n * @entrypoint \\@nvidia-elements/core/format-datetime\n * @slot - Date string to format (such as 2023-07-28T04:20:17.434Z). Serves as fallback before hydration.\n * @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time\n */\n@typeSSR()\nexport class FormatDatetime extends LitElement {\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-format-datetime',\n version: '0.0.0'\n };\n\n /**\n * Optional date string for values supplied by JavaScript or bound data.\n * By default, the component formats the element's text content, which also serves as the SSR fallback.\n * When both are present, this property takes precedence.\n */\n @property({ type: String }) date?: string;\n\n /**\n * Language tag (such as en-US, de-DE). Defaults to document.documentElement.lang or browser default.\n */\n @property({ type: String }) locale?: string;\n\n /**\n * Weekday representation: 'long' | 'short' | 'narrow'.\n */\n @property({ type: String }) weekday?: 'long' | 'short' | 'narrow';\n\n /**\n * Year representation: 'numeric' | '2-digit'.\n */\n @property({ type: String }) year?: 'numeric' | '2-digit';\n\n /**\n * Month representation: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow'.\n */\n @property({ type: String }) month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow';\n\n /**\n * Day representation: 'numeric' | '2-digit'.\n */\n @property({ type: String }) day?: 'numeric' | '2-digit';\n\n /**\n * Hour representation: 'numeric' | '2-digit'.\n */\n @property({ type: String }) hour?: 'numeric' | '2-digit';\n\n /**\n * Minute representation: 'numeric' | '2-digit'.\n */\n @property({ type: String }) minute?: 'numeric' | '2-digit';\n\n /**\n * Second representation: 'numeric' | '2-digit'.\n */\n @property({ type: String }) second?: 'numeric' | '2-digit';\n\n /**\n * Preset date formatting style: 'full' | 'long' | 'medium' | 'short'.\n * Preset styles take precedence over granular date and time part options.\n */\n @property({ type: String, attribute: 'date-style' }) dateStyle?: 'full' | 'long' | 'medium' | 'short';\n\n /**\n * Preset time formatting style: 'full' | 'long' | 'medium' | 'short'.\n * Preset styles take precedence over granular date and time part options.\n */\n @property({ type: String, attribute: 'time-style' }) timeStyle?: 'full' | 'long' | 'medium' | 'short';\n\n /**\n * Time zone name display: 'long' | 'short'. Use it with granular options only; preset styles ignore it.\n */\n @property({ type: String, attribute: 'time-zone-name' }) timeZoneName?: 'long' | 'short';\n\n /**\n * IANA time zone identifier (such as 'America/New_York', 'UTC').\n */\n @property({ type: String, attribute: 'time-zone' }) timeZone?: string;\n\n get #dateValue(): string {\n return this.date ?? this.textContent?.trim() ?? '';\n }\n\n get #resolvedLocale(): string | undefined {\n return this.locale ?? (globalThis.document?.documentElement?.lang || undefined);\n }\n\n get #formattedDate(): string {\n const iso = this.#dateValue;\n if (!iso) return '';\n\n const date = this.#parseDate(iso);\n if (!date) return iso;\n\n try {\n return new Intl.DateTimeFormat(this.#resolvedLocale, this.#formatOptions).format(date);\n } catch {\n return iso;\n }\n }\n\n get #formatOptions(): Intl.DateTimeFormatOptions {\n return this.#hasPresetStyle ? this.#presetFormatOptions : this.#granularFormatOptions;\n }\n\n get #hasPresetStyle(): boolean {\n return this.dateStyle !== undefined || this.timeStyle !== undefined;\n }\n\n get #presetFormatOptions(): Intl.DateTimeFormatOptions {\n const options: Intl.DateTimeFormatOptions = {};\n\n if (this.dateStyle) options.dateStyle = this.dateStyle;\n if (this.timeStyle) options.timeStyle = this.timeStyle;\n if (this.timeZone) options.timeZone = this.timeZone;\n\n return options;\n }\n\n get #granularFormatOptions(): Intl.DateTimeFormatOptions {\n const options: Intl.DateTimeFormatOptions = {};\n\n if (this.weekday) options.weekday = this.weekday;\n if (this.year) options.year = this.year;\n if (this.month) options.month = this.month;\n if (this.day) options.day = this.day;\n if (this.hour) options.hour = this.hour;\n if (this.minute) options.minute = this.minute;\n if (this.second) options.second = this.second;\n if (this.timeZoneName) options.timeZoneName = this.timeZoneName;\n if (this.timeZone) options.timeZone = this.timeZone;\n\n return options;\n }\n\n #parseDate(iso: string): Date | null {\n const date = new Date(iso);\n if (!isNaN(date.getTime())) return date;\n\n return null;\n }\n\n render() {\n return html`<time internal-host datetime=${this.#dateValue}>${this.#formattedDate}<slot @slotchange=${this.#onSlotChange} hidden></slot></time>`;\n }\n\n #onSlotChange() {\n this.requestUpdate();\n }\n}\n"],"mappings":";;;;;;;AAmBO,IAAM,IAAN,cAA6B,EAAW;;EAC7B,KAAA,SAAA,EAAU,CAAC,CA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AA,GAAA,EAAA,WAAA,aAAA,KAAA,CAAA,GAKlD,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAiB,CAAC,CAAA,GAAA,EAAA,WAAA,gBAAA,KAAA,CAAA,GAKtD,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAY,CAAC,CAAA,GAAA,EAAA,WAAA,YAAA,KAAA,CAAA,GA5EnD,IAAA,EAAA,CAAA,EAAQ,CAAA,GAAA,CAAA"}
@@ -74,11 +74,11 @@ export declare class FormatNumber extends LitElement {
74
74
  */
75
75
  useGrouping?: 'auto' | 'always' | 'min2' | 'true' | 'false' | boolean;
76
76
  /**
77
- * Pad fraction output to at least this many digits (0-20).
77
+ * Pad fraction output to at least this many digits (0-100).
78
78
  */
79
79
  minimumFractionDigits?: number;
80
80
  /**
81
- * Round fraction output to at most this many digits (0-20).
81
+ * Round fraction output to at most this many digits (0-100).
82
82
  */
83
83
  maximumFractionDigits?: number;
84
84
  /**
@@ -1,12 +1,11 @@
1
- import { LogService as e } from "../internal/services/log.service.js";
2
- import { typeSSR as t } from "../internal/controllers/type-ssr.controller.js";
3
- import { useStyles as n } from "../internal/styles/index.js";
4
- import r from "../_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/decorate.js";
5
- import i from "./format-number.js";
6
- import { LitElement as a, html as o } from "lit";
7
- import { property as s } from "lit/decorators/property.js";
1
+ import { typeSSR as e } from "../internal/controllers/type-ssr.controller.js";
2
+ import { useStyles as t } from "../internal/styles/index.js";
3
+ import n from "../_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/decorate.js";
4
+ import r from "./format-number.js";
5
+ import { LitElement as i, html as a } from "lit";
6
+ import { property as o } from "lit/decorators/property.js";
8
7
  //#region src/format-number/format-number.ts
9
- var c = [
8
+ var s = [
10
9
  ["currency", "currency"],
11
10
  ["currencyDisplay", "currencyDisplay"],
12
11
  ["currencySign", "currencySign"],
@@ -15,21 +14,21 @@ var c = [
15
14
  ["unit", "unit"],
16
15
  ["unitDisplay", "unitDisplay"],
17
16
  ["signDisplay", "signDisplay"]
18
- ], l = [
17
+ ], c = [
19
18
  ["minimumFractionDigits", "minimumFractionDigits"],
20
19
  ["maximumFractionDigits", "maximumFractionDigits"],
21
20
  ["minimumIntegerDigits", "minimumIntegerDigits"]
22
- ], u = class extends a {
21
+ ], l = class extends i {
23
22
  constructor(...e) {
24
23
  super(...e), this.formatStyle = "decimal";
25
24
  }
26
25
  static {
27
- this.styles = n([i]);
26
+ this.styles = t([r]);
28
27
  }
29
28
  static {
30
29
  this.metadata = {
31
30
  tag: "nve-format-number",
32
- version: "2.18.1"
31
+ version: "2.18.2"
33
32
  };
34
33
  }
35
34
  get #e() {
@@ -39,73 +38,73 @@ var c = [
39
38
  return this.locale ?? (globalThis.document?.documentElement?.lang || void 0);
40
39
  }
41
40
  get #n() {
42
- let t = this.#e;
43
- if (!t) return null;
44
- let n = Number(t);
45
- return Number.isFinite(n) ? n : (e.warn(`format-number: invalid numeric value "${t}"`), null);
41
+ let e = this.#e;
42
+ if (!e) return null;
43
+ let t = Number(e);
44
+ return Number.isFinite(t) ? t : null;
46
45
  }
47
46
  get #r() {
48
47
  let e = { style: this.formatStyle };
49
- for (let [t, n] of c) {
48
+ for (let [t, n] of s) {
50
49
  let r = this[t];
51
50
  r !== void 0 && (e[n] = r);
52
51
  }
53
- for (let [t, n] of l) {
52
+ for (let [t, n] of c) {
54
53
  let r = this[t];
55
54
  r !== void 0 && (e[n] = r);
56
55
  }
57
56
  return this.useGrouping !== void 0 && (e.useGrouping = this.useGrouping === "false" ? !1 : this.useGrouping === "true" || this.useGrouping), e;
58
57
  }
59
58
  get #i() {
60
- let t = this.#e;
61
- if (!t) return "";
62
- let n = this.#n;
63
- if (n === null) return t;
59
+ let e = this.#e;
60
+ if (!e) return "";
61
+ let t = this.#n;
62
+ if (t === null) return e;
64
63
  try {
65
- return new Intl.NumberFormat(this.#t, this.#r).format(n);
66
- } catch (n) {
67
- return e.warn(`format-number: ${n.message}`), t;
64
+ return new Intl.NumberFormat(this.#t, this.#r).format(t);
65
+ } catch {
66
+ return e;
68
67
  }
69
68
  }
70
69
  render() {
71
- return o`<data internal-host value="${this.#e}">${this.#i}<slot @slotchange="${this.#a}" hidden></slot></data>`;
70
+ return a`<data internal-host value="${this.#e}">${this.#i}<slot @slotchange="${this.#a}" hidden></slot></data>`;
72
71
  }
73
72
  #a() {
74
73
  this.requestUpdate();
75
74
  }
76
75
  };
77
- r([s({ type: String })], u.prototype, "number", void 0), r([s({ type: String })], u.prototype, "locale", void 0), r([s({
76
+ n([o({ type: String })], l.prototype, "number", void 0), n([o({ type: String })], l.prototype, "locale", void 0), n([o({
78
77
  type: String,
79
78
  attribute: "format-style"
80
- })], u.prototype, "formatStyle", void 0), r([s({ type: String })], u.prototype, "currency", void 0), r([s({
79
+ })], l.prototype, "formatStyle", void 0), n([o({ type: String })], l.prototype, "currency", void 0), n([o({
81
80
  type: String,
82
81
  attribute: "currency-sign"
83
- })], u.prototype, "currencySign", void 0), r([s({
82
+ })], l.prototype, "currencySign", void 0), n([o({
84
83
  type: String,
85
84
  attribute: "currency-display"
86
- })], u.prototype, "currencyDisplay", void 0), r([s({ type: String })], u.prototype, "unit", void 0), r([s({
85
+ })], l.prototype, "currencyDisplay", void 0), n([o({ type: String })], l.prototype, "unit", void 0), n([o({
87
86
  type: String,
88
87
  attribute: "unit-display"
89
- })], u.prototype, "unitDisplay", void 0), r([s({ type: String })], u.prototype, "notation", void 0), r([s({
88
+ })], l.prototype, "unitDisplay", void 0), n([o({ type: String })], l.prototype, "notation", void 0), n([o({
90
89
  type: String,
91
90
  attribute: "compact-display"
92
- })], u.prototype, "compactDisplay", void 0), r([s({
91
+ })], l.prototype, "compactDisplay", void 0), n([o({
93
92
  type: String,
94
93
  attribute: "sign-display"
95
- })], u.prototype, "signDisplay", void 0), r([s({
94
+ })], l.prototype, "signDisplay", void 0), n([o({
96
95
  type: String,
97
96
  attribute: "use-grouping"
98
- })], u.prototype, "useGrouping", void 0), r([s({
97
+ })], l.prototype, "useGrouping", void 0), n([o({
99
98
  type: Number,
100
99
  attribute: "minimum-fraction-digits"
101
- })], u.prototype, "minimumFractionDigits", void 0), r([s({
100
+ })], l.prototype, "minimumFractionDigits", void 0), n([o({
102
101
  type: Number,
103
102
  attribute: "maximum-fraction-digits"
104
- })], u.prototype, "maximumFractionDigits", void 0), r([s({
103
+ })], l.prototype, "maximumFractionDigits", void 0), n([o({
105
104
  type: Number,
106
105
  attribute: "minimum-integer-digits"
107
- })], u.prototype, "minimumIntegerDigits", void 0), u = r([t()], u);
106
+ })], l.prototype, "minimumIntegerDigits", void 0), l = n([e()], l);
108
107
  //#endregion
109
- export { u as FormatNumber };
108
+ export { l as FormatNumber };
110
109
 
111
110
  //# sourceMappingURL=format-number2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-number2.js","names":[],"sources":["../../src/format-number/format-number.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { useStyles, typeSSR, LogService } from '@nvidia-elements/core/internal';\nimport styles from './format-number.css?inline';\n\nexport type FormatNumberStyle = 'decimal' | 'currency' | 'percent' | 'unit';\nexport type CurrencyDisplayOption = 'symbol' | 'code' | 'name' | 'narrowSymbol';\nexport type CurrencySignOption = 'standard' | 'accounting';\nexport type NotationOption = 'standard' | 'scientific' | 'engineering' | 'compact';\nexport type CompactDisplayOption = 'short' | 'long';\nexport type UnitDisplayOption = 'short' | 'long' | 'narrow';\nexport type SignDisplayOption = 'auto' | 'never' | 'always' | 'exceptZero';\n\nconst STRING_KEYS: [keyof FormatNumber, string][] = [\n ['currency', 'currency'],\n ['currencyDisplay', 'currencyDisplay'],\n ['currencySign', 'currencySign'],\n ['notation', 'notation'],\n ['compactDisplay', 'compactDisplay'],\n ['unit', 'unit'],\n ['unitDisplay', 'unitDisplay'],\n ['signDisplay', 'signDisplay']\n];\n\nconst NUMBER_KEYS: [keyof FormatNumber, string][] = [\n ['minimumFractionDigits', 'minimumFractionDigits'],\n ['maximumFractionDigits', 'maximumFractionDigits'],\n ['minimumIntegerDigits', 'minimumIntegerDigits']\n];\n\n/**\n * @element nve-format-number\n * @description A localized number formatter for currencies, percentages, units, and compact notation, backed by Intl.NumberFormat.\n * Provide a `currency` attribute when `formatStyle` is `currency`, and a `unit` attribute when `formatStyle` is `unit`.\n * @documentation https://nvidia.github.io/elements/docs/elements/format-number/\n * @since 0.0.0\n * @entrypoint \\@nvidia-elements/core/format-number\n * @slot - Numeric string to format (such as 1234567 or 1234.56). Serves as fallback before hydration.\n * @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/data\n */\n@typeSSR()\nexport class FormatNumber extends LitElement {\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-format-number',\n version: '0.0.0'\n };\n\n /**\n * Optional numeric string for values supplied by JavaScript or bound data.\n * By default, the component formats the element's text content, which also serves as the SSR fallback.\n * When both are present, this property takes precedence.\n */\n @property({ type: String }) number?: string;\n\n /**\n * Language tag (such as en-US, de-DE). Defaults to document.documentElement.lang or browser default.\n */\n @property({ type: String }) locale?: string;\n\n /**\n * Formatting style: 'decimal' | 'currency' | 'percent' | 'unit'.\n */\n @property({ type: String, attribute: 'format-style' }) formatStyle: FormatNumberStyle = 'decimal';\n\n /**\n * ISO 4217 currency code (such as USD or EUR). Required when formatStyle is currency.\n */\n @property({ type: String }) currency?: string;\n\n /**\n * Currency sign style: 'standard' | 'accounting'.\n */\n @property({ type: String, attribute: 'currency-sign' }) currencySign?: CurrencySignOption;\n\n /**\n * Currency display style: 'symbol' | 'code' | 'name' | 'narrowSymbol'.\n */\n @property({ type: String, attribute: 'currency-display' }) currencyDisplay?: CurrencyDisplayOption;\n\n /**\n * Unit identifier (such as kilometer or byte). Required when formatStyle is unit.\n */\n @property({ type: String }) unit?: string;\n\n /**\n * Unit display style: 'short' | 'long' | 'narrow'.\n */\n @property({ type: String, attribute: 'unit-display' }) unitDisplay?: UnitDisplayOption;\n\n /**\n * Number notation: 'standard' | 'scientific' | 'engineering' | 'compact'.\n */\n @property({ type: String }) notation?: NotationOption;\n\n /**\n * Compact notation display: 'short' | 'long'. Only applies when notation is compact.\n */\n @property({ type: String, attribute: 'compact-display' }) compactDisplay?: CompactDisplayOption;\n\n /**\n * Sign display: 'auto' | 'never' | 'always' | 'exceptZero'.\n */\n @property({ type: String, attribute: 'sign-display' }) signDisplay?: SignDisplayOption;\n\n /**\n * Grouping separators: 'auto' | 'always' | 'min2' | 'true' | 'false'.\n */\n @property({ type: String, attribute: 'use-grouping' })\n useGrouping?: 'auto' | 'always' | 'min2' | 'true' | 'false' | boolean;\n\n /**\n * Pad fraction output to at least this many digits (0-20).\n */\n @property({ type: Number, attribute: 'minimum-fraction-digits' }) minimumFractionDigits?: number;\n\n /**\n * Round fraction output to at most this many digits (0-20).\n */\n @property({ type: Number, attribute: 'maximum-fraction-digits' }) maximumFractionDigits?: number;\n\n /**\n * Pad integer output to at least this many digits (1-21).\n */\n @property({ type: Number, attribute: 'minimum-integer-digits' }) minimumIntegerDigits?: number;\n\n get #rawValue(): string {\n return this.number ?? this.textContent?.trim() ?? '';\n }\n\n get #resolvedLocale(): string | undefined {\n return this.locale ?? (globalThis.document?.documentElement?.lang || undefined);\n }\n\n get #parsedNumber(): number | null {\n const raw = this.#rawValue;\n if (!raw) return null;\n\n const numericValue = Number(raw);\n if (Number.isFinite(numericValue)) return numericValue;\n\n LogService.warn(`format-number: invalid numeric value \"${raw}\"`);\n return null;\n }\n\n get #formatOptions(): Intl.NumberFormatOptions {\n const options: Intl.NumberFormatOptions = { style: this.formatStyle };\n\n for (const [prop, key] of STRING_KEYS) {\n const value = this[prop] as string | undefined;\n if (value !== undefined) (options as Record<string, unknown>)[key] = value;\n }\n\n for (const [prop, key] of NUMBER_KEYS) {\n const value = this[prop] as number | undefined;\n if (value !== undefined) (options as Record<string, unknown>)[key] = value;\n }\n\n if (this.useGrouping !== undefined) {\n const grouping = this.useGrouping === 'false' ? false : this.useGrouping === 'true' ? true : this.useGrouping;\n (options as Record<string, unknown>).useGrouping = grouping;\n }\n\n return options;\n }\n\n get #formattedNumber(): string {\n const raw = this.#rawValue;\n if (!raw) return '';\n\n const numericValue = this.#parsedNumber;\n if (numericValue === null) return raw;\n\n try {\n return new Intl.NumberFormat(this.#resolvedLocale, this.#formatOptions).format(numericValue);\n } catch (e) {\n LogService.warn(`format-number: ${(e as Error).message}`);\n return raw;\n }\n }\n\n render() {\n return html`<data internal-host value=${this.#rawValue}>${this.#formattedNumber}<slot @slotchange=${this.#onSlotChange} hidden></slot></data>`;\n }\n\n #onSlotChange() {\n this.requestUpdate();\n }\n}\n"],"mappings":";;;;;;;;AAgBA,IAAM,IAA8C;CAClD,CAAC,YAAY,UAAU;CACvB,CAAC,mBAAmB,iBAAiB;CACrC,CAAC,gBAAgB,cAAc;CAC/B,CAAC,YAAY,UAAU;CACvB,CAAC,kBAAkB,gBAAgB;CACnC,CAAC,QAAQ,MAAM;CACf,CAAC,eAAe,aAAa;CAC7B,CAAC,eAAe,aAAa;AAC/B,GAEM,IAA8C;CAClD,CAAC,yBAAyB,uBAAuB;CACjD,CAAC,yBAAyB,uBAAuB;CACjD,CAAC,wBAAwB,sBAAsB;AACjD,GAaa,IAAN,cAA2B,EAAW;;EAuB6C,aAAA,KAAA,cAAA;;;EAtBxE,KAAA,SAAA,EAAU,CAAC,CAAM,CAAC;;;EAEP,KAAA,WAAA;GACzB,KAAK;GACL,SAAS;EACX;;CAgFA,IAAI,KAAoB;EACtB,OAAO,KAAK,UAAU,KAAK,aAAa,KAAK,KAAK;CACpD;CAEA,IAAI,KAAsC;EACxC,OAAO,KAAK,WAAW,WAAW,UAAU,iBAAiB,QAAQ,KAAA;CACvE;CAEA,IAAI,KAA+B;EACjC,IAAM,IAAM,KAAK;EACjB,IAAI,C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AC,CAAA,GAAA,EAAA,WAAA,wBAAA,KAAA,CAAA,GArFhE,IAAA,EAAA,CAAA,EAAQ,CAAA,GAAA,CAAA"}
1
+ {"version":3,"file":"format-number2.js","names":[],"sources":["../../src/format-number/format-number.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { useStyles, typeSSR } from '@nvidia-elements/core/internal';\nimport styles from './format-number.css?inline';\n\nexport type FormatNumberStyle = 'decimal' | 'currency' | 'percent' | 'unit';\nexport type CurrencyDisplayOption = 'symbol' | 'code' | 'name' | 'narrowSymbol';\nexport type CurrencySignOption = 'standard' | 'accounting';\nexport type NotationOption = 'standard' | 'scientific' | 'engineering' | 'compact';\nexport type CompactDisplayOption = 'short' | 'long';\nexport type UnitDisplayOption = 'short' | 'long' | 'narrow';\nexport type SignDisplayOption = 'auto' | 'never' | 'always' | 'exceptZero';\n\nconst STRING_KEYS: [keyof FormatNumber, string][] = [\n ['currency', 'currency'],\n ['currencyDisplay', 'currencyDisplay'],\n ['currencySign', 'currencySign'],\n ['notation', 'notation'],\n ['compactDisplay', 'compactDisplay'],\n ['unit', 'unit'],\n ['unitDisplay', 'unitDisplay'],\n ['signDisplay', 'signDisplay']\n];\n\nconst NUMBER_KEYS: [keyof FormatNumber, string][] = [\n ['minimumFractionDigits', 'minimumFractionDigits'],\n ['maximumFractionDigits', 'maximumFractionDigits'],\n ['minimumIntegerDigits', 'minimumIntegerDigits']\n];\n\n/**\n * @element nve-format-number\n * @description A localized number formatter for currencies, percentages, units, and compact notation, backed by Intl.NumberFormat.\n * Provide a `currency` attribute when `formatStyle` is `currency`, and a `unit` attribute when `formatStyle` is `unit`.\n * @documentation https://nvidia.github.io/elements/docs/elements/format-number/\n * @since 0.0.0\n * @entrypoint \\@nvidia-elements/core/format-number\n * @slot - Numeric string to format (such as 1234567 or 1234.56). Serves as fallback before hydration.\n * @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/data\n */\n@typeSSR()\nexport class FormatNumber extends LitElement {\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-format-number',\n version: '0.0.0'\n };\n\n /**\n * Optional numeric string for values supplied by JavaScript or bound data.\n * By default, the component formats the element's text content, which also serves as the SSR fallback.\n * When both are present, this property takes precedence.\n */\n @property({ type: String }) number?: string;\n\n /**\n * Language tag (such as en-US, de-DE). Defaults to document.documentElement.lang or browser default.\n */\n @property({ type: String }) locale?: string;\n\n /**\n * Formatting style: 'decimal' | 'currency' | 'percent' | 'unit'.\n */\n @property({ type: String, attribute: 'format-style' }) formatStyle: FormatNumberStyle = 'decimal';\n\n /**\n * ISO 4217 currency code (such as USD or EUR). Required when formatStyle is currency.\n */\n @property({ type: String }) currency?: string;\n\n /**\n * Currency sign style: 'standard' | 'accounting'.\n */\n @property({ type: String, attribute: 'currency-sign' }) currencySign?: CurrencySignOption;\n\n /**\n * Currency display style: 'symbol' | 'code' | 'name' | 'narrowSymbol'.\n */\n @property({ type: String, attribute: 'currency-display' }) currencyDisplay?: CurrencyDisplayOption;\n\n /**\n * Unit identifier (such as kilometer or byte). Required when formatStyle is unit.\n */\n @property({ type: String }) unit?: string;\n\n /**\n * Unit display style: 'short' | 'long' | 'narrow'.\n */\n @property({ type: String, attribute: 'unit-display' }) unitDisplay?: UnitDisplayOption;\n\n /**\n * Number notation: 'standard' | 'scientific' | 'engineering' | 'compact'.\n */\n @property({ type: String }) notation?: NotationOption;\n\n /**\n * Compact notation display: 'short' | 'long'. Only applies when notation is compact.\n */\n @property({ type: String, attribute: 'compact-display' }) compactDisplay?: CompactDisplayOption;\n\n /**\n * Sign display: 'auto' | 'never' | 'always' | 'exceptZero'.\n */\n @property({ type: String, attribute: 'sign-display' }) signDisplay?: SignDisplayOption;\n\n /**\n * Grouping separators: 'auto' | 'always' | 'min2' | 'true' | 'false'.\n */\n @property({ type: String, attribute: 'use-grouping' })\n useGrouping?: 'auto' | 'always' | 'min2' | 'true' | 'false' | boolean;\n\n /**\n * Pad fraction output to at least this many digits (0-100).\n */\n @property({ type: Number, attribute: 'minimum-fraction-digits' }) minimumFractionDigits?: number;\n\n /**\n * Round fraction output to at most this many digits (0-100).\n */\n @property({ type: Number, attribute: 'maximum-fraction-digits' }) maximumFractionDigits?: number;\n\n /**\n * Pad integer output to at least this many digits (1-21).\n */\n @property({ type: Number, attribute: 'minimum-integer-digits' }) minimumIntegerDigits?: number;\n\n get #rawValue(): string {\n return this.number ?? this.textContent?.trim() ?? '';\n }\n\n get #resolvedLocale(): string | undefined {\n return this.locale ?? (globalThis.document?.documentElement?.lang || undefined);\n }\n\n get #parsedNumber(): number | null {\n const raw = this.#rawValue;\n if (!raw) return null;\n\n const numericValue = Number(raw);\n if (Number.isFinite(numericValue)) return numericValue;\n\n return null;\n }\n\n get #formatOptions(): Intl.NumberFormatOptions {\n const options: Intl.NumberFormatOptions = { style: this.formatStyle };\n\n for (const [prop, key] of STRING_KEYS) {\n const value = this[prop] as string | undefined;\n if (value !== undefined) (options as Record<string, unknown>)[key] = value;\n }\n\n for (const [prop, key] of NUMBER_KEYS) {\n const value = this[prop] as number | undefined;\n if (value !== undefined) (options as Record<string, unknown>)[key] = value;\n }\n\n if (this.useGrouping !== undefined) {\n const grouping = this.useGrouping === 'false' ? false : this.useGrouping === 'true' ? true : this.useGrouping;\n (options as Record<string, unknown>).useGrouping = grouping;\n }\n\n return options;\n }\n\n get #formattedNumber(): string {\n const raw = this.#rawValue;\n if (!raw) return '';\n\n const numericValue = this.#parsedNumber;\n if (numericValue === null) return raw;\n\n try {\n return new Intl.NumberFormat(this.#resolvedLocale, this.#formatOptions).format(numericValue);\n } catch {\n return raw;\n }\n }\n\n render() {\n return html`<data internal-host value=${this.#rawValue}>${this.#formattedNumber}<slot @slotchange=${this.#onSlotChange} hidden></slot></data>`;\n }\n\n #onSlotChange() {\n this.request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E,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,YAAA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAkB,CAAC,CAAA,GAAA,EAAA,WAAA,kBAAA,KAAA,CAAA,GAKvD,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAe,CAAC,CAAA,GAAA,EAAA,WAAA,eAAA,KAAA,CAAA,GAKpD,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAe,CAAC,CAAA,GAAA,EAAA,WAAA,eAAA,KAAA,CAAA,GAMpD,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAA0B,CAAC,CAAA,GAAA,EAAA,WAAA,yBAAA,KAAA,CAAA,GAK/D,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAA0B,CAAC,CAAA,GAAA,EAAA,WAAA,yBAAA,KAAA,CAAA,GAK/D,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAyB,CAAC,CAAA,GAAA,EAAA,WAAA,wBAAA,KAAA,CAAA,GArFhE,IAAA,EAAA,CAAA,EAAQ,CAAA,GAAA,CAAA"}
@@ -1,12 +1,11 @@
1
- import { LogService as e } from "../internal/services/log.service.js";
2
- import { typeSSR as t } from "../internal/controllers/type-ssr.controller.js";
3
- import { useStyles as n } from "../internal/styles/index.js";
4
- import r from "../_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/decorate.js";
5
- import i from "./format-relative-time.js";
6
- import { LitElement as a, html as o } from "lit";
7
- import { property as s } from "lit/decorators/property.js";
1
+ import { typeSSR as e } from "../internal/controllers/type-ssr.controller.js";
2
+ import { useStyles as t } from "../internal/styles/index.js";
3
+ import n from "../_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/decorate.js";
4
+ import r from "./format-relative-time.js";
5
+ import { LitElement as i, html as a } from "lit";
6
+ import { property as o } from "lit/decorators/property.js";
8
7
  //#region src/format-relative-time/format-relative-time.ts
9
- var c = {
8
+ var s = {
10
9
  second: 1e3,
11
10
  minute: 6e4,
12
11
  hour: 36e5,
@@ -14,7 +13,7 @@ var c = {
14
13
  week: 6048e5,
15
14
  month: 2592e6,
16
15
  year: 31536e6
17
- }, l = [
16
+ }, c = [
18
17
  {
19
18
  unit: "second",
20
19
  max: 60
@@ -43,17 +42,17 @@ var c = {
43
42
  unit: "year",
44
43
  max: Infinity
45
44
  }
46
- ], u = class extends a {
45
+ ], l = class extends i {
47
46
  constructor(...e) {
48
47
  super(...e), this.numeric = "always", this.formatStyle = "long", this.unit = "auto", this.sync = !1;
49
48
  }
50
49
  static {
51
- this.styles = n([i]);
50
+ this.styles = t([r]);
52
51
  }
53
52
  static {
54
53
  this.metadata = {
55
54
  tag: "nve-format-relative-time",
56
- version: "2.18.1"
55
+ version: "2.18.2"
57
56
  };
58
57
  }
59
58
  #e;
@@ -65,20 +64,20 @@ var c = {
65
64
  }
66
65
  #r(e) {
67
66
  let t = Math.abs(e), n = e < 0 ? -1 : 1;
68
- for (let { unit: e, max: r } of l) {
69
- let i = Math.round(t / c[e]);
67
+ for (let { unit: e, max: r } of c) {
68
+ let i = Math.round(t / s[e]);
70
69
  if (i < r) return {
71
70
  value: n * i,
72
71
  unit: e
73
72
  };
74
73
  }
75
74
  return {
76
- value: n * Math.round(t / c.year),
75
+ value: n * Math.round(t / s.year),
77
76
  unit: "year"
78
77
  };
79
78
  }
80
79
  #i(e, t) {
81
- return Math.round(e / c[t]);
80
+ return Math.round(e / s[t]);
82
81
  }
83
82
  #a(e) {
84
83
  return this.unit === "auto" ? this.#r(e) : {
@@ -87,18 +86,18 @@ var c = {
87
86
  };
88
87
  }
89
88
  get #o() {
90
- let t = this.#t;
91
- if (!t) return "";
92
- let n = new Date(t);
93
- if (isNaN(n.getTime())) return e.warn(`format-relative-time: invalid date value "${t}"`), t;
94
- let { value: r, unit: i } = this.#a(n.getTime() - Date.now());
89
+ let e = this.#t;
90
+ if (!e) return "";
91
+ let t = new Date(e);
92
+ if (isNaN(t.getTime())) return e;
93
+ let { value: n, unit: r } = this.#a(t.getTime() - Date.now());
95
94
  try {
96
95
  return new Intl.RelativeTimeFormat(this.#n, {
97
96
  numeric: this.numeric,
98
97
  style: this.formatStyle
99
- }).format(r, i);
100
- } catch (n) {
101
- return e.warn(`format-relative-time: ${n.message}`), t;
98
+ }).format(n, r);
99
+ } catch {
100
+ return e;
102
101
  }
103
102
  }
104
103
  #s() {
@@ -125,17 +124,17 @@ var c = {
125
124
  e.has("sync") && (this.sync ? this.#c() : this.#l());
126
125
  }
127
126
  render() {
128
- return o`<time internal-host datetime="${this.#t}">${this.#o}<slot @slotchange="${this.#u}" hidden></slot></time>`;
127
+ return a`<time internal-host datetime="${this.#t}">${this.#o}<slot @slotchange="${this.#u}" hidden></slot></time>`;
129
128
  }
130
129
  #u() {
131
130
  this.requestUpdate();
132
131
  }
133
132
  };
134
- r([s({ type: String })], u.prototype, "date", void 0), r([s({ type: String })], u.prototype, "locale", void 0), r([s({ type: String })], u.prototype, "numeric", void 0), r([s({
133
+ n([o({ type: String })], l.prototype, "date", void 0), n([o({ type: String })], l.prototype, "locale", void 0), n([o({ type: String })], l.prototype, "numeric", void 0), n([o({
135
134
  type: String,
136
135
  attribute: "format-style"
137
- })], u.prototype, "formatStyle", void 0), r([s({ type: String })], u.prototype, "unit", void 0), r([s({ type: Boolean })], u.prototype, "sync", void 0), u = r([t()], u);
136
+ })], l.prototype, "formatStyle", void 0), n([o({ type: String })], l.prototype, "unit", void 0), n([o({ type: Boolean })], l.prototype, "sync", void 0), l = n([e()], l);
138
137
  //#endregion
139
- export { u as FormatRelativeTime };
138
+ export { l as FormatRelativeTime };
140
139
 
141
140
  //# sourceMappingURL=format-relative-time2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-relative-time2.js","names":[],"sources":["../../src/format-relative-time/format-relative-time.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { useStyles, typeSSR, LogService } from '@nvidia-elements/core/internal';\nimport styles from './format-relative-time.css?inline';\n\ntype TimeUnitOption = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';\n\nconst UNIT_DIVISORS: Record<TimeUnitOption, number> = {\n second: 1000,\n minute: 60000,\n hour: 3600000,\n day: 86400000,\n week: 604800000,\n month: 2592000000,\n year: 31536000000\n};\n\nconst THRESHOLDS: { unit: TimeUnitOption; max: number }[] = [\n { unit: 'second', max: 60 },\n { unit: 'minute', max: 60 },\n { unit: 'hour', max: 24 },\n { unit: 'day', max: 7 },\n { unit: 'week', max: 4 },\n { unit: 'month', max: 12 },\n { unit: 'year', max: Number.POSITIVE_INFINITY }\n];\n\n/**\n * @element nve-format-relative-time\n * @description Formats a date/time value as localized relative text using the Intl.RelativeTimeFormat API. Renders inside a semantic time element.\n * Options mirror the Intl.RelativeTimeFormat API. When unit is 'auto', the component selects the best unit based on the time difference.\n * @documentation https://nvidia.github.io/elements/docs/elements/format-relative-time/\n * @since 0.0.0\n * @entrypoint \\@nvidia-elements/core/format-relative-time\n * @slot - Date string to format (such as 2023-07-28T04:20:17.434Z). Serves as fallback before hydration.\n * @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time\n */\n@typeSSR()\nexport class FormatRelativeTime extends LitElement {\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-format-relative-time',\n version: '0.0.0'\n };\n\n /**\n * Optional date string for values supplied by JavaScript or bound data.\n * By default, the component formats the element's text content, which also serves as the SSR fallback.\n * When both are present, this property takes precedence.\n */\n @property({ type: String }) date?: string;\n\n /**\n * Language tag (such as en-US, de-DE). Defaults to document.documentElement.lang or browser default.\n */\n @property({ type: String }) locale?: string;\n\n /**\n * Numeric formatting: 'always' | 'auto'. When 'auto', enables natural language forms such as 'yesterday' instead of '1 day ago'.\n */\n @property({ type: String }) numeric: 'always' | 'auto' = 'always';\n\n /**\n * Formatting length: 'long' | 'short' | 'narrow'. Controls verbosity (such as '3 days ago' vs '3d ago'). Maps to Intl.RelativeTimeFormat style option.\n */\n @property({ type: String, attribute: 'format-style' }) formatStyle: 'long' | 'short' | 'narrow' = 'long';\n\n /**\n * Time unit: 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year' | 'auto'. Use 'auto' to let the component select the most appropriate unit based on the time difference.\n */\n @property({ type: String }) unit: 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year' | 'auto' = 'auto';\n\n /**\n * When present, auto-updates the displayed relative time at appropriate intervals.\n */\n @property({ type: Boolean }) sync = false;\n\n #timer?: ReturnType<typeof setTimeout>;\n\n get #dateValue(): string {\n return this.date ?? this.textContent?.trim() ?? '';\n }\n\n get #resolvedLocale(): string | undefined {\n return this.locale ?? (globalThis.document?.documentElement?.lang || undefined);\n }\n\n #computeUnit(diffMs: number): { value: number; unit: Intl.RelativeTimeFormatUnit } {\n const absDiff = Math.abs(diffMs);\n const sign = diffMs < 0 ? -1 : 1;\n\n for (const { unit, max } of THRESHOLDS) {\n const value = Math.round(absDiff / UNIT_DIVISORS[unit]);\n if (value < max) return { value: sign * value, unit };\n }\n return { value: sign * Math.round(absDiff / UNIT_DIVISORS.year), unit: 'year' };\n }\n\n #computeExplicitUnit(diffMs: number, unit: TimeUnitOption): number {\n return Math.round(diffMs / UNIT_DIVISORS[unit]);\n }\n\n #resolveValueAndUnit(diffMs: number): { value: number; unit: Intl.RelativeTimeFormatUnit } {\n if (this.unit === 'auto') {\n return this.#computeUnit(diffMs);\n }\n return { unit: this.unit, value: this.#computeExplicitUnit(diffMs, this.unit) };\n }\n\n get #formattedRelativeTime(): string {\n const iso = this.#dateValue;\n if (!iso) return '';\n\n const target = new Date(iso);\n if (isNaN(target.getTime())) {\n LogService.warn(`format-relative-time: invalid date value \"${iso}\"`);\n return iso;\n }\n\n const { value, unit: resolvedUnit } = this.#resolveValueAndUnit(target.getTime() - Date.now());\n\n try {\n return new Intl.RelativeTimeFormat(this.#resolvedLocale, {\n numeric: this.numeric,\n style: this.formatStyle\n }).format(value, resolvedUnit);\n } catch (e) {\n LogService.warn(`format-relative-time: ${(e as Error).message}`);\n return iso;\n }\n }\n\n #getSyncInterval(): number {\n const iso = this.#dateValue;\n if (!iso) return 60000;\n\n const absDiff = Math.abs(new Date(iso).getTime() - Date.now());\n if (absDiff < 60000) return 10000;\n if (absDiff < 3600000) return 30000;\n if (absDiff < 86400000) return 300000;\n return 3600000;\n }\n\n #startSync() {\n this.#stopSync();\n if (!this.sync) return;\n\n this.#timer = setTimeout(() => {\n this.requestUpdate();\n this.#startSync();\n }, this.#getSyncInterval());\n }\n\n #stopSync() {\n if (this.#timer !== undefined) {\n clearTimeout(this.#timer);\n this.#timer = undefined;\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (this.sync) this.#startSync();\n }\n\n disconnectedCallback() {\n this.#stopSync();\n super.disconnectedCallback();\n }\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('sync')) {\n if (this.sync) {\n this.#startSync();\n } else {\n this.#stopSync();\n }\n }\n }\n\n render() {\n return html`<time internal-host datetime=${this.#dateValue}>${this.#formattedRelativeTime}<slot @slotchange=${this.#onSlotChange} hidden></slot></time>`;\n }\n\n #onSlotChange() {\n this.requestUpdate();\n }\n}\n"],"mappings":";;;;;;;;AAUA,IAAM,IAAgD;CACpD,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,KAAK;CACL,MAAM;CACN,OAAO;CACP,MAAM;AACR,GAEM,IAAsD;CAC1D;EAAE,MAAM;EAAU,KAAK;CAAG;CAC1B;EAAE,MAAM;EAAU,KAAK;CAAG;CAC1B;EAAE,MAAM;EAAQ,KAAK;CAAG;CACxB;EAAE,MAAM;EAAO,KAAK;CAAE;CACtB;EAAE,MAAM;EAAQ,KAAK;CAAE;CACvB;EAAE,MAAM;EAAS,KAAK;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AAO,CAAC,CAAA,GAAA,EAAA,WAAA,UAAA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,WAAA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAe,CAAC,CAAA,GAAA,EAAA,WAAA,eAAA,KAAA,CAAA,GAKpD,EAAA,CAAA,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS,EAAE,MAAM,QAAQ,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,GAvC5B,IAAA,EAAA,CAAA,EAAQ,CAAA,GAAA,CAAA"}
1
+ {"version":3,"file":"format-relative-time2.js","names":[],"sources":["../../src/format-relative-time/format-relative-time.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { useStyles, typeSSR } from '@nvidia-elements/core/internal';\nimport styles from './format-relative-time.css?inline';\n\ntype TimeUnitOption = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';\n\nconst UNIT_DIVISORS: Record<TimeUnitOption, number> = {\n second: 1000,\n minute: 60000,\n hour: 3600000,\n day: 86400000,\n week: 604800000,\n month: 2592000000,\n year: 31536000000\n};\n\nconst THRESHOLDS: { unit: TimeUnitOption; max: number }[] = [\n { unit: 'second', max: 60 },\n { unit: 'minute', max: 60 },\n { unit: 'hour', max: 24 },\n { unit: 'day', max: 7 },\n { unit: 'week', max: 4 },\n { unit: 'month', max: 12 },\n { unit: 'year', max: Number.POSITIVE_INFINITY }\n];\n\n/**\n * @element nve-format-relative-time\n * @description Formats a date/time value as localized relative text using the Intl.RelativeTimeFormat API. Renders inside a semantic time element.\n * Options mirror the Intl.RelativeTimeFormat API. When unit is 'auto', the component selects the best unit based on the time difference.\n * @documentation https://nvidia.github.io/elements/docs/elements/format-relative-time/\n * @since 0.0.0\n * @entrypoint \\@nvidia-elements/core/format-relative-time\n * @slot - Date string to format (such as 2023-07-28T04:20:17.434Z). Serves as fallback before hydration.\n * @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time\n */\n@typeSSR()\nexport class FormatRelativeTime extends LitElement {\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-format-relative-time',\n version: '0.0.0'\n };\n\n /**\n * Optional date string for values supplied by JavaScript or bound data.\n * By default, the component formats the element's text content, which also serves as the SSR fallback.\n * When both are present, this property takes precedence.\n */\n @property({ type: String }) date?: string;\n\n /**\n * Language tag (such as en-US, de-DE). Defaults to document.documentElement.lang or browser default.\n */\n @property({ type: String }) locale?: string;\n\n /**\n * Numeric formatting: 'always' | 'auto'. When 'auto', enables natural language forms such as 'yesterday' instead of '1 day ago'.\n */\n @property({ type: String }) numeric: 'always' | 'auto' = 'always';\n\n /**\n * Formatting length: 'long' | 'short' | 'narrow'. Controls verbosity (such as '3 days ago' vs '3d ago'). Maps to Intl.RelativeTimeFormat style option.\n */\n @property({ type: String, attribute: 'format-style' }) formatStyle: 'long' | 'short' | 'narrow' = 'long';\n\n /**\n * Time unit: 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year' | 'auto'. Use 'auto' to let the component select the most appropriate unit based on the time difference.\n */\n @property({ type: String }) unit: 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year' | 'auto' = 'auto';\n\n /**\n * When present, auto-updates the displayed relative time at appropriate intervals.\n */\n @property({ type: Boolean }) sync = false;\n\n #timer?: ReturnType<typeof setTimeout>;\n\n get #dateValue(): string {\n return this.date ?? this.textContent?.trim() ?? '';\n }\n\n get #resolvedLocale(): string | undefined {\n return this.locale ?? (globalThis.document?.documentElement?.lang || undefined);\n }\n\n #computeUnit(diffMs: number): { value: number; unit: Intl.RelativeTimeFormatUnit } {\n const absDiff = Math.abs(diffMs);\n const sign = diffMs < 0 ? -1 : 1;\n\n for (const { unit, max } of THRESHOLDS) {\n const value = Math.round(absDiff / UNIT_DIVISORS[unit]);\n if (value < max) return { value: sign * value, unit };\n }\n return { value: sign * Math.round(absDiff / UNIT_DIVISORS.year), unit: 'year' };\n }\n\n #computeExplicitUnit(diffMs: number, unit: TimeUnitOption): number {\n return Math.round(diffMs / UNIT_DIVISORS[unit]);\n }\n\n #resolveValueAndUnit(diffMs: number): { value: number; unit: Intl.RelativeTimeFormatUnit } {\n if (this.unit === 'auto') {\n return this.#computeUnit(diffMs);\n }\n return { unit: this.unit, value: this.#computeExplicitUnit(diffMs, this.unit) };\n }\n\n get #formattedRelativeTime(): string {\n const iso = this.#dateValue;\n if (!iso) return '';\n\n const target = new Date(iso);\n if (isNaN(target.getTime())) {\n return iso;\n }\n\n const { value, unit: resolvedUnit } = this.#resolveValueAndUnit(target.getTime() - Date.now());\n\n try {\n return new Intl.RelativeTimeFormat(this.#resolvedLocale, {\n numeric: this.numeric,\n style: this.formatStyle\n }).format(value, resolvedUnit);\n } catch {\n return iso;\n }\n }\n\n #getSyncInterval(): number {\n const iso = this.#dateValue;\n if (!iso) return 60000;\n\n const absDiff = Math.abs(new Date(iso).getTime() - Date.now());\n if (absDiff < 60000) return 10000;\n if (absDiff < 3600000) return 30000;\n if (absDiff < 86400000) return 300000;\n return 3600000;\n }\n\n #startSync() {\n this.#stopSync();\n if (!this.sync) return;\n\n this.#timer = setTimeout(() => {\n this.requestUpdate();\n this.#startSync();\n }, this.#getSyncInterval());\n }\n\n #stopSync() {\n if (this.#timer !== undefined) {\n clearTimeout(this.#timer);\n this.#timer = undefined;\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (this.sync) this.#startSync();\n }\n\n disconnectedCallback() {\n this.#stopSync();\n super.disconnectedCallback();\n }\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('sync')) {\n if (this.sync) {\n this.#startSync();\n } else {\n this.#stopSync();\n }\n }\n }\n\n render() {\n return html`<time internal-host datetime=${this.#dateValue}>${this.#formattedRelativeTime}<slot @slotchange=${this.#onSlotChange} hidden></slot></time>`;\n }\n\n #onSlotChange() {\n this.requestUpdate();\n }\n}\n"],"mappings":";;;;;;;AAUA,IAAM,IAAgD;CACpD,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,KAAK;CACL,MAAM;CACN,OAAO;CACP,MAAM;AACR,GAEM,IAAsD;CAC1D;EAAE,MAAM;EAAU,KAAK;CAAG;CAC1B;EAAE,MAAM;EAAU,KAAK;CAAG;CAC1B;EAAE,MAAM;EAAQ,KAAK;CAAG;CACxB;EAAE,MAAM;EAAO,KAAK;CAAE;CACtB;EAAE,MAAM;EAAQ,KAAK;CAAE;CACvB;EAAE,MAAM;EAAS,KAAK;CAAG;CACzB;EAAE,MAAM;EAAQ,KAAK;CAAyB;AAChD,GAaa,IAAN,cAAiC,EAAW;;EAsCb,aAfqB,KAAA,UAAA,UAKyC,KAAA,cAAA,QAKY,KAAA,OAAA,QAK1E,KAAA,OAAA;;;EArCpB,KAAA,SAAA,EAAU,CAAC,CAAM,CAAC;;;EAEP,KAAA,WAAA;GACzB,KAAK;GACL,SAAS;EACX;;CAkCA;CAEA,IAAI,KAAqB;EACvB,OAAO,KAAK,QAAQ,KAAK,aAAa,KAAK,KAAK;CAClD;CAEA,IAAI,KAAsC;EACxC,OAAO,KAAK,WAAW,WAAW,UAAU,iBAAiB,QAAQ,KAAA;CACvE;CAEA,GAAa,GAAsE;EACjF,IAAM,IAAU,KAAK,IAAI,CAAM,GACzB,IAAO,IAAS,IAAI,KAAK;EAE/B,KAAK,IAAM,EAAE,SAAM,YAAS,GAAY;GACtC,IAAM,IAAQ,KAAK,MAAM,IAAU,EAAc,EAAK;GACtD,IAAI,IAAQ,GAAK,OAAO;IAAE,OAAO,IAAO;IAAO;GAAK;EACtD;EACA,OAAO;GAAE,OAAO,IAAO,KAAK,MAAM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W;CACjC;CAEA,uBAAuB;EAErB,AADA,KAAK,GAAU,GACf,MAAM,qBAAqB;CAC7B;CAEA,QAAQ,GAA+B;EACrC,AAAI,EAAQ,IAAI,MAAM,MAChB,KAAK,OACP,KAAK,GAAW,IAEhB,KAAK,GAAU;CAGrB;CAEA,SAAS;EACP,OAAO,CAAI,iCAAgC,KAAK,GAAW,IAAG,KAAK,GAAuB,qBAAoB,KAAK,GAAc;CACnI;CAEA,KAAgB;EACd,KAAK,cAAc;CACrB;AACF;AAvIG,EAAA,CAAA,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,UAAA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,WAAA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAe,CAAC,CAAA,GAAA,EAAA,WAAA,eAAA,KAAA,CAAA,GAKpD,EAAA,CAAA,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,GAKzB,EAAA,CAAA,EAAS,EAAE,MAAM,QAAQ,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,GAvC5B,IAAA,EAAA,CAAA,EAAQ,CAAA,GAAA,CAAA"}
@@ -19,7 +19,7 @@ var d = class extends c {
19
19
  static {
20
20
  this.metadata = {
21
21
  tag: "nve-format-truncate",
22
- version: "2.18.1"
22
+ version: "2.18.2"
23
23
  };
24
24
  }
25
25
  #e;
@@ -48,7 +48,7 @@ var C = class extends v {
48
48
  static {
49
49
  this.metadata = {
50
50
  tag: "nve-control",
51
- version: "2.18.1"
51
+ version: "2.18.2"
52
52
  };
53
53
  }
54
54
  render() {
@@ -24,7 +24,7 @@ var m = class extends d {
24
24
  static {
25
25
  this.metadata = {
26
26
  tag: "nve-control-group",
27
- version: "2.18.1"
27
+ version: "2.18.2"
28
28
  };
29
29
  }
30
30
  render() {