@nivaro/react 0.3.139 → 0.3.140

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 (87) hide show
  1. package/dist/components/InlineGridField.js +95 -92
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +36 -2
  4. package/dist/shared/components/AudienceConfirmPanel.js +19 -19
  5. package/dist/shared/components/BroadcastView.js +213 -211
  6. package/dist/shared/components/CollectionBrowserView.js +2677 -2658
  7. package/dist/shared/components/ConfigHistory.js +45 -45
  8. package/dist/shared/components/ConformanceView.js +110 -110
  9. package/dist/shared/components/DataTable.js +51 -51
  10. package/dist/shared/components/FilePreviewLightbox.js +26 -25
  11. package/dist/shared/components/ItemEditForm.js +3038 -3027
  12. package/dist/shared/components/LiveCount.js +27 -23
  13. package/dist/shared/components/LiveTraceView.js +62 -61
  14. package/dist/shared/components/PageRenderer.js +422 -410
  15. package/dist/shared/components/ProfileView.js +199 -199
  16. package/dist/shared/components/QualityRulesView.js +70 -70
  17. package/dist/shared/components/QueryTable.js +131 -130
  18. package/dist/shared/components/RecordGraph.js +98 -98
  19. package/dist/shared/components/RecordReadView.js +287 -288
  20. package/dist/shared/components/ReportView.js +1279 -1259
  21. package/dist/shared/components/SlaRulesView.js +73 -74
  22. package/dist/shared/components/WidgetSlot.js +73 -73
  23. package/dist/shared/components/ai/AiChart.js +36 -32
  24. package/dist/shared/components/ai/AiMarkdown.js +136 -129
  25. package/dist/shared/components/ai/TaskDo.js +87 -87
  26. package/dist/shared/components/ai/answer-formats.js +37 -30
  27. package/dist/shared/components/ai/call-log/format.js +17 -16
  28. package/dist/shared/components/bulk/BulkActionButtons.js +66 -66
  29. package/dist/shared/components/bulk/BulkFieldUpdate.js +59 -59
  30. package/dist/shared/components/bulk/BulkSelectionNotices.js +34 -34
  31. package/dist/shared/components/bulk/MessageStakeholders.js +31 -29
  32. package/dist/shared/components/bulk/PushBulkButtons.js +83 -82
  33. package/dist/shared/components/bulk/bulk-field-options.js +10 -10
  34. package/dist/shared/components/cbv/column-totals.js +53 -51
  35. package/dist/shared/components/chat/ChatAnalyticsView.js +87 -87
  36. package/dist/shared/components/collections-directory/CollectionsToolbar.js +18 -18
  37. package/dist/shared/components/command-center/announce.js +7 -6
  38. package/dist/shared/components/command-center/panels/AttentionPanel.js +32 -31
  39. package/dist/shared/components/command-center/panels/FlowPanel.js +29 -28
  40. package/dist/shared/components/command-center/panels/PeoplePanel.js +39 -39
  41. package/dist/shared/components/delegation/DelegationConsoleView.js +27 -27
  42. package/dist/shared/components/imports/RunDetailSheet.js +1 -1
  43. package/dist/shared/components/integrations/IntegrationObligationsView.js +119 -119
  44. package/dist/shared/components/integrations/console/EventsView.js +35 -35
  45. package/dist/shared/components/integrations/console/FirefightView.js +15 -14
  46. package/dist/shared/components/integrations/console/PartnerDetail.js +78 -78
  47. package/dist/shared/components/integrations/console/ReadyToSendView.js +103 -103
  48. package/dist/shared/components/integrations/console/SignalCard.js +67 -67
  49. package/dist/shared/components/item-edit/CatalogPickerField.js +536 -527
  50. package/dist/shared/components/item-edit/ChangesTray.js +88 -74
  51. package/dist/shared/components/item-edit/FilePickerField.js +123 -123
  52. package/dist/shared/components/item-edit/GroupSection.js +301 -292
  53. package/dist/shared/components/item-edit/HeaderSummaryChip.js +54 -54
  54. package/dist/shared/components/item-edit/InlineGridField.js +45 -36
  55. package/dist/shared/components/item-edit/InlineTableField.js +1167 -1153
  56. package/dist/shared/components/item-edit/NestedRelationEditor.js +106 -99
  57. package/dist/shared/components/item-edit/RecordChatMentionsChip.js +11 -11
  58. package/dist/shared/components/layout-editor/ai-forms/SlimPanel.js +43 -44
  59. package/dist/shared/components/monitoring/ApiRequestLog.js +35 -35
  60. package/dist/shared/components/notifications/NotificationCenterView.js +268 -268
  61. package/dist/shared/components/ops-report/format.js +37 -36
  62. package/dist/shared/components/panels/ReferencedByPanel.js +21 -20
  63. package/dist/shared/components/panels/RevisionsPanel.js +306 -305
  64. package/dist/shared/components/pipeline/OwnerMatrixVersionsCard.js +12 -12
  65. package/dist/shared/components/pipeline/PipelineEditorView.js +483 -482
  66. package/dist/shared/components/pipeline/PipelineHealthCards.js +33 -32
  67. package/dist/shared/components/pipeline/TeamsView.js +189 -130
  68. package/dist/shared/components/profile/AgentsPanel.js +6 -6
  69. package/dist/shared/components/profile/DelegationCard.js +13 -12
  70. package/dist/shared/components/profile/PersonActivity.js +48 -48
  71. package/dist/shared/components/profile/PersonExtras.js +107 -107
  72. package/dist/shared/components/profile/PersonWeek.js +9 -9
  73. package/dist/shared/components/queue/QueueBulkBar.js +19 -18
  74. package/dist/shared/components/queue/QueueBulkMove.js +21 -20
  75. package/dist/shared/components/queue/QueueItemSheet.js +136 -131
  76. package/dist/shared/components/queue/QueueWorklist.js +671 -670
  77. package/dist/shared/components/queue/worklist-helpers.js +36 -21
  78. package/dist/shared/components/support/RequestList.js +121 -121
  79. package/dist/shared/components/support/SupportAnalytics.js +29 -29
  80. package/dist/shared/lib/activity-sentence.js +251 -229
  81. package/dist/shared/lib/format-value.js +5 -4
  82. package/dist/shared/lib/number-format.js +87 -0
  83. package/dist/shared/lib/number-kind.js +133 -0
  84. package/dist/shared/lib/utils.js +24 -20
  85. package/dist/shared/lib/watch-list.js +1 -1
  86. package/dist/shared/lib/widget-value-format.js +26 -12
  87. package/package.json +1 -1
@@ -1,11 +1,11 @@
1
- import { formatDateTime as s, toLocalDateString as a, formatRelative as m } from "./utils.js";
1
+ import { formatDateTime as s, toLocalDateString as m, formatRelative as a } from "./utils.js";
2
2
  const c = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], l = /* @__PURE__ */ new Set(["true", "1", "yes", "y"]), h = /* @__PURE__ */ new Set(["false", "0", "no", "n"]);
3
3
  function u(t) {
4
4
  return String(t).padStart(2, "0");
5
5
  }
6
6
  function f(t, e) {
7
7
  const n = t.match(/^(\d{4})-(\d{2})-(\d{2})(?:T00:00:00(?:\.000)?Z)?$/), r = n ? new Date(Number(n[1]), Number(n[2]) - 1, Number(n[3])) : new Date(t);
8
- return Number.isNaN(r.getTime()) ? t : e === "relative" ? m(r) : e.replace(/YYYY|MMM|YY|MM|DD|HH|hh|mm|ss|h|A|a/g, (i) => {
8
+ return Number.isNaN(r.getTime()) ? t : e === "relative" ? a(r) : e.replace(/YYYY|MMM|YY|MM|DD|HH|hh|mm|ss|h|A|a/g, (i) => {
9
9
  switch (i) {
10
10
  case "YYYY":
11
11
  return String(r.getFullYear());
@@ -39,14 +39,15 @@ function f(t, e) {
39
39
  function p(t, e) {
40
40
  if (e.type === "count") return t;
41
41
  if (e.type === "datetime")
42
- return e.template !== "relative" && /h|H/.test(e.template) ? s(t) || t : e.template !== "relative" && /D/.test(e.template) && /M/.test(e.template) && /Y/.test(e.template) ? a(t) || t : f(t, e.template);
42
+ return e.template !== "relative" && /h|H/.test(e.template) ? s(t) || t : e.template !== "relative" && /D/.test(e.template) && /M/.test(e.template) && /Y/.test(e.template) ? m(t) || t : f(t, e.template);
43
43
  if (e.type === "number") {
44
44
  const r = Number(t);
45
45
  if (Number.isNaN(r) || t.trim() === "") return t;
46
46
  const i = new Intl.NumberFormat("en-US", {
47
47
  minimumFractionDigits: e.decimals ?? 0,
48
48
  maximumFractionDigits: e.decimals ?? 0,
49
- useGrouping: e.thousands ?? !1
49
+ // Grouped unless the column says otherwise (thousands: false keeps ids / PO numbers as stored).
50
+ useGrouping: e.thousands ?? !0
50
51
  }).format(r);
51
52
  return `${e.prefix ?? ""}${i}${e.suffix ?? ""}`;
52
53
  }
@@ -0,0 +1,87 @@
1
+ import { numberKindOf as y, isReferenceName as p, numberKindOfValue as g, numberDecimalsOf as a, numberCurrencyOf as N } from "./number-kind.js";
2
+ import { nameWords as I } from "./number-kind.js";
3
+ import { numberLocale as b } from "./utils.js";
4
+ function u(t) {
5
+ if (t == null || typeof t == "boolean") return null;
6
+ if (typeof t == "number") return Number.isFinite(t) ? t : null;
7
+ if (typeof t == "bigint") return Number(t);
8
+ if (typeof t != "string") return null;
9
+ const n = t.trim();
10
+ if (!n || !/^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i.test(n)) return null;
11
+ const r = Number(n);
12
+ return Number.isFinite(r) ? r : null;
13
+ }
14
+ function m(t) {
15
+ if (t == null || typeof t == "number") return "";
16
+ const n = String(t);
17
+ return n.trim() ? n : "";
18
+ }
19
+ function l(t) {
20
+ const n = String(t ?? "USD").toUpperCase();
21
+ return /^[A-Z]{3}$/.test(n) ? n : "USD";
22
+ }
23
+ function F(t, n = {}) {
24
+ const r = u(t);
25
+ if (r == null) return m(t);
26
+ const e = l(n.currency), o = b(), i = n.decimals ?? 2, c = i === "auto" ? Number.isInteger(r) ? 0 : 2 : Math.min(Math.max(Math.trunc(Number(i) || 0), 0), 10), s = (f) => {
27
+ try {
28
+ return new Intl.NumberFormat(o, { style: "currency", currency: e, ...f }).format(r);
29
+ } catch {
30
+ return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", ...f }).format(r);
31
+ }
32
+ };
33
+ return n.compact && Math.abs(r) >= 1e3 ? s({ notation: "compact", minimumFractionDigits: 0, maximumFractionDigits: 1 }) : s({ minimumFractionDigits: c, maximumFractionDigits: c });
34
+ }
35
+ function D(t, n = 2) {
36
+ const r = u(t);
37
+ return r == null ? m(t) : new Intl.NumberFormat(b(), {
38
+ maximumFractionDigits: Math.min(Math.max(Math.trunc(n), 0), 10)
39
+ }).format(r);
40
+ }
41
+ function O(t, n) {
42
+ if (t == null || t === "") return "";
43
+ const r = u(t);
44
+ if (r == null) return m(t);
45
+ const e = y(n) ?? (p(n == null ? void 0 : n.field) ? "plain" : g(t) ?? "plain");
46
+ return S(r, e, n, t);
47
+ }
48
+ function S(t, n, r, e) {
49
+ if (!Number.isFinite(t)) return "";
50
+ if (n === "money")
51
+ return F(t, {
52
+ currency: N(r) ?? "USD",
53
+ decimals: a(r, 2)
54
+ });
55
+ if (n === "plain")
56
+ return e != null && typeof e != "object" ? String(e).trim() : String(t);
57
+ const o = D(
58
+ t,
59
+ n === "count" && Number.isInteger(t) ? 0 : a(r, 2)
60
+ ), i = h(r);
61
+ return !i || i === "$" ? o : i === "%" ? `${o}%` : `${o} ${i}`;
62
+ }
63
+ function h(t) {
64
+ const n = t == null ? void 0 : t.options;
65
+ let r = {};
66
+ if (typeof n == "string")
67
+ try {
68
+ r = JSON.parse(n) ?? {};
69
+ } catch {
70
+ r = {};
71
+ }
72
+ else n && typeof n == "object" && (r = n);
73
+ return typeof r.unit == "string" ? r.unit.trim() : "";
74
+ }
75
+ export {
76
+ F as formatCurrency,
77
+ O as formatFieldNumber,
78
+ D as formatGrouped,
79
+ S as formatNumberAs,
80
+ p as isReferenceName,
81
+ I as nameWords,
82
+ N as numberCurrencyOf,
83
+ a as numberDecimalsOf,
84
+ y as numberKindOf,
85
+ g as numberKindOfValue,
86
+ u as toFiniteNumber
87
+ };
@@ -0,0 +1,133 @@
1
+ const a = /* @__PURE__ */ new Set(["money", "currency", "smallmoney"]), f = /* @__PURE__ */ new Set(["decimal", "float", "double", "numeric", "real", "number"]), l = /* @__PURE__ */ new Set([
2
+ "integer",
3
+ "int",
4
+ "biginteger",
5
+ "bigint",
6
+ "smallint",
7
+ "tinyint",
8
+ "bigincrements",
9
+ "increments"
10
+ ]), y = /* @__PURE__ */ new Set([
11
+ "string",
12
+ "text",
13
+ "uuid",
14
+ "char",
15
+ "varchar",
16
+ "nvarchar",
17
+ "csv",
18
+ "hash",
19
+ "json"
20
+ ]), p = /* @__PURE__ */ new Set([
21
+ "count",
22
+ "counts",
23
+ "qty",
24
+ "quantity",
25
+ "quantities",
26
+ "total",
27
+ "totals",
28
+ "units",
29
+ "sum",
30
+ "amount",
31
+ "balance",
32
+ "hours",
33
+ "minutes",
34
+ "days",
35
+ "size",
36
+ "bytes",
37
+ "weight",
38
+ "length",
39
+ "width",
40
+ "height",
41
+ "cost",
42
+ "price"
43
+ ]), m = /* @__PURE__ */ new Set([
44
+ "id",
45
+ "pk",
46
+ "number",
47
+ "num",
48
+ "no",
49
+ "nbr",
50
+ "nr",
51
+ "line",
52
+ "year",
53
+ "yr",
54
+ "fy",
55
+ "code",
56
+ "zip",
57
+ "zipcode",
58
+ "postal",
59
+ "phone",
60
+ "fax",
61
+ "ext",
62
+ "seq",
63
+ "sequence",
64
+ "version",
65
+ "ver",
66
+ "rev",
67
+ "revision",
68
+ "po",
69
+ "sku",
70
+ "ref",
71
+ "reference",
72
+ "key",
73
+ "acct",
74
+ "account"
75
+ ]);
76
+ function c(n) {
77
+ if (!n) return {};
78
+ if (typeof n == "string")
79
+ try {
80
+ const e = JSON.parse(n);
81
+ return e && typeof e == "object" && !Array.isArray(e) ? e : {};
82
+ } catch {
83
+ return {};
84
+ }
85
+ return typeof n == "object" && !Array.isArray(n) ? n : {};
86
+ }
87
+ function d(n) {
88
+ return String(n ?? "").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
89
+ }
90
+ function S(n) {
91
+ if (!n) return null;
92
+ const e = c(n.options), r = c(n.display_options), t = String(e.format ?? r.format ?? "").toLowerCase(), i = typeof e.unit == "string" ? e.unit.trim() : "", s = String(n.type ?? "").toLowerCase(), o = String(n.interface ?? "").toLowerCase();
93
+ if (!(t === "currency" || !!e.currency || !!r.currency || !t && i === "$" || o === "currency" || a.has(s))) return null;
94
+ const u = String(e.currency ?? r.currency ?? "USD").toUpperCase();
95
+ return /^[A-Z]{3}$/.test(u) ? u : "USD";
96
+ }
97
+ function b(n) {
98
+ var o;
99
+ if (!n) return null;
100
+ const e = c(n.options), r = String(e.format ?? "").toLowerCase();
101
+ if (r === "currency") return "money";
102
+ if (r === "int" || r === "integer" || r === "number" || r === "count") return "count";
103
+ if (r === "decimal") return "decimal";
104
+ if (r === "plain" || r === "id" || r === "none") return "plain";
105
+ if (S(n)) return "money";
106
+ let t = String(n.type ?? "").toLowerCase();
107
+ if ((!t || t === "alias" || t === "unknown") && (t = String(n.computed_type ?? "").toLowerCase()), y.has(t)) return "plain";
108
+ const i = f.has(t);
109
+ return !i && !l.has(t) ? null : n.is_primary_key || (o = n.schema) != null && o.is_primary_key || g(n.field) ? "plain" : i ? "decimal" : "count";
110
+ }
111
+ function g(n) {
112
+ const e = String(n ?? ""), r = d(e);
113
+ return r.some((i) => p.has(i)) ? !1 : /[a-z]id$/i.test(e) && !/(paid|valid|void|grid|fluid|hybrid)$/i.test(e) || r.some((i) => m.has(i));
114
+ }
115
+ function w(n) {
116
+ if (typeof n == "number")
117
+ return Number.isFinite(n) ? Number.isInteger(n) ? "count" : "decimal" : null;
118
+ if (typeof n != "string") return null;
119
+ const e = n.trim();
120
+ return /^-?\d+(\.\d+)?$/.test(e) ? e.includes(".") ? "decimal" : "plain" : null;
121
+ }
122
+ function E(n, e = 2) {
123
+ const r = Number(c(n == null ? void 0 : n.options).precision);
124
+ return Number.isFinite(r) ? Math.min(Math.max(Math.trunc(r), 0), 10) : e;
125
+ }
126
+ export {
127
+ g as isReferenceName,
128
+ d as nameWords,
129
+ S as numberCurrencyOf,
130
+ E as numberDecimalsOf,
131
+ b as numberKindOf,
132
+ w as numberKindOfValue
133
+ };
@@ -15,7 +15,7 @@ function M(t) {
15
15
  }
16
16
  o = t;
17
17
  }
18
- function I() {
18
+ function b() {
19
19
  return o;
20
20
  }
21
21
  const _ = /* @__PURE__ */ new Set(["1899-12-30", "1900-01-01"]);
@@ -24,7 +24,7 @@ function f(t) {
24
24
  const n = t instanceof Date ? Number.isNaN(t.getTime()) ? "" : t.toISOString() : String(t);
25
25
  return _.has(n.slice(0, 10));
26
26
  }
27
- function b(t, n) {
27
+ function I(t, n) {
28
28
  if (f(t)) return "";
29
29
  const e = typeof t == "string" ? t.match(/^(\d{4})-(\d{2})-(\d{2})(?:T00:00:00(?:\.000)?Z)?$/) : null, r = e ? new Date(Number(e[1]), Number(e[2]) - 1, Number(e[3])) : new Date(t);
30
30
  return new Intl.DateTimeFormat("en-US", {
@@ -73,13 +73,16 @@ function y(t) {
73
73
  a = "en-US";
74
74
  l = (t == null ? void 0 : t.compact) === !0;
75
75
  }
76
- function U(t, n) {
76
+ function U() {
77
+ return a;
78
+ }
79
+ function E(t, n) {
77
80
  const e = n.trim().toLowerCase();
78
81
  if (!e) return !0;
79
82
  const r = t.toLowerCase();
80
83
  return e.split(/\s+/).every((i) => r.includes(i));
81
84
  }
82
- function E(t) {
85
+ function C(t) {
83
86
  if (t == null || Number.isNaN(t)) return "—";
84
87
  const n = Math.max(0, t);
85
88
  if (n < 1) return `${Math.max(1, Math.round(n * 60))}m`;
@@ -93,7 +96,7 @@ function E(t) {
93
96
  const r = Math.floor(e / 30), i = Math.round(e - r * 30);
94
97
  return i > 0 ? `${r}mo ${i}d` : `${r}mo`;
95
98
  }
96
- function C(t) {
99
+ function O(t) {
97
100
  if (s === "exact") return m(t);
98
101
  const n = new Date(t), e = g() - n.getTime(), r = Math.floor(e / 6e4);
99
102
  if (r < 1) return "just now";
@@ -114,23 +117,23 @@ const d = {
114
117
  }, S = {
115
118
  _and: [...d._and, { account_kind: { _null: !0 } }]
116
119
  };
117
- function O(t) {
120
+ function Z(t) {
118
121
  return t ? d : S;
119
122
  }
120
- function Z(t) {
123
+ function A(t) {
121
124
  const n = String(t ?? "");
122
125
  return n.startsWith("$t:") ? T(n.slice(3).replace(/-/g, "_")) : n;
123
126
  }
124
- function A(t) {
127
+ function R(t) {
125
128
  return t == null ? "—" : l && Math.abs(t) >= 1e4 ? new Intl.NumberFormat(a, {
126
129
  notation: "compact",
127
130
  maximumFractionDigits: 1
128
131
  }).format(t) : t.toLocaleString(a);
129
132
  }
130
- function R(t) {
133
+ function B(t) {
131
134
  return t == null ? "—" : t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : t < 1024 * 1024 * 1024 ? `${(t / (1024 * 1024)).toFixed(1)} MB` : `${(t / (1024 * 1024 * 1024)).toFixed(2)} GB`;
132
135
  }
133
- function B(t) {
136
+ function P(t) {
134
137
  if (!t) return null;
135
138
  const n = t.split("-").map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("");
136
139
  return N[n];
@@ -138,22 +141,23 @@ function B(t) {
138
141
  export {
139
142
  d as ACTIVE_USER_OPTION_FILTER,
140
143
  S as PEOPLE_USER_OPTION_FILTER,
141
- Z as choiceLabel,
144
+ A as choiceLabel,
142
145
  F as cn,
143
- b as formatDate,
146
+ I as formatDate,
144
147
  m as formatDateTime,
145
- R as formatFileSize,
146
- A as formatNumber,
147
- C as formatRelative,
148
- I as getDisplayTimezone,
149
- E as humanHours,
148
+ B as formatFileSize,
149
+ R as formatNumber,
150
+ O as formatRelative,
151
+ b as getDisplayTimezone,
152
+ C as humanHours,
150
153
  f as isNullDate,
151
- U as matchesAllTokens,
152
- B as resolveCollectionIcon,
154
+ E as matchesAllTokens,
155
+ U as numberLocale,
156
+ P as resolveCollectionIcon,
153
157
  M as setDisplayTimezone,
154
158
  y as setNumberFormat,
155
159
  x as setTimeDisplay,
156
160
  T as titleCase,
157
161
  L as toLocalDateString,
158
- O as userOptionFilter
162
+ Z as userOptionFilter
159
163
  };
@@ -4,7 +4,7 @@ import { useOptionalNivaroClient as z } from "../context.js";
4
4
  import { post as p, del as M, patch as D, put as ie, get as re } from "./commands.js";
5
5
  import { toastError as $ } from "./error-toast.js";
6
6
  const oe = {
7
- state: "open",
7
+ state: "closed",
8
8
  width: 320,
9
9
  tab: "watching",
10
10
  sort: "mine"
@@ -1,19 +1,33 @@
1
- function n(t, r) {
2
- return t == null ? "—" : typeof t == "number" ? r === "currency" ? new Intl.NumberFormat(void 0, {
3
- minimumFractionDigits: 2,
4
- maximumFractionDigits: 2
5
- }).format(t) : r === "integer" ? new Intl.NumberFormat().format(Math.round(t)) : r === "percent" ? `${new Intl.NumberFormat(void 0, {
6
- minimumFractionDigits: 1,
7
- maximumFractionDigits: 1
8
- }).format(t)}%` : new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }).format(t) : String(t);
1
+ import { toFiniteNumber as m, formatCurrency as o } from "./number-format.js";
2
+ function u(t) {
3
+ const r = String(t ?? "").trim();
4
+ return r === "$" || r === "US$" || r.toUpperCase() === "USD";
9
5
  }
10
- function i(t, r) {
6
+ function c(t, r, e) {
7
+ if (t == null) return "—";
8
+ const n = typeof t == "number" ? t : r ? m(t) : null;
9
+ if (n != null && Number.isFinite(n)) {
10
+ if (r === "currency") {
11
+ const i = String((e == null ? void 0 : e.prefix) ?? "").trim();
12
+ return i && !u(i) ? new Intl.NumberFormat(void 0, {
13
+ minimumFractionDigits: 2,
14
+ maximumFractionDigits: 2
15
+ }).format(n) : o(n);
16
+ }
17
+ return r === "integer" ? new Intl.NumberFormat().format(Math.round(n)) : r === "percent" ? `${new Intl.NumberFormat(void 0, {
18
+ minimumFractionDigits: 1,
19
+ maximumFractionDigits: 1
20
+ }).format(n)}%` : new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }).format(n);
21
+ }
22
+ return String(t);
23
+ }
24
+ function x(t, r) {
11
25
  return t == null ? { prefix: "", suffix: "" } : {
12
- prefix: String((r == null ? void 0 : r.prefix) ?? ""),
26
+ prefix: (r == null ? void 0 : r.format) === "currency" && u(r == null ? void 0 : r.prefix) ? "" : String((r == null ? void 0 : r.prefix) ?? ""),
13
27
  suffix: String((r == null ? void 0 : r.suffix) ?? "")
14
28
  };
15
29
  }
16
30
  export {
17
- i as affixesFor,
18
- n as formatWidgetValue
31
+ x as affixesFor,
32
+ c as formatWidgetValue
19
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.139",
3
+ "version": "0.3.140",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",