basalt-ui 2.13.3 → 2.15.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.
Files changed (187) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/MIGRATING.md +42 -12
  3. package/agent/agents/basalt-design-reviewer.md +83 -0
  4. package/agent/rules/basalt-batteries.md +1 -2
  5. package/agent/rules/basalt-charts.md +1 -1
  6. package/agent/rules/basalt-controls.md +3 -3
  7. package/agent/rules/basalt-mantine.md +1 -2
  8. package/agent/rules/basalt-state.md +1 -2
  9. package/agent/rules/basalt-tokens.md +1 -3
  10. package/agent/skills/basalt-design/SKILL.md +26 -8
  11. package/agent/templates/AGENTS-block.md.tpl +7 -0
  12. package/configs/oxlint-plugin.js +39 -2
  13. package/configs/oxlint-plugin.test.ts +48 -0
  14. package/dist/agent/chat/thread-feed-row.d.ts.map +1 -1
  15. package/dist/agent/chat/thread-feed-row.js +2 -2
  16. package/dist/agent/chat/thread-message.d.ts.map +1 -1
  17. package/dist/agent/chat/thread-message.js +2 -2
  18. package/dist/agent/chat/thread-outcome-card.js +2 -2
  19. package/dist/charts/DualPanel.d.ts.map +1 -1
  20. package/dist/charts/DualPanel.js +1 -0
  21. package/dist/charts/compile.d.ts.map +1 -1
  22. package/dist/charts/compile.js +3 -2
  23. package/dist/charts/cursor.d.ts +10 -6
  24. package/dist/charts/cursor.d.ts.map +1 -1
  25. package/dist/charts/cursor.js +20 -13
  26. package/dist/charts/legend.d.ts +7 -6
  27. package/dist/charts/legend.d.ts.map +1 -1
  28. package/dist/charts/legend.js +3 -3
  29. package/dist/charts/panel.d.ts +2 -0
  30. package/dist/charts/panel.d.ts.map +1 -1
  31. package/dist/charts/panel.js +1 -0
  32. package/dist/cli/board-freshness.d.ts +25 -0
  33. package/dist/cli/board-freshness.d.ts.map +1 -0
  34. package/dist/cli/board-freshness.js +88 -0
  35. package/dist/cli/doctor.d.ts +2 -1
  36. package/dist/cli/doctor.d.ts.map +1 -1
  37. package/dist/cli/doctor.js +3 -1
  38. package/dist/cli/help.d.ts.map +1 -1
  39. package/dist/cli/help.js +9 -3
  40. package/dist/cli/index.d.ts +15 -1
  41. package/dist/cli/index.d.ts.map +1 -1
  42. package/dist/cli/index.js +57 -7
  43. package/dist/cli/init.d.ts.map +1 -1
  44. package/dist/cli/init.js +6 -1
  45. package/dist/cli/shot/board.d.ts +5 -0
  46. package/dist/cli/shot/board.d.ts.map +1 -0
  47. package/dist/cli/shot/board.js +96 -0
  48. package/dist/cli/shot/capture.d.ts +59 -0
  49. package/dist/cli/shot/capture.d.ts.map +1 -0
  50. package/dist/cli/shot/capture.js +473 -0
  51. package/dist/cli/shot/index.d.ts +45 -0
  52. package/dist/cli/shot/index.d.ts.map +1 -0
  53. package/dist/cli/shot/index.js +289 -0
  54. package/dist/cli/shot/measure.d.ts +28 -0
  55. package/dist/cli/shot/measure.d.ts.map +1 -0
  56. package/dist/cli/shot/measure.js +176 -0
  57. package/dist/cli/shot/playwright.d.ts +101 -0
  58. package/dist/cli/shot/playwright.d.ts.map +1 -0
  59. package/dist/cli/shot/playwright.js +60 -0
  60. package/dist/cli/shot/serve.d.ts +6 -0
  61. package/dist/cli/shot/serve.d.ts.map +1 -0
  62. package/dist/cli/shot/serve.js +33 -0
  63. package/dist/cli/shot/types.d.ts +97 -0
  64. package/dist/cli/shot/types.d.ts.map +1 -0
  65. package/dist/cli/shot/types.js +17 -0
  66. package/dist/cli/sync.d.ts.map +1 -1
  67. package/dist/cli/sync.js +2 -1
  68. package/dist/commands/notifications/center.d.ts.map +1 -1
  69. package/dist/commands/notifications/center.js +2 -11
  70. package/dist/controls/control-name.d.ts +27 -0
  71. package/dist/controls/control-name.d.ts.map +1 -0
  72. package/dist/controls/control-name.js +11 -0
  73. package/dist/controls/enum-filter.d.ts +3 -6
  74. package/dist/controls/enum-filter.d.ts.map +1 -1
  75. package/dist/controls/enum-filter.js +8 -4
  76. package/dist/controls/filter-base.d.ts +30 -0
  77. package/dist/controls/filter-base.d.ts.map +1 -0
  78. package/dist/controls/filter-base.js +0 -0
  79. package/dist/controls/filter-pill.d.ts +3 -1
  80. package/dist/controls/filter-pill.d.ts.map +1 -1
  81. package/dist/controls/filter-pill.js +2 -0
  82. package/dist/controls/filter-sheet.d.ts +0 -32
  83. package/dist/controls/filter-sheet.d.ts.map +1 -1
  84. package/dist/controls/filter-sheet.js +1 -28
  85. package/dist/controls/glyphs.d.ts +12 -0
  86. package/dist/controls/glyphs.d.ts.map +1 -1
  87. package/dist/controls/glyphs.js +23 -2
  88. package/dist/controls/index.d.ts +2 -1
  89. package/dist/controls/index.d.ts.map +1 -1
  90. package/dist/controls/multi-select-filter.d.ts +8 -3
  91. package/dist/controls/multi-select-filter.d.ts.map +1 -1
  92. package/dist/controls/multi-select-filter.js +27 -10
  93. package/dist/controls/number-filter.d.ts +3 -12
  94. package/dist/controls/number-filter.d.ts.map +1 -1
  95. package/dist/controls/number-filter.js +17 -6
  96. package/dist/controls/panel-row.d.ts +5 -8
  97. package/dist/controls/panel-row.d.ts.map +1 -1
  98. package/dist/controls/panel-row.js +3 -0
  99. package/dist/controls/range-filter.d.ts +14 -14
  100. package/dist/controls/range-filter.d.ts.map +1 -1
  101. package/dist/controls/range-filter.js +18 -41
  102. package/dist/controls/search-filter.d.ts +5 -2
  103. package/dist/controls/search-filter.d.ts.map +1 -1
  104. package/dist/controls/search-filter.js +74 -40
  105. package/dist/controls/select-filter.d.ts +2 -15
  106. package/dist/controls/select-filter.d.ts.map +1 -1
  107. package/dist/controls/sync-button.d.ts +0 -6
  108. package/dist/controls/sync-button.d.ts.map +1 -1
  109. package/dist/controls/sync-button.js +6 -36
  110. package/dist/controls/toggle-filter.d.ts +2 -2
  111. package/dist/controls/toggle-filter.d.ts.map +1 -1
  112. package/dist/controls/toggle-filter.js +3 -2
  113. package/dist/controls/view-tabs.d.ts +3 -4
  114. package/dist/controls/view-tabs.d.ts.map +1 -1
  115. package/dist/controls/view-tabs.js +24 -5
  116. package/dist/format/date.d.ts +43 -10
  117. package/dist/format/date.d.ts.map +1 -1
  118. package/dist/format/date.js +109 -18
  119. package/dist/format/index.d.ts +12 -11
  120. package/dist/format/index.d.ts.map +1 -1
  121. package/dist/format/index.js +11 -2
  122. package/dist/format/measure.d.ts +9 -9
  123. package/dist/format/measure.d.ts.map +1 -1
  124. package/dist/format/measure.js +19 -8
  125. package/dist/format/number.d.ts +35 -27
  126. package/dist/format/number.d.ts.map +1 -1
  127. package/dist/format/number.js +41 -20
  128. package/dist/format/shared.d.ts +38 -7
  129. package/dist/format/shared.d.ts.map +1 -1
  130. package/dist/format/shared.js +61 -13
  131. package/dist/provider/index.d.ts +13 -1
  132. package/dist/provider/index.d.ts.map +1 -1
  133. package/dist/provider/index.js +8 -0
  134. package/dist/surfaces.d.ts +2 -0
  135. package/dist/surfaces.d.ts.map +1 -1
  136. package/dist/surfaces.js +2 -0
  137. package/llms.txt +35 -14
  138. package/package.json +1 -1
  139. package/src/agent/chat/thread-feed-row.tsx +2 -2
  140. package/src/agent/chat/thread-message.tsx +2 -2
  141. package/src/agent/chat/thread-outcome-card.tsx +2 -2
  142. package/src/charts/DualPanel.tsx +1 -0
  143. package/src/charts/compile.ts +3 -2
  144. package/src/charts/cursor.ts +44 -27
  145. package/src/charts/legend.tsx +11 -8
  146. package/src/charts/panel.tsx +3 -0
  147. package/src/cli/board-freshness.ts +132 -0
  148. package/src/cli/doctor.ts +10 -1
  149. package/src/cli/help.ts +14 -2
  150. package/src/cli/index.ts +80 -10
  151. package/src/cli/init.ts +8 -1
  152. package/src/cli/shot/board.ts +154 -0
  153. package/src/cli/shot/capture.ts +650 -0
  154. package/src/cli/shot/index.ts +362 -0
  155. package/src/cli/shot/measure.ts +225 -0
  156. package/src/cli/shot/playwright.ts +152 -0
  157. package/src/cli/shot/serve.ts +35 -0
  158. package/src/cli/shot/types.ts +91 -0
  159. package/src/cli/sync.ts +2 -1
  160. package/src/commands/notifications/center.tsx +2 -14
  161. package/src/controls/control-name.ts +33 -0
  162. package/src/controls/enum-filter.tsx +29 -27
  163. package/src/controls/filter-base.ts +31 -0
  164. package/src/controls/filter-pill.tsx +4 -0
  165. package/src/controls/filter-sheet.tsx +0 -56
  166. package/src/controls/glyphs.tsx +45 -2
  167. package/src/controls/index.ts +2 -1
  168. package/src/controls/multi-select-filter.tsx +67 -43
  169. package/src/controls/number-filter.tsx +47 -47
  170. package/src/controls/panel-row.tsx +7 -8
  171. package/src/controls/range-filter.tsx +54 -78
  172. package/src/controls/search-filter.tsx +107 -54
  173. package/src/controls/select-filter.tsx +2 -18
  174. package/src/controls/sync-button.tsx +7 -40
  175. package/src/controls/toggle-filter.tsx +9 -7
  176. package/src/controls/view-tabs.tsx +41 -21
  177. package/src/format/date.ts +189 -36
  178. package/src/format/index.ts +12 -11
  179. package/src/format/measure.ts +29 -18
  180. package/src/format/number.ts +76 -37
  181. package/src/format/shared.ts +116 -25
  182. package/src/provider/index.tsx +23 -0
  183. package/src/surfaces.ts +5 -0
  184. package/dist/agent/chat/relative-time.d.ts +0 -27
  185. package/dist/agent/chat/relative-time.d.ts.map +0 -1
  186. package/dist/agent/chat/relative-time.js +0 -27
  187. package/src/agent/chat/relative-time.ts +0 -55
@@ -1,39 +1,98 @@
1
- import { dateFormat, NON_FINITE, toDate } from "./shared.js";
1
+ import { dateFormat, NON_FINITE, numberFormat, toDate } from "./shared.js";
2
+ const CALENDAR_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
3
+ function calendarDate(value, utc) {
4
+ const match = CALENDAR_DATE.exec(value);
5
+ if (match === null) return void 0;
6
+ const year = Number(match[1]);
7
+ const month = Number(match[2]) - 1;
8
+ const day = Number(match[3]);
9
+ const result = /* @__PURE__ */ new Date(0);
10
+ if (utc) {
11
+ result.setUTCFullYear(year, month, day);
12
+ result.setUTCHours(0, 0, 0, 0);
13
+ const ok2 = result.getUTCFullYear() === year && result.getUTCMonth() === month && result.getUTCDate() === day;
14
+ return ok2 ? result : null;
15
+ }
16
+ result.setFullYear(year, month, day);
17
+ result.setHours(0, 0, 0, 0);
18
+ const ok = result.getFullYear() === year && result.getMonth() === month && result.getDate() === day;
19
+ return ok ? result : null;
20
+ }
2
21
  function weekday(value, options = {}) {
3
- const date = typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value) ? (() => {
4
- const [y, m, d] = value.split("-").map(Number);
5
- return new Date(y ?? 1970, (m ?? 1) - 1, d ?? 1);
6
- })() : toDate(value);
7
- if (date === null) return NON_FINITE;
22
+ const parsed = typeof value === "string" ? calendarDate(value, false) : void 0;
23
+ const resolved = parsed === void 0 ? toDate(value) : parsed;
24
+ if (resolved === null) return NON_FINITE;
8
25
  const { locale, format = "short" } = options;
9
- return dateFormat(locale, { weekday: format }).format(date);
26
+ return dateFormat(locale, { weekday: format }).format(resolved);
10
27
  }
28
+ const MINUTE_MS = 6e4;
11
29
  const RELATIVE_TIME_UNITS = [
12
30
  { unit: "year", ms: 31536e6 },
13
31
  { unit: "month", ms: 2628e6 },
14
32
  { unit: "week", ms: 6048e5 },
15
33
  { unit: "day", ms: 864e5 },
16
34
  { unit: "hour", ms: 36e5 },
17
- { unit: "minute", ms: 6e4 }
35
+ { unit: "minute", ms: MINUTE_MS }
18
36
  ];
37
+ const NEGATIVE_ZERO = -0;
19
38
  const relativeTimeFormatterCache = /* @__PURE__ */ new Map();
20
- function relativeTimeFormat(locale) {
21
- const key = locale ?? "";
39
+ function relativeTimeFormat(locale, style, numeric) {
40
+ const key = `${locale ?? ""}|${style}|${numeric}`;
22
41
  const cached = relativeTimeFormatterCache.get(key);
23
42
  if (cached !== void 0) return cached;
24
- const created = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
43
+ const created = new Intl.RelativeTimeFormat(locale, { style, numeric });
25
44
  relativeTimeFormatterCache.set(key, created);
26
45
  return created;
27
46
  }
28
47
  function relativeTime(value, options = {}) {
29
- const { locale, now = Date.now() } = options;
30
- const timestamp = value instanceof Date ? value.getTime() : typeof value === "number" ? value : Date.parse(value);
31
- if (!Number.isFinite(timestamp)) return NON_FINITE;
48
+ const { locale, style = "long", numeric = "auto", now = Date.now() } = options;
49
+ const timestamp = value === null || value === void 0 ? void 0 : toDate(value)?.getTime();
50
+ if (timestamp === void 0) return NON_FINITE;
51
+ const formatter = relativeTimeFormat(locale, style, numeric);
32
52
  const diffMs = timestamp - now;
33
- const absMs = Math.abs(diffMs);
34
- if (absMs < 6e4) return "just now";
35
- const unit = RELATIVE_TIME_UNITS.find(({ ms }) => absMs >= ms) ?? RELATIVE_TIME_UNITS.at(-1);
36
- return relativeTimeFormat(locale).format(Math.round(diffMs / unit.ms), unit.unit);
53
+ const magnitude = Math.abs(diffMs);
54
+ const sign = diffMs < 0 ? -1 : 1;
55
+ const index = RELATIVE_TIME_UNITS.findIndex(({ ms }) => magnitude >= ms);
56
+ const picked = RELATIVE_TIME_UNITS[index];
57
+ if (picked !== void 0) {
58
+ const larger = RELATIVE_TIME_UNITS[index - 1];
59
+ const unit = larger !== void 0 && Math.round(magnitude / picked.ms) * picked.ms >= larger.ms ? larger : picked;
60
+ return formatter.format(sign * Math.round(magnitude / unit.ms), unit.unit);
61
+ }
62
+ return formatter.format(diffMs < 0 ? NEGATIVE_ZERO : 0, "second");
63
+ }
64
+ function resolveDateInput(value, timeZone) {
65
+ if (value === null || value === void 0) return null;
66
+ const calendar = typeof value === "string" ? calendarDate(value, true) : void 0;
67
+ if (calendar !== void 0) return calendar === null ? null : { date: calendar, timeZone: "UTC" };
68
+ const parsed = toDate(value);
69
+ return parsed === null ? null : { date: parsed, timeZone };
70
+ }
71
+ function date(value, options = {}) {
72
+ const resolved = resolveDateInput(value, options.timeZone);
73
+ if (resolved === null) return NON_FINITE;
74
+ const { locale, format = "medium" } = options;
75
+ return dateFormat(locale, { dateStyle: format, timeZone: resolved.timeZone }).format(
76
+ resolved.date
77
+ );
78
+ }
79
+ function time(value, options = {}) {
80
+ const resolved = resolveDateInput(value, options.timeZone);
81
+ if (resolved === null) return NON_FINITE;
82
+ const { locale, format = "medium" } = options;
83
+ return dateFormat(locale, { timeStyle: format, timeZone: resolved.timeZone }).format(
84
+ resolved.date
85
+ );
86
+ }
87
+ function dateTime(value, options = {}) {
88
+ const resolved = resolveDateInput(value, options.timeZone);
89
+ if (resolved === null) return NON_FINITE;
90
+ const { locale, format = "medium" } = options;
91
+ return dateFormat(locale, {
92
+ dateStyle: format,
93
+ timeStyle: format,
94
+ timeZone: resolved.timeZone
95
+ }).format(resolved.date);
37
96
  }
38
97
  function durationClock(seconds) {
39
98
  if (!Number.isFinite(seconds)) return NON_FINITE;
@@ -45,8 +104,40 @@ function durationClock(seconds) {
45
104
  const ss = String(s).padStart(2, "0");
46
105
  return h > 0 ? `${h}:${mm}:${ss}` : `${mm}:${ss}`;
47
106
  }
107
+ const DURATION_UNITS = [
108
+ { unit: "day", short: "d", seconds: 86400 },
109
+ { unit: "hour", short: "h", seconds: 3600 },
110
+ { unit: "minute", short: "m", seconds: 60 },
111
+ { unit: "second", short: "s", seconds: 1 }
112
+ ];
113
+ function duration(seconds, options = {}) {
114
+ if (seconds === null || seconds === void 0 || !Number.isFinite(seconds)) return NON_FINITE;
115
+ const { style = "clock", largest = "hour", locale } = options;
116
+ if (style === "clock") return durationClock(seconds);
117
+ const total = Math.max(0, Math.round(seconds));
118
+ const shown = DURATION_UNITS.slice(DURATION_UNITS.findIndex(({ unit }) => unit === largest));
119
+ const parts = shown.map(({ unit, short, seconds: size }, i) => {
120
+ const count = Math.floor(total / size);
121
+ const upper = shown[i - 1]?.seconds;
122
+ return { unit, short, value: upper === void 0 ? count : count % (upper / size) };
123
+ });
124
+ const firstNonZero = parts.findIndex(({ value }) => value > 0);
125
+ const start = firstNonZero === -1 ? parts.length - 1 : firstNonZero;
126
+ const end = firstNonZero === -1 ? start : parts.findLastIndex(({ value }) => value > 0);
127
+ return parts.slice(start, end + 1).map(({ unit, short, value }, i) => {
128
+ if (style === "long") {
129
+ return numberFormat(locale, { style: "unit", unit, unitDisplay: "long" }).format(value);
130
+ }
131
+ const digits = i === 0 ? String(value) : String(value).padStart(2, "0");
132
+ return `${digits}${short}`;
133
+ }).join(" ");
134
+ }
48
135
  export {
136
+ date,
137
+ dateTime,
138
+ duration,
49
139
  durationClock,
50
140
  relativeTime,
141
+ time,
51
142
  weekday
52
143
  };
@@ -1,24 +1,25 @@
1
1
  /**
2
- * `basalt-ui/format` — Mantine-free, React-free `Intl`-backed formatting. One implementation for
3
- * numbers/percentages/money, dates/times/durations and the two measurement units argo needed
4
- * (`km`/`kcal`) — replacing argo's `features/*\/{formatters,formulas,format}.ts` (~350 of 643
5
- * lines across four duration spellings) and the 1.x chart layer's own formatters (2.0's charts
6
- * import the internals directly).
2
+ * `basalt-ui/format` — Mantine-free, React-free `Intl`-backed formatting: numbers, percentages,
3
+ * money, bytes and signed deltas, dates and durations, and the two measurement units argo needed
4
+ * (`km`/`kcal`).
7
5
  *
8
- * Every formatter takes `(value, opts?)`; `locale` on every `opts` defaults to `undefined` —
9
- * `Intl`'s own "use the runtime's locale". Every non-finite/unparseable input prints the same
10
- * {@link NON_FINITE} em dash rather than `"NaN"` or throwing.
6
+ * Every formatter takes `(value, opts?)`. `locale` defaults to what `defineFormat` (or
7
+ * the provider's locale and time zone props) set, else the runtime's locale. That default is
8
+ * ONE value per process; pass `locale` per call to override it. Number formatters accept
9
+ * `null | undefined`, and every non-finite/unparseable input prints the same {@link NON_FINITE}
10
+ * em dash rather than `"NaN"` or throwing.
11
11
  *
12
12
  * @example
13
13
  * import { money, percent, durationClock, weekday, relativeTime } from 'basalt-ui/format'
14
14
  *
15
- * money(1234, { currency: 'USD' }) // "$1,234"
15
+ * money(1234, { currency: 'USD' }) // "$1,234.00"
16
16
  * percent(0.42) // "42%"
17
17
  * durationClock(3_723) // "1:02:03"
18
18
  * weekday('2026-09-02') // "Wed"
19
19
  * relativeTime(Date.now() - 3_600_000) // "1 hour ago"
20
20
  */
21
- export { integer, money, percent } from './number.js';
22
- export { durationClock, relativeTime, weekday } from './date.js';
21
+ export { bytes, compact, delta, integer, money, percent } from './number.js';
22
+ export { date, dateTime, duration, durationClock, relativeTime, time, weekday } from './date.js';
23
23
  export { kcal, km } from './measure.js';
24
+ export { defineFormat } from './shared.js';
24
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/format/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAC7D,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/format/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AACzE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAC7F,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA"}
@@ -1,7 +1,15 @@
1
- import { integer, money, percent } from "./number.js";
2
- import { durationClock, relativeTime, weekday } from "./date.js";
1
+ import { bytes, compact, delta, integer, money, percent } from "./number.js";
2
+ import { date, dateTime, duration, durationClock, relativeTime, time, weekday } from "./date.js";
3
3
  import { kcal, km } from "./measure.js";
4
+ import { defineFormat } from "./shared.js";
4
5
  export {
6
+ bytes,
7
+ compact,
8
+ date,
9
+ dateTime,
10
+ defineFormat,
11
+ delta,
12
+ duration,
5
13
  durationClock,
6
14
  integer,
7
15
  kcal,
@@ -9,5 +17,6 @@ export {
9
17
  money,
10
18
  percent,
11
19
  relativeTime,
20
+ time,
12
21
  weekday
13
22
  };
@@ -1,15 +1,15 @@
1
- export type KmOptions = {
1
+ import type { LocaleOption, Numeric } from './shared.js';
2
+ export type KmOptions = LocaleOption & {
2
3
  /** Fraction digits. Default 2 (`"5.30 km"`). */
3
4
  digits?: number;
4
5
  };
5
- /** Meters as kilometers — `"5.30 km"`. A non-finite value prints {@link NON_FINITE}. */
6
- export declare function km(meters: number, options?: KmOptions): string;
7
- export type KcalOptions = {
8
- /** Fraction digits once compacted to `k cal`. Default 2. Below 1000 kcal always rounds to a
9
- * whole number, matching the seed (`formatKcal`). */
6
+ /** Meters as kilometers — `"5.30 km"` (`"5,30 km"` in `de`). */
7
+ export declare function km(meters: Numeric, options?: KmOptions): string;
8
+ export type KcalOptions = LocaleOption & {
9
+ /** Max fraction digits once scaled to thousands. Default 2. Below 1000 always whole. */
10
10
  digits?: number;
11
11
  };
12
- /** Kilocalories, compacting to `"k cal"` above 1000 — `"842 kcal"`, `"1.24 k cal"`. A non-finite
13
- * value prints {@link NON_FINITE}. */
14
- export declare function kcal(value: number, options?: KcalOptions): string;
12
+ /** Kilocalories — `"842 kcal"`, and `"1.24k kcal"` from 1000 up. The unit string is always
13
+ * `kcal`. */
14
+ export declare function kcal(value: Numeric, options?: KcalOptions): string;
15
15
  //# sourceMappingURL=measure.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"measure.d.ts","sourceRoot":"","sources":["../../src/format/measure.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,SAAS,GAAG;IACtB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,wFAAwF;AACxF,wBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,SAAc,GAAG,MAAM,CAIlE;AAED,MAAM,MAAM,WAAW,GAAG;IACxB;yDACqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;sCACsC;AACtC,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAKrE"}
1
+ {"version":3,"file":"measure.d.ts","sourceRoot":"","sources":["../../src/format/measure.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAErD,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG;IACrC,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,gEAAgE;AAChE,wBAAgB,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,GAAE,SAAc,GAAG,MAAM,CAWnE;AAED,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG;IACvC,wFAAwF;IACxF,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;aACa;AACb,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAStE"}
@@ -1,14 +1,25 @@
1
- import { NON_FINITE } from "./shared.js";
1
+ import { isFiniteNumber, NON_FINITE, numberFormat, scaleThousands } from "./shared.js";
2
2
  function km(meters, options = {}) {
3
- if (!Number.isFinite(meters)) return NON_FINITE;
4
- const { digits = 2 } = options;
5
- return `${(meters / 1e3).toFixed(digits)} km`;
3
+ if (!isFiniteNumber(meters)) return NON_FINITE;
4
+ const { digits = 2, locale } = options;
5
+ return numberFormat(locale, {
6
+ signDisplay: "negative",
7
+ style: "unit",
8
+ unit: "kilometer",
9
+ unitDisplay: "short",
10
+ minimumFractionDigits: digits,
11
+ maximumFractionDigits: digits
12
+ }).format(meters / 1e3);
6
13
  }
7
14
  function kcal(value, options = {}) {
8
- if (!Number.isFinite(value)) return NON_FINITE;
9
- const { digits = 2 } = options;
10
- if (value >= 1e3) return `${(value / 1e3).toFixed(digits)} k cal`;
11
- return `${Math.round(value)} kcal`;
15
+ if (!isFiniteNumber(value)) return NON_FINITE;
16
+ const { digits = 2, locale } = options;
17
+ const { scaled, unit } = scaleThousands(value, digits, 1);
18
+ const text = numberFormat(locale, {
19
+ signDisplay: "negative",
20
+ maximumFractionDigits: unit === 0 ? 0 : digits
21
+ }).format(scaled);
22
+ return `${text}${unit === 0 ? "" : "k"} kcal`;
12
23
  }
13
24
  export {
14
25
  kcal,
@@ -1,30 +1,27 @@
1
1
  /**
2
2
  * Number formatting — `Intl.NumberFormat` with the arguments already decided, so a caller states
3
3
  * WHAT a number is rather than how to punctuate it. One implementation: the chart layer imports
4
- * `fmtCompact` from here for its default axis format.
5
- *
6
- * `money`/`percent`/`integer`/`compact`/`deltaPct` are the argo-facing names (seeded from
7
- * `features/*\/{formatters,formulas}.ts`); `fmtCurrency`/`fmtPercent`/`fmtInt`/`fmtCompact` are the
8
- * original chart-formatter names, internal since 2.0 and delegated to by the public names.
4
+ * `compact` from here for its default axis format. Every formatter accepts `null | undefined` and
5
+ * prints {@link NON_FINITE} for it (as for `NaN` / `±Infinity`).
9
6
  */
10
7
  import { NON_FINITE } from './shared.js';
11
- import type { LocaleOption } from './shared.js';
8
+ import type { LocaleOption, Numeric } from './shared.js';
12
9
  export type { LocaleOption };
13
10
  export { NON_FINITE };
14
- export type FmtCompactOptions = LocaleOption & {
15
- /** Significant-ish fraction digits on the compacted number. Default 1 (`1.2k`, `3.4M`). */
11
+ export type CompactOptions = LocaleOption & {
12
+ /** Fraction digits on the compacted number. Default 1 (`1.2k`, `3.4M`). */
16
13
  digits?: number;
17
14
  };
18
15
  /**
19
16
  * Compact notation: `1.2k`, `3.4M`, `-820`. The axis formatter for any count whose range spans
20
- * more than three digits. A non-finite value prints {@link NON_FINITE}.
17
+ * more than three digits.
21
18
  *
22
19
  * Note `Intl`'s compact notation is LOCALE text, not a suffix table: `en` gives `1.2K`, and this
23
20
  * lowercases the `K` to match the package's own numeral style while leaving every other locale's
24
21
  * word (`1,2 Mio.`) untouched.
25
22
  */
26
- export declare function fmtCompact(value: number, options?: FmtCompactOptions): string;
27
- export type FmtPercentOptions = LocaleOption & {
23
+ export declare function compact(value: Numeric, options?: CompactOptions): string;
24
+ export type PercentOptions = LocaleOption & {
28
25
  /** Fraction digits. Default 0 (`42%`). */
29
26
  digits?: number;
30
27
  /**
@@ -33,26 +30,37 @@ export type FmtPercentOptions = LocaleOption & {
33
30
  */
34
31
  input?: 'ratio' | 'percent';
35
32
  };
36
- /** Percentages, from either a ratio or an already-scaled percentage. A non-finite value prints
37
- * {@link NON_FINITE}. */
38
- export declare function fmtPercent(value: number, options?: FmtPercentOptions): string;
39
- /** `percent` — the `basalt-ui/format` name for {@link fmtPercent}. */
40
- export declare const percent: typeof fmtPercent;
41
- export type FmtCurrencyOptions = LocaleOption & {
33
+ /** Percentages, from either a ratio or an already-scaled percentage. */
34
+ export declare function percent(value: Numeric, options?: PercentOptions): string;
35
+ export type MoneyOptions = LocaleOption & {
42
36
  /** ISO 4217 code — required. There is no default currency. */
43
37
  currency: string;
44
38
  /** Compact notation for the amount (`$1.2k`). Default false. */
45
39
  compact?: boolean;
46
- /** Fraction digits. Default 0 compacted, else the currency's own default (`undefined`). */
40
+ /**
41
+ * Fraction digits. Unset → the currency's own default (USD 2, JPY 0) — or, compacted, up to 1.
42
+ * An explicit number (`0`) pins min and max: an opt-in to rounding away the cents.
43
+ */
44
+ digits?: number;
45
+ };
46
+ /** Money. `money(12.5, { currency: 'USD' })` → `$12.50`. */
47
+ export declare function money(value: Numeric, options: MoneyOptions): string;
48
+ /** Grouped integer: `12,480`. Rounds. */
49
+ export declare function integer(value: Numeric, options?: LocaleOption): string;
50
+ export type BytesOptions = LocaleOption & {
51
+ /** Max fraction digits. Default 1 (`1.2 MB`). */
52
+ digits?: number;
53
+ };
54
+ /**
55
+ * Byte sizes in DECIMAL (SI) units — `1 kB` is 1000 bytes, the convention of browsers' download
56
+ * UIs, storage vendors and `Intl`'s own `kilobyte`. `bytes(1_200_000)` → `1.2 MB`; below 1000 it
57
+ * prints whole bytes (`512 B`). Negative values keep their sign. The cap is `PB`.
58
+ */
59
+ export declare function bytes(value: Numeric, options?: BytesOptions): string;
60
+ export type DeltaOptions = LocaleOption & {
61
+ /** Max fraction digits. Default 1 (`+3.2`). */
47
62
  digits?: number;
48
63
  };
49
- /** Money. `fmtCurrency(1234, { currency: 'USD' })` → `$1,234`. A non-finite amount prints
50
- * {@link NON_FINITE}. */
51
- export declare function fmtCurrency(value: number, options: FmtCurrencyOptions): string;
52
- /** `money` — the `basalt-ui/format` name for {@link fmtCurrency}. */
53
- export declare const money: typeof fmtCurrency;
54
- /** Grouped integer: `12,480`. Rounds. A non-finite value prints {@link NON_FINITE}. */
55
- export declare function fmtInt(value: number, options?: LocaleOption): string;
56
- /** `integer` — the `basalt-ui/format` name for {@link fmtInt}. */
57
- export declare const integer: typeof fmtInt;
64
+ /** A signed change: `+3.2`, `-1`, `0`. Zero (and anything that rounds to it) carries no sign. */
65
+ export declare function delta(value: Numeric, options?: DeltaOptions): string;
58
66
  //# sourceMappingURL=number.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../src/format/number.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAgB,MAAM,UAAU,CAAA;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAE5C,YAAY,EAAE,YAAY,EAAE,CAAA;AAC5B,OAAO,EAAE,UAAU,EAAE,CAAA;AAMrB,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG;IAC7C,2FAA2F;IAC3F,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAUjF;AAED,MAAM,MAAM,iBAAiB,GAAG,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, numberFormat, scaleThousands } from "./shared.js";
2
2
  const COMPACT_K = /(\d\s?)K/;
3
- function fmtCompact(value, options = {}) {
4
- if (!Number.isFinite(value)) return NON_FINITE;
3
+ const SIGN = { signDisplay: "negative" };
4
+ function compact(value, options = {}) {
5
+ if (!isFiniteNumber(value)) return NON_FINITE;
5
6
  const { digits = 1, locale } = options;
6
7
  return numberFormat(locale, {
8
+ ...SIGN,
7
9
  notation: "compact",
8
10
  compactDisplay: "short",
9
11
  maximumFractionDigits: digits
10
12
  }).format(value).replace(COMPACT_K, "$1k");
11
13
  }
12
- function fmtPercent(value, options = {}) {
13
- if (!Number.isFinite(value)) return NON_FINITE;
14
+ function percent(value, options = {}) {
15
+ if (!isFiniteNumber(value)) return NON_FINITE;
14
16
  const { digits = 0, input = "ratio", locale } = options;
15
17
  return numberFormat(locale, {
18
+ ...SIGN,
16
19
  style: "percent",
17
20
  minimumFractionDigits: digits,
18
21
  maximumFractionDigits: digits
19
22
  }).format(input === "percent" ? value / 100 : value);
20
23
  }
21
- const percent = fmtPercent;
22
- function fmtCurrency(value, options) {
23
- if (!Number.isFinite(value)) return NON_FINITE;
24
+ function fractionDigitOptions(isCompact, digits) {
25
+ if (isCompact) return { minimumFractionDigits: 0, maximumFractionDigits: digits ?? 1 };
26
+ if (digits === void 0) return {};
27
+ return { minimumFractionDigits: digits, maximumFractionDigits: digits };
28
+ }
29
+ function money(value, options) {
30
+ if (!isFiniteNumber(value)) return NON_FINITE;
24
31
  const { currency, compact: isCompact = false, digits, locale } = options;
25
- const fractionDigits = digits ?? (isCompact ? 1 : 0);
26
32
  return numberFormat(locale, {
33
+ ...SIGN,
27
34
  style: "currency",
28
35
  currency,
29
36
  ...isCompact && { notation: "compact", compactDisplay: "short" },
30
- minimumFractionDigits: isCompact ? 0 : fractionDigits,
31
- maximumFractionDigits: fractionDigits
37
+ ...fractionDigitOptions(isCompact, digits)
32
38
  }).format(value).replace(COMPACT_K, "$1k");
33
39
  }
34
- const money = fmtCurrency;
35
- function fmtInt(value, options = {}) {
36
- if (!Number.isFinite(value)) return NON_FINITE;
37
- return numberFormat(options.locale, { maximumFractionDigits: 0 }).format(value);
40
+ function integer(value, options = {}) {
41
+ if (!isFiniteNumber(value)) return NON_FINITE;
42
+ return numberFormat(options.locale, { ...SIGN, maximumFractionDigits: 0 }).format(value);
43
+ }
44
+ const BYTE_UNITS = ["B", "kB", "MB", "GB", "TB", "PB"];
45
+ function bytes(value, options = {}) {
46
+ if (!isFiniteNumber(value)) return NON_FINITE;
47
+ const { digits = 1, locale } = options;
48
+ const { scaled, unit } = scaleThousands(value, digits, BYTE_UNITS.length - 1);
49
+ const text = numberFormat(locale, {
50
+ ...SIGN,
51
+ maximumFractionDigits: unit === 0 ? 0 : digits
52
+ }).format(scaled);
53
+ return `${text} ${BYTE_UNITS[unit]}`;
54
+ }
55
+ function delta(value, options = {}) {
56
+ if (!isFiniteNumber(value)) return NON_FINITE;
57
+ const { digits = 1, locale } = options;
58
+ return numberFormat(locale, { signDisplay: "exceptZero", maximumFractionDigits: digits }).format(
59
+ value
60
+ );
38
61
  }
39
- const integer = fmtInt;
40
62
  export {
41
63
  NON_FINITE,
42
- fmtCompact,
43
- fmtCurrency,
44
- fmtInt,
45
- fmtPercent,
64
+ bytes,
65
+ compact,
66
+ delta,
46
67
  integer,
47
68
  money,
48
69
  percent
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Shared low-level pieces of `basalt-ui/format` — the em-dash sentinel and the memoized
3
- * `Intl.NumberFormat` cache every number formatter in this module reuses. Moved here (out of
4
- * `src/charts/utils/format.ts`, C5 consolidation) so the subpath is the single implementation;
5
- * 2.0's chart layer imports it directly (`docs/V2-SPEC.md` § 9).
2
+ * Shared low-level pieces of `basalt-ui/format`: the {@link NON_FINITE} sentinel, the default
3
+ * locale / time zone ({@link defineFormat}), the memoized `Intl` caches and the number-input
4
+ * guard every formatter in this module reuses. The subpath is the single implementation; the chart
5
+ * layer imports it directly (`docs/V2-SPEC.md` § 9).
6
6
  */
7
7
  /**
8
8
  * What EVERY formatter in this module prints for input it cannot represent — `NaN`, `±Infinity`,
@@ -10,13 +10,44 @@
10
10
  * number that is not one.
11
11
  */
12
12
  export declare const NON_FINITE = "\u2014";
13
- /** Options every number formatter here accepts. */
13
+ /** Options every number/measure formatter accepts. */
14
14
  export type LocaleOption = {
15
- /** BCP-47 tag. Default `undefined` — the runtime's own locale. */
16
- locale?: string;
15
+ /** BCP-47 tag. Default: the {@link defineFormat} default, else the runtime's own locale. */
16
+ locale?: string | undefined;
17
17
  };
18
+ export type FormatDefaults = {
19
+ /** BCP-47 tag every formatter uses when a call passes none. */
20
+ locale?: string | undefined;
21
+ /** IANA time zone every date formatter uses when a call passes none. */
22
+ timeZone?: string | undefined;
23
+ };
24
+ /**
25
+ * Sets the locale / time zone every formatter in `basalt-ui/format` falls back to when a call
26
+ * passes none. Merges: only DEFINED fields are applied, `undefined` leaves the earlier value.
27
+ *
28
+ * The default is ONE module-global per process (formatters are plain functions, not hooks), so it
29
+ * is an app-wide setting, not a per-request one — a server rendering many locales passes `locale`
30
+ * per call instead. `BasaltProvider`'s `locale` / `timeZone` props call this.
31
+ */
32
+ export declare function defineFormat(next?: FormatDefaults): void;
33
+ /** Clears the {@link defineFormat} defaults back to the runtime's own locale and zone. */
34
+ export declare function resetFormatDefaults(): void;
18
35
  export declare function numberFormat(locale: string | undefined, options: Intl.NumberFormatOptions): Intl.NumberFormat;
19
36
  export declare function dateFormat(locale: string | undefined, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
37
+ /** What every number/measure formatter accepts. */
38
+ export type Numeric = number | null | undefined;
39
+ /** True for a finite number; `null`, `undefined`, `NaN` and `±Infinity` are the inputs every
40
+ * number/measure formatter answers with {@link NON_FINITE}. */
41
+ export declare function isFiniteNumber(value: Numeric): value is number;
42
+ /**
43
+ * Scales `value` down by 1000 per step (up to `maxUnit`) and returns the step. Rounds FIRST, then
44
+ * promotes when the rounded magnitude reaches 1000 — `999.6` at step 0 is `1000` and belongs to
45
+ * the next unit, not `1,000 B`. Step 0 is whole numbers; higher steps round to `digits`.
46
+ */
47
+ export declare function scaleThousands(value: number, digits: number, maxUnit: number): {
48
+ scaled: number;
49
+ unit: number;
50
+ };
20
51
  /** Coerces the flexible `Date | number | string` inputs this module's date formatters accept into
21
52
  * a `Date`. A `number` is treated as epoch milliseconds (matching `Date`'s own constructor and
22
53
  * `agent-chat/relative-time.ts`'s prior contract) — a caller with epoch seconds multiplies by
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/format/shared.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,eAAO,MAAM,UAAU,WAAM,CAAA;AAE7B,mDAAmD;AACnD,MAAM,MAAM,YAAY,GAAG;IACzB,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AASD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,IAAI,CAAC,mBAAmB,GAChC,IAAI,CAAC,YAAY,CAOnB;AAID,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,IAAI,CAAC,qBAAqB,GAClC,IAAI,CAAC,cAAc,CAOrB;AAED;;;;0DAI0D;AAC1D,wBAAgB,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,CAGjE"}
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/format/shared.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,eAAO,MAAM,UAAU,WAAM,CAAA;AAE7B,sDAAsD;AACtD,MAAM,MAAM,YAAY,GAAG;IACzB,4FAA4F;IAC5F,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,+DAA+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