basalt-ui 2.13.3 → 2.14.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 +26 -0
- package/MIGRATING.md +36 -12
- 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 +5 -4
- 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/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/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 +9 -6
- package/src/charts/panel.tsx +3 -0
- 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/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/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,MA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 new Map();
|
|
4
|
+
let defaults = {};
|
|
5
|
+
function defineFormat(next = {}) {
|
|
6
|
+
const merged = {
|
|
7
|
+
locale: next.locale ?? defaults.locale,
|
|
8
|
+
timeZone: next.timeZone ?? defaults.timeZone
|
|
9
|
+
};
|
|
10
|
+
if (merged.locale === defaults.locale && merged.timeZone === defaults.timeZone) return;
|
|
11
|
+
defaults = merged;
|
|
12
|
+
numberCaches.clear();
|
|
13
|
+
dateCaches.clear();
|
|
14
|
+
}
|
|
15
|
+
function resetFormatDefaults() {
|
|
16
|
+
defaults = {};
|
|
17
|
+
numberCaches.clear();
|
|
18
|
+
dateCaches.clear();
|
|
19
|
+
}
|
|
20
|
+
function optionsKey(options) {
|
|
21
|
+
let key = "";
|
|
22
|
+
for (const [name, value] of Object.entries(options).sort(([a], [b]) => a < b ? -1 : 1)) {
|
|
23
|
+
key += `${name}=${String(value)};`;
|
|
24
|
+
}
|
|
25
|
+
return key;
|
|
26
|
+
}
|
|
27
|
+
function memoize(caches, locale, options, create) {
|
|
28
|
+
const localeKey = locale ?? "";
|
|
29
|
+
let cache = caches.get(localeKey);
|
|
30
|
+
if (cache === void 0) {
|
|
31
|
+
cache = /* @__PURE__ */ new Map();
|
|
32
|
+
caches.set(localeKey, cache);
|
|
33
|
+
}
|
|
34
|
+
const key = optionsKey(options);
|
|
35
|
+
const cached = cache.get(key);
|
|
6
36
|
if (cached !== void 0) return cached;
|
|
7
|
-
const created =
|
|
8
|
-
|
|
37
|
+
const created = create();
|
|
38
|
+
cache.set(key, created);
|
|
9
39
|
return created;
|
|
10
40
|
}
|
|
11
|
-
|
|
41
|
+
function numberFormat(locale, options) {
|
|
42
|
+
const resolved = locale ?? defaults.locale;
|
|
43
|
+
return memoize(numberCaches, resolved, options, () => new Intl.NumberFormat(resolved, options));
|
|
44
|
+
}
|
|
12
45
|
function dateFormat(locale, options) {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return
|
|
46
|
+
const resolved = locale ?? defaults.locale;
|
|
47
|
+
const withZone = options.timeZone === void 0 && defaults.timeZone !== void 0 ? { ...options, timeZone: defaults.timeZone } : options;
|
|
48
|
+
return memoize(dateCaches, resolved, withZone, () => new Intl.DateTimeFormat(resolved, withZone));
|
|
49
|
+
}
|
|
50
|
+
function isFiniteNumber(value) {
|
|
51
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
52
|
+
}
|
|
53
|
+
function scaleThousands(value, digits, maxUnit) {
|
|
54
|
+
let scaled = value;
|
|
55
|
+
let unit = 0;
|
|
56
|
+
while (unit < maxUnit) {
|
|
57
|
+
const factor = 10 ** (unit === 0 ? 0 : digits);
|
|
58
|
+
if (Math.round(Math.abs(scaled) * factor) / factor < 1e3) break;
|
|
59
|
+
scaled /= 1e3;
|
|
60
|
+
unit += 1;
|
|
61
|
+
}
|
|
62
|
+
return { scaled, unit };
|
|
19
63
|
}
|
|
20
64
|
function toDate(value) {
|
|
21
65
|
const date = value instanceof Date ? value : new Date(value);
|
|
@@ -24,6 +68,10 @@ function toDate(value) {
|
|
|
24
68
|
export {
|
|
25
69
|
NON_FINITE,
|
|
26
70
|
dateFormat,
|
|
71
|
+
defineFormat,
|
|
72
|
+
isFiniteNumber,
|
|
27
73
|
numberFormat,
|
|
74
|
+
resetFormatDefaults,
|
|
75
|
+
scaleThousands,
|
|
28
76
|
toDate
|
|
29
77
|
};
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -53,6 +53,18 @@ type BasaltProviderCommonProps = {
|
|
|
53
53
|
* action wiring mounts.
|
|
54
54
|
*/
|
|
55
55
|
spotlight?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Default BCP-47 locale for every `basalt-ui/format` formatter that gets no per-call `locale`
|
|
58
|
+
* (`integer(1112)` → `1,112` under `en-US`). App-level config, static for the provider's
|
|
59
|
+
* lifetime: it sets ONE module-global default per process (formatters are plain functions, not
|
|
60
|
+
* hooks) and a per-call `locale` is the override. An unset prop LEAVES the current default in
|
|
61
|
+
* place (it never resets it), and changing the prop at runtime does not re-render formatted
|
|
62
|
+
* children.
|
|
63
|
+
*/
|
|
64
|
+
locale?: string;
|
|
65
|
+
/** Default IANA time zone for the date/time formatters; same lifecycle as `locale`. Unset leaves
|
|
66
|
+
* the current default (initially the runtime's zone). */
|
|
67
|
+
timeZone?: string;
|
|
56
68
|
} & Omit<MantineProviderProps, 'children' | 'theme' | 'defaultColorScheme' | 'cssVariablesResolver'>;
|
|
57
69
|
/**
|
|
58
70
|
* Two modes, never both: pass a `createBasaltRouter` `router` and the provider mounts it, or pass
|
|
@@ -103,6 +115,6 @@ export declare function composeInjectedCss(base: string, fontsCss: string, radiu
|
|
|
103
115
|
* closes the gap between hydration and the next client paint.
|
|
104
116
|
*/
|
|
105
117
|
export declare function useHostAttribute(): void;
|
|
106
|
-
export declare function BasaltProvider({ theme, telemetry, fallback, injectPalette, paletteOptions, defaultColorScheme, nonce, sizeClassHint, navCommandLabel, spotlight, router: mountedRouter, children, ...rest }: BasaltProviderProps): import("react").JSX.Element;
|
|
118
|
+
export declare function BasaltProvider({ theme, telemetry, fallback, injectPalette, paletteOptions, defaultColorScheme, nonce, sizeClassHint, navCommandLabel, spotlight, locale, timeZone, router: mountedRouter, children, ...rest }: BasaltProviderProps): import("react").JSX.Element;
|
|
107
119
|
export {};
|
|
108
120
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAMzD,OAAO,EAAE,SAAS,EAAwD,MAAM,OAAO,CAAA;AACvF,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAMjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts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AAc,EACd,kBAA2B,EAC3B,KAAK,EACL,aAAyB,EACzB,eAAe,EACf,SAAgB,EAChB,MAAM,EACN,QAAQ,EACR,MAAM,EAAE,aAAa,EACrB,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,mBAAmB,+BAsErB"}
|
package/dist/provider/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import { buildPaletteData } from "../tokens/palette.js";
|
|
|
14
14
|
import { useMediaQuery } from "../common/use-media-query.js";
|
|
15
15
|
import { registerColorSchemeSetter } from "../commands/shell-bridge.js";
|
|
16
16
|
import { useIsomorphicLayoutEffect } from "../common/isomorphic-layout-effect.js";
|
|
17
|
+
import { defineFormat } from "../format/shared.js";
|
|
17
18
|
import { PageTitle } from "../shell/page-title.js";
|
|
18
19
|
import { SizeClassHintContext } from "../shell/use-size-class.js";
|
|
19
20
|
import {
|
|
@@ -272,12 +273,19 @@ function BasaltProvider({
|
|
|
272
273
|
sizeClassHint = "compact",
|
|
273
274
|
navCommandLabel,
|
|
274
275
|
spotlight = true,
|
|
276
|
+
locale,
|
|
277
|
+
timeZone,
|
|
275
278
|
router: mountedRouter,
|
|
276
279
|
children,
|
|
277
280
|
...rest
|
|
278
281
|
}) {
|
|
279
282
|
useDuplicateProviderGuard();
|
|
280
283
|
useHostAttribute();
|
|
284
|
+
const appliedFormat = useRef({});
|
|
285
|
+
if (appliedFormat.current.locale !== locale || appliedFormat.current.timeZone !== timeZone) {
|
|
286
|
+
appliedFormat.current = { locale, timeZone };
|
|
287
|
+
defineFormat({ locale, timeZone });
|
|
288
|
+
}
|
|
281
289
|
const sink = telemetry ?? (process.env.NODE_ENV === "production" ? void 0 : devConsoleSink);
|
|
282
290
|
const sinkRef = useRef(sink);
|
|
283
291
|
useEffect(() => {
|
package/llms.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# basalt-ui v2.
|
|
1
|
+
# basalt-ui v2.14.0
|
|
2
2
|
# Opinionated framework for Mantine-based React apps — theme, app shell, TanStack Charts, toolchain presets
|
|
3
3
|
#
|
|
4
4
|
# Entry points: use the exact import specifier below; do not guess.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# A subpath's `Install:` line is its required peers; `OptionalPeers:` are import()-only, install on use.
|
|
14
14
|
|
|
15
15
|
Package: basalt-ui
|
|
16
|
-
Version: 2.
|
|
16
|
+
Version: 2.14.0
|
|
17
17
|
|
|
18
18
|
## basalt-ui
|
|
19
19
|
Import: import { ... } from 'basalt-ui'
|
|
@@ -32,6 +32,8 @@ Signature: BasaltProvider(props: BasaltProviderProps): JSX.Element
|
|
|
32
32
|
sizeClassHint?: "compact" | "medium" | "expanded"
|
|
33
33
|
navCommandLabel?: (item: FlatNavItem) => string
|
|
34
34
|
spotlight?: boolean
|
|
35
|
+
locale?: string
|
|
36
|
+
timeZone?: string
|
|
35
37
|
router: BasaltRouter
|
|
36
38
|
children: ReactNode
|
|
37
39
|
Signature: BasaltShell(props: BasaltShellProps<G, T>): JSX.Element
|
|
@@ -516,13 +518,23 @@ OptionalPeers: vite-plugin-pwa@^1.3.0
|
|
|
516
518
|
Import: import { ... } from 'basalt-ui/format'
|
|
517
519
|
Description: integer/money/percent/durationClock/relativeTime/weekday/km/kcal — Intl-backed, Mantine-free, React-free formatting; the chart layer formats through the same implementation
|
|
518
520
|
Layer: headless
|
|
521
|
+
Signature: bytes(value: Numeric, options: BytesOptions): string
|
|
522
|
+
Signature: compact(value: Numeric, options: CompactOptions): string
|
|
523
|
+
Signature: date(value: DateInput, options: DateOptions): string
|
|
524
|
+
Signature: dateTime(value: DateInput, options: DateOptions): string
|
|
525
|
+
Signature: defineFormat(next: FormatDefaults): void
|
|
526
|
+
locale?: string
|
|
527
|
+
timeZone?: string
|
|
528
|
+
Signature: delta(value: Numeric, options: DeltaOptions): string
|
|
529
|
+
Signature: duration(seconds: number | null | undefined, options: DurationOptions): string
|
|
519
530
|
Signature: durationClock(seconds: number): string
|
|
520
|
-
Signature: integer(value:
|
|
521
|
-
Signature: kcal(value:
|
|
522
|
-
Signature: km(meters:
|
|
523
|
-
Signature: money(value:
|
|
524
|
-
Signature: percent(value:
|
|
525
|
-
Signature: relativeTime(value:
|
|
531
|
+
Signature: integer(value: Numeric, options: LocaleOption): string
|
|
532
|
+
Signature: kcal(value: Numeric, options: KcalOptions): string
|
|
533
|
+
Signature: km(meters: Numeric, options: KmOptions): string
|
|
534
|
+
Signature: money(value: Numeric, options: MoneyOptions): string
|
|
535
|
+
Signature: percent(value: Numeric, options: PercentOptions): string
|
|
536
|
+
Signature: relativeTime(value: DateInput, options: RelativeTimeOptions): string
|
|
537
|
+
Signature: time(value: DateInput, options: DateOptions): string
|
|
526
538
|
Signature: weekday(value: string | number | Date, options: WeekdayOptions): string
|
|
527
539
|
|
|
528
540
|
## basalt-ui/forms
|
|
@@ -809,9 +821,11 @@ Signature: MultiSelectFilter(props: MultiSelectFilterProps<T>): ReactNode
|
|
|
809
821
|
value?: never
|
|
810
822
|
onChange?: never
|
|
811
823
|
size?: never
|
|
812
|
-
field: FieldHandle<MultiField<T>>
|
|
813
824
|
label: string
|
|
814
825
|
icon?: ReactNode
|
|
826
|
+
clearable?: boolean
|
|
827
|
+
disabled?: boolean
|
|
828
|
+
field: FieldHandle<MultiField<T>>
|
|
815
829
|
noun?: string
|
|
816
830
|
options?: readonly FilterOption[]
|
|
817
831
|
counts?: Record<string, number>
|
|
@@ -822,21 +836,23 @@ Signature: NumberFilter(props: NumberFilterProps): ReactNode
|
|
|
822
836
|
value?: never
|
|
823
837
|
onChange?: never
|
|
824
838
|
size?: never
|
|
825
|
-
field: FieldHandle<NumberField>
|
|
826
839
|
label: string
|
|
827
840
|
icon?: ReactNode
|
|
828
|
-
options?: readonly NumberFilterOption[]
|
|
829
|
-
step?: number
|
|
830
841
|
clearable?: boolean
|
|
842
|
+
disabled?: boolean
|
|
843
|
+
field: FieldHandle<NumberField>
|
|
844
|
+
options?: readonly FilterOption<number>[]
|
|
845
|
+
step?: number
|
|
831
846
|
Signature: RangeFilter(props: RangeFilterProps<P, C>): ReactNode
|
|
832
847
|
className?: string
|
|
833
848
|
style?: CSSProperties
|
|
834
849
|
value?: never
|
|
835
850
|
onChange?: never
|
|
836
851
|
size?: never
|
|
837
|
-
field: FieldHandle<RangeField<P, C>>
|
|
838
852
|
icon?: ReactNode
|
|
853
|
+
disabled?: boolean
|
|
839
854
|
label?: string
|
|
855
|
+
field: FieldHandle<RangeField<P, C>>
|
|
840
856
|
customPicker?: ComponentType<RangeCustomPickerProps>
|
|
841
857
|
Signature: SearchFilter(props: SearchFilterProps): ReactNode
|
|
842
858
|
className?: string
|
|
@@ -844,9 +860,11 @@ Signature: SearchFilter(props: SearchFilterProps): ReactNode
|
|
|
844
860
|
value?: never
|
|
845
861
|
onChange?: never
|
|
846
862
|
size?: never
|
|
863
|
+
disabled?: boolean
|
|
847
864
|
field: FieldHandle<StringField>
|
|
848
865
|
placeholder?: string
|
|
849
866
|
label?: string
|
|
867
|
+
clearable?: boolean
|
|
850
868
|
Signature: SelectFilter(props: SelectFilterEnumProps<T>): ReactNode
|
|
851
869
|
className?: string
|
|
852
870
|
style?: CSSProperties
|
|
@@ -856,6 +874,7 @@ Signature: SelectFilter(props: SelectFilterEnumProps<T>): ReactNode
|
|
|
856
874
|
label: string
|
|
857
875
|
icon?: ReactNode
|
|
858
876
|
clearable?: boolean
|
|
877
|
+
disabled?: boolean
|
|
859
878
|
field: FieldHandle<EnumField<T>>
|
|
860
879
|
options?: readonly FilterOption[]
|
|
861
880
|
Signature: SyncButton(props: SyncButtonProps): ReactNode
|
|
@@ -873,15 +892,17 @@ Signature: ToggleFilter(props: ToggleFilterProps): ReactNode
|
|
|
873
892
|
value?: never
|
|
874
893
|
onChange?: never
|
|
875
894
|
size?: never
|
|
876
|
-
field: FieldHandle<BooleanField>
|
|
877
895
|
label: string
|
|
878
896
|
icon?: ReactNode
|
|
897
|
+
disabled?: boolean
|
|
898
|
+
field: FieldHandle<BooleanField>
|
|
879
899
|
Signature: ViewTabs(props: ViewTabsProps<T>): ReactNode
|
|
880
900
|
className?: string
|
|
881
901
|
style?: CSSProperties
|
|
882
902
|
value?: never
|
|
883
903
|
onChange?: never
|
|
884
904
|
size?: never
|
|
905
|
+
disabled?: boolean
|
|
885
906
|
field: FieldHandle<EnumField<T>>
|
|
886
907
|
options?: readonly ViewTabsOption<T>[]
|
|
887
908
|
label?: string
|
package/package.json
CHANGED
|
@@ -43,11 +43,11 @@ import { BasaltStickToBottom } from '../stick-to-bottom'
|
|
|
43
43
|
import { cx } from '../../common/props'
|
|
44
44
|
import type { BasaltProps, SlotStylesProps } from '../../common/props'
|
|
45
45
|
import { assertRequiredProps } from '../../common/validate'
|
|
46
|
+
import { relativeTime } from '../../format'
|
|
46
47
|
import { VX } from '../../tokens'
|
|
47
48
|
import type { ComposerProps, ComposerSubmit } from './composer'
|
|
48
49
|
import { Composer } from './composer'
|
|
49
50
|
import type { MessageAffordances } from './message-affordances'
|
|
50
|
-
import { formatRelativeTime } from './relative-time'
|
|
51
51
|
import { ThreadTranscript } from './thread-message'
|
|
52
52
|
import { resolveRowHeight } from './virtualize'
|
|
53
53
|
import type { RowHeightProps, VirtualizeProps } from './virtualize'
|
|
@@ -309,7 +309,7 @@ export function ThreadFeedRow(props: ThreadFeedRowProps): JSX.Element {
|
|
|
309
309
|
flexShrink: 0,
|
|
310
310
|
}}
|
|
311
311
|
>
|
|
312
|
-
{
|
|
312
|
+
{relativeTime(thread.updatedAt)}
|
|
313
313
|
</Text>
|
|
314
314
|
<ChevronGlyph expanded={expanded} />
|
|
315
315
|
</Group>
|
|
@@ -53,10 +53,10 @@ import type { BasaltProps } from '../../common/props'
|
|
|
53
53
|
import { assertRequiredProps } from '../../common/validate'
|
|
54
54
|
import { Markdown } from '../../content/markdown'
|
|
55
55
|
import { CopyAction } from '../../content/copy-action'
|
|
56
|
+
import { relativeTime } from '../../format'
|
|
56
57
|
import { VX } from '../../tokens'
|
|
57
58
|
import { DEFAULT_AFFORDANCES } from './message-affordances'
|
|
58
59
|
import type { MessageAffordances } from './message-affordances'
|
|
59
|
-
import { formatRelativeTime } from './relative-time'
|
|
60
60
|
import { ToolChip } from './tool-chip'
|
|
61
61
|
import { resolveVirtualize } from './virtualize'
|
|
62
62
|
import type { VirtualizeOptions, VirtualizeProps } from './virtualize'
|
|
@@ -345,7 +345,7 @@ function MessageAffordanceRow({
|
|
|
345
345
|
const timestampLabel =
|
|
346
346
|
timestampMode === 'absolute'
|
|
347
347
|
? new Date(message.createdAt).toLocaleString()
|
|
348
|
-
:
|
|
348
|
+
: relativeTime(message.createdAt)
|
|
349
349
|
|
|
350
350
|
return (
|
|
351
351
|
<Group
|
|
@@ -25,8 +25,8 @@ import type { AgentThread, ThreadStatus } from '../thread'
|
|
|
25
25
|
import { assertRequiredProps } from '../../common/validate'
|
|
26
26
|
import { cx } from '../../common/props'
|
|
27
27
|
import type { BasaltProps } from '../../common/props'
|
|
28
|
+
import { relativeTime } from '../../format'
|
|
28
29
|
import { alpha, VX } from '../../tokens'
|
|
29
|
-
import { formatRelativeTime } from './relative-time'
|
|
30
30
|
|
|
31
31
|
// ── Status badge — shown ONLY for states that need a glance (attention/error). ────
|
|
32
32
|
// done/pending/streaming stay badge-free: a settled feed shouldn't be a wall of green chips —
|
|
@@ -113,7 +113,7 @@ function OutcomeBody({ thread }: { thread: AgentThread }): JSX.Element {
|
|
|
113
113
|
<Text
|
|
114
114
|
style={{ fontFamily: 'var(--basalt-font-mono)', fontSize: VX.text.micro, color: VX.faint }}
|
|
115
115
|
>
|
|
116
|
-
{
|
|
116
|
+
{relativeTime(thread.updatedAt)}
|
|
117
117
|
</Text>
|
|
118
118
|
</Stack>
|
|
119
119
|
)
|
package/src/charts/DualPanel.tsx
CHANGED
package/src/charts/compile.ts
CHANGED
|
@@ -23,7 +23,7 @@ import type {
|
|
|
23
23
|
StoredChartSpec,
|
|
24
24
|
} from '@tanstack/charts/types/core'
|
|
25
25
|
import { SHORT_CHART_HEIGHT } from './box'
|
|
26
|
-
import {
|
|
26
|
+
import { compact } from '../format/number'
|
|
27
27
|
import { VX } from '../tokens'
|
|
28
28
|
import type { ContainerClass } from '../tokens/size-classes'
|
|
29
29
|
import { cursorBinding, followerOptions, quietWhileFollowing } from './cursor'
|
|
@@ -119,7 +119,7 @@ const labelsInside = (cls: ContainerClass, height: number): boolean =>
|
|
|
119
119
|
cls === 'compact' && height > 0 && height < SHORT_CHART_HEIGHT
|
|
120
120
|
|
|
121
121
|
export function defaultNumberFormat(v: number): string {
|
|
122
|
-
return
|
|
122
|
+
return compact(v, { digits: Math.abs(v) >= 1000 ? 1 : 2 })
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
|
@@ -917,6 +917,7 @@ export function compileCartesian<T, X extends ChartX>(
|
|
|
917
917
|
group: input.cursorGroup,
|
|
918
918
|
chartId: input.chartId,
|
|
919
919
|
keys: model.values,
|
|
920
|
+
extent: model.extent,
|
|
920
921
|
mode: input.cursorResolution ?? 'nearest',
|
|
921
922
|
pin: input.coarse === true,
|
|
922
923
|
}),
|