@flyos/design-system 2.4.0 → 2.5.0

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.
@@ -47,7 +47,7 @@ import { CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
47
47
  // tools/publish-library.ps1 at bump time, and asserted by the spec beside this file.
48
48
  // Used only for the diagnostic message; the duplicate-instance detection itself is
49
49
  // version-agnostic, so a stale literal misnames a fork rather than hiding one.
50
- const FLY_DS_VERSION = '2.4.0';
50
+ const FLY_DS_VERSION = '2.5.0';
51
51
  const FLY_DS_REGISTRY_KEY = '__FLY_DS_INSTANCES__';
52
52
  /**
53
53
  * Records this design-system instance on the shared `scope` and returns the
@@ -19602,6 +19602,8 @@ function currencyFormatter(locale, code, digits) {
19602
19602
  currencyDisplay: 'code',
19603
19603
  minimumFractionDigits: digits,
19604
19604
  maximumFractionDigits: digits,
19605
+ // See TRAILING_ZERO_OPTION — "AED 620,000.00" reads as noise; "AED 620,000" is the figure.
19606
+ ...TRAILING_ZERO_OPTION,
19605
19607
  });
19606
19608
  moneyFormatterCache.set(key, f);
19607
19609
  return f;
@@ -19610,12 +19612,34 @@ function currencyFormatter(locale, code, digits) {
19610
19612
  return null;
19611
19613
  }
19612
19614
  }
19615
+ /**
19616
+ * Drop the decimal part when it carries no value: `620000.00` renders `620,000`, while
19617
+ * `620000.50` still renders `620,000.50`.
19618
+ *
19619
+ * <b>`stripIfInteger`, NOT `minimumFractionDigits: 0`.</b> The latter also strips the trailing zero
19620
+ * INSIDE the decimals (`620,000.5`), which is wrong for money — a partial amount conventionally
19621
+ * shows the currency's full minor units. This option strips all-or-nothing, which is the intent:
19622
+ * the decimals either mean something or they do not.
19623
+ *
19624
+ * `maximumFractionDigits` is still the currency's own `decimalDigits`, so 3-decimal dinars and
19625
+ * 0-decimal yen are unaffected in the cases that matter — this only removes a run of zeros a reader
19626
+ * gains nothing from.
19627
+ *
19628
+ * Spread rather than set inline because `trailingZeroDisplay` is a newer Intl option than the
19629
+ * TypeScript DOM lib in this workspace declares; the cast is contained to this one constant instead
19630
+ * of every formatter construction.
19631
+ */
19632
+ const TRAILING_ZERO_OPTION = { trailingZeroDisplay: 'stripIfInteger' };
19613
19633
  const plainDecimalCache = new Map();
19614
19634
  function plainDecimalFormatter(locale, digits) {
19615
19635
  const key = `${locale}|${digits}`;
19616
19636
  let f = plainDecimalCache.get(key);
19617
19637
  if (!f) {
19618
- f = new Intl.NumberFormat(locale, { minimumFractionDigits: digits, maximumFractionDigits: digits });
19638
+ f = new Intl.NumberFormat(locale, {
19639
+ minimumFractionDigits: digits,
19640
+ maximumFractionDigits: digits,
19641
+ ...TRAILING_ZERO_OPTION,
19642
+ });
19619
19643
  plainDecimalCache.set(key, f);
19620
19644
  }
19621
19645
  return f;
@@ -19632,7 +19656,8 @@ function manualFormat(amount, meta, display, locale) {
19632
19656
  * ```ts
19633
19657
  * flyFormatMoney(1234.5, kwdRow) // "د.ك 1,234.500" (KWD is 3-decimal)
19634
19658
  * flyFormatMoney(1234, 'JPY') // "JPY 1,234" (bare code, no symbol to read — degrades to the code)
19635
- * flyFormatMoney(-42, usdRow, { display: 'code' }) // "-USD 42.00"
19659
+ * flyFormatMoney(-42, usdRow, { display: 'code' }) // "-USD 42" (whole amount — see TRAILING_ZERO_OPTION)
19660
+ * flyFormatMoney(-42.5, usdRow, { display: 'code' }) // "-USD 42.50" (partial amount keeps its minor units)
19636
19661
  * flyFormatMoney(99.9, eurRow, { display: 'none' }) // "99.90" (currency named elsewhere on screen)
19637
19662
  * flyFormatMoney(null, usdRow) // "—" (never "NaN")
19638
19663
  * ```