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.
- package/CHANGELOG.md +66 -0
- package/MIGRATING.md +42 -12
- package/agent/agents/basalt-design-reviewer.md +83 -0
- package/agent/rules/basalt-batteries.md +1 -2
- package/agent/rules/basalt-charts.md +1 -1
- package/agent/rules/basalt-controls.md +3 -3
- package/agent/rules/basalt-mantine.md +1 -2
- package/agent/rules/basalt-state.md +1 -2
- package/agent/rules/basalt-tokens.md +1 -3
- package/agent/skills/basalt-design/SKILL.md +26 -8
- package/agent/templates/AGENTS-block.md.tpl +7 -0
- package/configs/oxlint-plugin.js +39 -2
- package/configs/oxlint-plugin.test.ts +48 -0
- package/dist/agent/chat/thread-feed-row.d.ts.map +1 -1
- package/dist/agent/chat/thread-feed-row.js +2 -2
- package/dist/agent/chat/thread-message.d.ts.map +1 -1
- package/dist/agent/chat/thread-message.js +2 -2
- package/dist/agent/chat/thread-outcome-card.js +2 -2
- package/dist/charts/DualPanel.d.ts.map +1 -1
- package/dist/charts/DualPanel.js +1 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +3 -2
- package/dist/charts/cursor.d.ts +10 -6
- package/dist/charts/cursor.d.ts.map +1 -1
- package/dist/charts/cursor.js +20 -13
- package/dist/charts/legend.d.ts +7 -6
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +3 -3
- package/dist/charts/panel.d.ts +2 -0
- package/dist/charts/panel.d.ts.map +1 -1
- package/dist/charts/panel.js +1 -0
- package/dist/cli/board-freshness.d.ts +25 -0
- package/dist/cli/board-freshness.d.ts.map +1 -0
- package/dist/cli/board-freshness.js +88 -0
- package/dist/cli/doctor.d.ts +2 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +3 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +9 -3
- package/dist/cli/index.d.ts +15 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +57 -7
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +6 -1
- package/dist/cli/shot/board.d.ts +5 -0
- package/dist/cli/shot/board.d.ts.map +1 -0
- package/dist/cli/shot/board.js +96 -0
- package/dist/cli/shot/capture.d.ts +59 -0
- package/dist/cli/shot/capture.d.ts.map +1 -0
- package/dist/cli/shot/capture.js +473 -0
- package/dist/cli/shot/index.d.ts +45 -0
- package/dist/cli/shot/index.d.ts.map +1 -0
- package/dist/cli/shot/index.js +289 -0
- package/dist/cli/shot/measure.d.ts +28 -0
- package/dist/cli/shot/measure.d.ts.map +1 -0
- package/dist/cli/shot/measure.js +176 -0
- package/dist/cli/shot/playwright.d.ts +101 -0
- package/dist/cli/shot/playwright.d.ts.map +1 -0
- package/dist/cli/shot/playwright.js +60 -0
- package/dist/cli/shot/serve.d.ts +6 -0
- package/dist/cli/shot/serve.d.ts.map +1 -0
- package/dist/cli/shot/serve.js +33 -0
- package/dist/cli/shot/types.d.ts +97 -0
- package/dist/cli/shot/types.d.ts.map +1 -0
- package/dist/cli/shot/types.js +17 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -1
- package/dist/commands/notifications/center.d.ts.map +1 -1
- package/dist/commands/notifications/center.js +2 -11
- package/dist/controls/control-name.d.ts +27 -0
- package/dist/controls/control-name.d.ts.map +1 -0
- package/dist/controls/control-name.js +11 -0
- package/dist/controls/enum-filter.d.ts +3 -6
- package/dist/controls/enum-filter.d.ts.map +1 -1
- package/dist/controls/enum-filter.js +8 -4
- package/dist/controls/filter-base.d.ts +30 -0
- package/dist/controls/filter-base.d.ts.map +1 -0
- package/dist/controls/filter-base.js +0 -0
- package/dist/controls/filter-pill.d.ts +3 -1
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +2 -0
- package/dist/controls/filter-sheet.d.ts +0 -32
- package/dist/controls/filter-sheet.d.ts.map +1 -1
- package/dist/controls/filter-sheet.js +1 -28
- package/dist/controls/glyphs.d.ts +12 -0
- package/dist/controls/glyphs.d.ts.map +1 -1
- package/dist/controls/glyphs.js +23 -2
- package/dist/controls/index.d.ts +2 -1
- package/dist/controls/index.d.ts.map +1 -1
- package/dist/controls/multi-select-filter.d.ts +8 -3
- package/dist/controls/multi-select-filter.d.ts.map +1 -1
- package/dist/controls/multi-select-filter.js +27 -10
- package/dist/controls/number-filter.d.ts +3 -12
- package/dist/controls/number-filter.d.ts.map +1 -1
- package/dist/controls/number-filter.js +17 -6
- package/dist/controls/panel-row.d.ts +5 -8
- package/dist/controls/panel-row.d.ts.map +1 -1
- package/dist/controls/panel-row.js +3 -0
- package/dist/controls/range-filter.d.ts +14 -14
- package/dist/controls/range-filter.d.ts.map +1 -1
- package/dist/controls/range-filter.js +18 -41
- package/dist/controls/search-filter.d.ts +5 -2
- package/dist/controls/search-filter.d.ts.map +1 -1
- package/dist/controls/search-filter.js +74 -40
- package/dist/controls/select-filter.d.ts +2 -15
- package/dist/controls/select-filter.d.ts.map +1 -1
- package/dist/controls/sync-button.d.ts +0 -6
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/controls/sync-button.js +6 -36
- package/dist/controls/toggle-filter.d.ts +2 -2
- package/dist/controls/toggle-filter.d.ts.map +1 -1
- package/dist/controls/toggle-filter.js +3 -2
- package/dist/controls/view-tabs.d.ts +3 -4
- package/dist/controls/view-tabs.d.ts.map +1 -1
- package/dist/controls/view-tabs.js +24 -5
- package/dist/format/date.d.ts +43 -10
- package/dist/format/date.d.ts.map +1 -1
- package/dist/format/date.js +109 -18
- package/dist/format/index.d.ts +12 -11
- package/dist/format/index.d.ts.map +1 -1
- package/dist/format/index.js +11 -2
- package/dist/format/measure.d.ts +9 -9
- package/dist/format/measure.d.ts.map +1 -1
- package/dist/format/measure.js +19 -8
- package/dist/format/number.d.ts +35 -27
- package/dist/format/number.d.ts.map +1 -1
- package/dist/format/number.js +41 -20
- package/dist/format/shared.d.ts +38 -7
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +61 -13
- package/dist/provider/index.d.ts +13 -1
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +8 -0
- package/dist/surfaces.d.ts +2 -0
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +2 -0
- package/llms.txt +35 -14
- package/package.json +1 -1
- package/src/agent/chat/thread-feed-row.tsx +2 -2
- package/src/agent/chat/thread-message.tsx +2 -2
- package/src/agent/chat/thread-outcome-card.tsx +2 -2
- package/src/charts/DualPanel.tsx +1 -0
- package/src/charts/compile.ts +3 -2
- package/src/charts/cursor.ts +44 -27
- package/src/charts/legend.tsx +11 -8
- package/src/charts/panel.tsx +3 -0
- package/src/cli/board-freshness.ts +132 -0
- package/src/cli/doctor.ts +10 -1
- package/src/cli/help.ts +14 -2
- package/src/cli/index.ts +80 -10
- package/src/cli/init.ts +8 -1
- package/src/cli/shot/board.ts +154 -0
- package/src/cli/shot/capture.ts +650 -0
- package/src/cli/shot/index.ts +362 -0
- package/src/cli/shot/measure.ts +225 -0
- package/src/cli/shot/playwright.ts +152 -0
- package/src/cli/shot/serve.ts +35 -0
- package/src/cli/shot/types.ts +91 -0
- package/src/cli/sync.ts +2 -1
- package/src/commands/notifications/center.tsx +2 -14
- package/src/controls/control-name.ts +33 -0
- package/src/controls/enum-filter.tsx +29 -27
- package/src/controls/filter-base.ts +31 -0
- package/src/controls/filter-pill.tsx +4 -0
- package/src/controls/filter-sheet.tsx +0 -56
- package/src/controls/glyphs.tsx +45 -2
- package/src/controls/index.ts +2 -1
- package/src/controls/multi-select-filter.tsx +67 -43
- package/src/controls/number-filter.tsx +47 -47
- package/src/controls/panel-row.tsx +7 -8
- package/src/controls/range-filter.tsx +54 -78
- package/src/controls/search-filter.tsx +107 -54
- package/src/controls/select-filter.tsx +2 -18
- package/src/controls/sync-button.tsx +7 -40
- package/src/controls/toggle-filter.tsx +9 -7
- package/src/controls/view-tabs.tsx +41 -21
- package/src/format/date.ts +189 -36
- package/src/format/index.ts +12 -11
- package/src/format/measure.ts +29 -18
- package/src/format/number.ts +76 -37
- package/src/format/shared.ts +116 -25
- package/src/provider/index.tsx +23 -0
- package/src/surfaces.ts +5 -0
- package/dist/agent/chat/relative-time.d.ts +0 -27
- package/dist/agent/chat/relative-time.d.ts.map +0 -1
- package/dist/agent/chat/relative-time.js +0 -27
- package/src/agent/chat/relative-time.ts +0 -55
package/dist/format/date.js
CHANGED
|
@@ -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
|
|
4
|
-
|
|
5
|
-
|
|
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(
|
|
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:
|
|
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
|
|
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
|
|
31
|
-
if (
|
|
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
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
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
|
};
|
package/dist/format/index.d.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `basalt-ui/format` — Mantine-free, React-free `Intl`-backed formatting
|
|
3
|
-
*
|
|
4
|
-
* (`km`/`kcal`)
|
|
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?)
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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;
|
|
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"}
|
package/dist/format/index.js
CHANGED
|
@@ -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
|
};
|
package/dist/format/measure.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
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"
|
|
6
|
-
export declare function km(meters:
|
|
7
|
-
export type KcalOptions = {
|
|
8
|
-
/**
|
|
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
|
|
13
|
-
*
|
|
14
|
-
export declare function kcal(value:
|
|
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":"
|
|
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"}
|
package/dist/format/measure.js
CHANGED
|
@@ -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 (!
|
|
4
|
-
const { digits = 2 } = options;
|
|
5
|
-
return
|
|
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 (!
|
|
9
|
-
const { digits = 2 } = options;
|
|
10
|
-
|
|
11
|
-
|
|
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,
|
package/dist/format/number.d.ts
CHANGED
|
@@ -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
|
-
* `
|
|
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
|
|
15
|
-
/**
|
|
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.
|
|
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
|
|
27
|
-
export type
|
|
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.
|
|
37
|
-
|
|
38
|
-
export
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
50
|
-
|
|
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
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../src/format/number.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAkB,UAAU,EAAgC,MAAM,UAAU,CAAA;AACnF,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAErD,YAAY,EAAE,YAAY,EAAE,CAAA;AAC5B,OAAO,EAAE,UAAU,EAAE,CAAA;AASrB,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG;IAC1C,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,cAAmB,GAAG,MAAM,CAW5E;AAED,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG;IAC1C,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC5B,CAAA;AAED,wEAAwE;AACxE,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,cAAmB,GAAG,MAAM,CAS5E;AAED,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG;IACxC,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAA;IAChB,gEAAgE;IAChE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAWD,4DAA4D;AAC5D,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAYnE;AAED,yCAAyC;AACzC,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,CAG1E;AAID,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG;IACxC,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,CASxE;AAED,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG;IACxC,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,iGAAiG;AACjG,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,CAMxE"}
|
package/dist/format/number.js
CHANGED
|
@@ -1,48 +1,69 @@
|
|
|
1
|
-
import { NON_FINITE, numberFormat } from "./shared.js";
|
|
1
|
+
import { isFiniteNumber, NON_FINITE, numberFormat, scaleThousands } from "./shared.js";
|
|
2
2
|
const COMPACT_K = /(\d\s?)K/;
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
13
|
-
if (!
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
if (
|
|
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
|
-
|
|
31
|
-
maximumFractionDigits: fractionDigits
|
|
37
|
+
...fractionDigitOptions(isCompact, digits)
|
|
32
38
|
}).format(value).replace(COMPACT_K, "$1k");
|
|
33
39
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
fmtPercent,
|
|
64
|
+
bytes,
|
|
65
|
+
compact,
|
|
66
|
+
delta,
|
|
46
67
|
integer,
|
|
47
68
|
money,
|
|
48
69
|
percent
|
package/dist/format/shared.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared low-level pieces of `basalt-ui/format
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
|
|
13
|
+
/** Options every number/measure formatter accepts. */
|
|
14
14
|
export type LocaleOption = {
|
|
15
|
-
/** BCP-47 tag. Default
|
|
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,
|
|
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+D;IAC/D,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B,CAAA;AAWD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,cAAmB,GAAG,IAAI,CAS5D;AAED,0FAA0F;AAC1F,wBAAgB,mBAAmB,IAAI,IAAI,CAI1C;AAkCD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,IAAI,CAAC,mBAAmB,GAChC,IAAI,CAAC,YAAY,CAGnB;AAED,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,IAAI,CAAC,qBAAqB,GAClC,IAAI,CAAC,cAAc,CAOrB;AAED,mDAAmD;AACnD,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;AAE/C;+DAC+D;AAC/D,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE9D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAUlC;AAED;;;;0DAI0D;AAC1D,wBAAgB,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,CAGjE"}
|