@mediaradar/design-components 0.57.0 → 0.58.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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.57.0",
2
+ "version": "0.58.0",
3
3
  "components": [
4
4
  "AISpark",
5
5
  "AdvertiserNoResults",
package/dist/index.cjs CHANGED
@@ -61,6 +61,7 @@ __export(index_exports, {
61
61
  MultiSelectFilter: () => MultiSelectFilter,
62
62
  NO_RESULTS_BODY: () => NO_RESULTS_BODY,
63
63
  NO_RESULTS_TITLE: () => NO_RESULTS_TITLE,
64
+ NO_VALUE: () => NO_VALUE,
64
65
  NameListModal: () => NameListModal,
65
66
  NoResultsEmptyState: () => NoResultsEmptyState,
66
67
  PRIMARY_ACTION_CLASS: () => PRIMARY_ACTION_CLASS,
@@ -98,13 +99,18 @@ __export(index_exports, {
98
99
  chipTriggerClass: () => chipTriggerClass,
99
100
  cycleSort: () => cycleSort,
100
101
  defaultDateOrder: () => defaultDateOrder,
102
+ formatCount: () => formatCount,
103
+ formatCountFull: () => formatCountFull,
101
104
  formatDate: () => formatDate,
102
105
  formatDateRange: () => formatDateRange,
103
106
  formatDateTime: () => formatDateTime,
104
107
  formatIsoDate: () => formatIsoDate,
108
+ formatMoney: () => formatMoney,
109
+ formatMoneyFull: () => formatMoneyFull,
105
110
  formatMonth: () => formatMonth,
106
111
  formatMonthAxis: () => formatMonthAxis,
107
112
  formatOpenRange: () => formatOpenRange,
113
+ formatPercent: () => formatPercent,
108
114
  formatQuarter: () => formatQuarter,
109
115
  formatRelative: () => formatRelative,
110
116
  formatTime: () => formatTime,
@@ -6017,6 +6023,62 @@ function defaultDateOrder(country) {
6017
6023
  const c = (country ?? "").toUpperCase();
6018
6024
  return c === "US" || c === "CA" || c === "" ? "mdy" : "dmy";
6019
6025
  }
6026
+
6027
+ // src/numbers.ts
6028
+ var US = { units: ["K", "M", "B", "T"] };
6029
+ var STYLES = {
6030
+ "en-US": US,
6031
+ "en-CA": US,
6032
+ "en-GB": { units: ["k", "m", "bn", "tn"] }
6033
+ };
6034
+ var styleFor = (language) => STYLES[language ?? "en-US"] ?? US;
6035
+ var NO_VALUE = "\u2014";
6036
+ var MINUS = "\u2212";
6037
+ var SHORTEN_FROM = 1e4;
6038
+ var isMissing = (v) => v === null || v === void 0 || Number.isNaN(v);
6039
+ var withCommas = (n) => Math.round(n).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
6040
+ function shortAbs(abs, style) {
6041
+ if (abs < SHORTEN_FROM) return withCommas(abs);
6042
+ let tier = Math.min(Math.floor(Math.log10(abs) / 3), 4);
6043
+ let scaled = Math.round(abs / 1e3 ** tier * 10) / 10;
6044
+ if (scaled >= 1e3 && tier < 4) {
6045
+ tier += 1;
6046
+ scaled = Math.round(abs / 1e3 ** tier * 10) / 10;
6047
+ }
6048
+ const text = Number.isInteger(scaled) ? withCommas(scaled) : scaled.toFixed(1);
6049
+ return `${text}${style.units[tier - 1]}`;
6050
+ }
6051
+ function symbol(opts) {
6052
+ const currency = opts.currency ?? "USD";
6053
+ if (currency === "GBP") return "\xA3";
6054
+ if (currency === "EUR") return "\u20AC";
6055
+ if (opts.mixedDollars) return currency === "CAD" ? "CA$" : "US$";
6056
+ return "$";
6057
+ }
6058
+ var sign = (v) => v < 0 ? MINUS : "";
6059
+ function formatCount(value, opts = {}) {
6060
+ if (isMissing(value)) return NO_VALUE;
6061
+ return sign(value) + shortAbs(Math.abs(value), styleFor(opts.language));
6062
+ }
6063
+ function formatCountFull(value) {
6064
+ if (isMissing(value)) return NO_VALUE;
6065
+ return sign(value) + withCommas(Math.abs(value));
6066
+ }
6067
+ function formatMoney(value, opts = {}) {
6068
+ if (isMissing(value)) return NO_VALUE;
6069
+ return sign(value) + symbol(opts) + shortAbs(Math.abs(value), styleFor(opts.language));
6070
+ }
6071
+ function formatMoneyFull(value, opts = {}) {
6072
+ if (isMissing(value)) return NO_VALUE;
6073
+ return sign(value) + symbol(opts) + withCommas(Math.abs(value));
6074
+ }
6075
+ function formatPercent(value, _opts = {}) {
6076
+ if (isMissing(value)) return NO_VALUE;
6077
+ const abs = Math.abs(value);
6078
+ if (abs > 0 && abs < 0.05) return `${value < 0 ? MINUS : ""}<0.1%`;
6079
+ const text = (Math.round(abs * 10) / 10).toFixed(1);
6080
+ return text === "0.0" ? "0.0%" : `${sign(value)}${text}%`;
6081
+ }
6020
6082
  // Annotate the CommonJS export names for ESM import in node:
6021
6083
  0 && (module.exports = {
6022
6084
  AISpark,
@@ -6059,6 +6121,7 @@ function defaultDateOrder(country) {
6059
6121
  MultiSelectFilter,
6060
6122
  NO_RESULTS_BODY,
6061
6123
  NO_RESULTS_TITLE,
6124
+ NO_VALUE,
6062
6125
  NameListModal,
6063
6126
  NoResultsEmptyState,
6064
6127
  PRIMARY_ACTION_CLASS,
@@ -6096,13 +6159,18 @@ function defaultDateOrder(country) {
6096
6159
  chipTriggerClass,
6097
6160
  cycleSort,
6098
6161
  defaultDateOrder,
6162
+ formatCount,
6163
+ formatCountFull,
6099
6164
  formatDate,
6100
6165
  formatDateRange,
6101
6166
  formatDateTime,
6102
6167
  formatIsoDate,
6168
+ formatMoney,
6169
+ formatMoneyFull,
6103
6170
  formatMonth,
6104
6171
  formatMonthAxis,
6105
6172
  formatOpenRange,
6173
+ formatPercent,
6106
6174
  formatQuarter,
6107
6175
  formatRelative,
6108
6176
  formatTime,