basalt-ui 2.13.2 → 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 +34 -0
- package/MIGRATING.md +40 -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/create-router.d.ts +9 -4
- package/dist/provider/create-router.d.ts.map +1 -1
- package/dist/provider/create-router.js +1 -19
- package/dist/provider/error-fallback.module.css +4 -15
- package/dist/provider/error-fallback.module.css.d.ts +0 -1
- package/dist/provider/fallback.module.css +37 -0
- package/dist/provider/fallback.module.css.d.ts +11 -0
- package/dist/provider/index.d.ts +13 -1
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +10 -1
- package/dist/provider/route-defaults.d.ts +10 -0
- package/dist/provider/route-defaults.d.ts.map +1 -0
- package/dist/provider/route-defaults.js +25 -0
- package/dist/provider/route-defaults.module.css +39 -0
- package/dist/provider/route-defaults.module.css.d.ts +10 -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/create-router.tsx +2 -36
- package/src/provider/error-fallback.module.css +4 -15
- package/src/provider/error-fallback.module.css.d.ts +0 -1
- package/src/provider/fallback.module.css +37 -0
- package/src/provider/fallback.module.css.d.ts +11 -0
- package/src/provider/index.tsx +25 -1
- package/src/provider/route-defaults.module.css +39 -0
- package/src/provider/route-defaults.module.css.d.ts +10 -0
- package/src/provider/route-defaults.tsx +39 -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,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"}
|
package/dist/format/shared.js
CHANGED
|
@@ -1,21 +1,65 @@
|
|
|
1
1
|
const NON_FINITE = "\u2014";
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
const numberCaches = /* @__PURE__ */ new Map();
|
|
3
|
+
const dateCaches = /* @__PURE__ */ 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
|
};
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `basaltRouterOptions` / `createBasaltRouter` — the router + QueryClient wiring (V2-SPEC § 2). One
|
|
3
|
+
* `QueryClient` per call (so an SSR entry gets one per request), carried on `context.queryClient`,
|
|
4
|
+
* plus the router defaults basalt owns: intent preloading with Query-owned freshness, scroll restoration, the
|
|
5
|
+
* pending / error / not-found components, and the route view transition (direction from the
|
|
6
|
+
* `BasaltShell` nav order, V2-SPEC § 5).
|
|
7
|
+
*/
|
|
1
8
|
import type { QueryClient, QueryClientConfig } from '@tanstack/react-query';
|
|
2
9
|
import { Router } from '@tanstack/react-router';
|
|
3
|
-
import type { AnyRoute,
|
|
10
|
+
import type { AnyRoute, RouterHistory } from '@tanstack/react-router';
|
|
4
11
|
import type { RouterHook } from '../telemetry.js';
|
|
12
|
+
import { ErrorComponent, NotFoundComponent, PendingComponent } from './route-defaults.js';
|
|
5
13
|
import { routeViewTransition } from './route-transition.js';
|
|
6
14
|
/** The root route's context: `createRootRouteWithContext<BasaltRouterContext>()`. */
|
|
7
15
|
export type BasaltRouterContext = {
|
|
@@ -22,9 +30,6 @@ declare const basaltRouterBrand: unique symbol;
|
|
|
22
30
|
export type BasaltRouter<TRouteTree extends AnyRoute = any> = BasaltRouterBase<TRouteTree> & {
|
|
23
31
|
readonly [basaltRouterBrand]: true;
|
|
24
32
|
};
|
|
25
|
-
declare function PendingComponent(): import("react").JSX.Element;
|
|
26
|
-
declare function ErrorComponent({ error, reset }: ErrorComponentProps): import("react").JSX.Element;
|
|
27
|
-
declare function NotFoundComponent(): import("react").JSX.Element;
|
|
28
33
|
/** The options `createBasaltRouter` owns. Each is `never` on it: basalt's, not a consumer knob. */
|
|
29
34
|
type ManagedKeys = Exclude<keyof BasaltRouterOptions, 'context'>;
|
|
30
35
|
/** `queryClient` and `__basalt` are basalt's: a consumer's would be replaced, so the type rejects them. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-router.d.ts","sourceRoot":"","sources":["../../src/provider/create-router.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-router.d.ts","sourceRoot":"","sources":["../../src/provider/create-router.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,29 +1,11 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Center, Loader, Stack, Text } from "@mantine/core";
|
|
3
1
|
import { Router, createRouter } from "@tanstack/react-router";
|
|
4
|
-
import { toErrorMessage } from "../common/errors.js";
|
|
5
2
|
import { makeQueryClient } from "../query-client.js";
|
|
3
|
+
import { ErrorComponent, NotFoundComponent, PendingComponent } from "./route-defaults.js";
|
|
6
4
|
import {
|
|
7
5
|
guardViewTransitionRejections,
|
|
8
6
|
routeViewTransition,
|
|
9
7
|
supportsViewTransitionTypes
|
|
10
8
|
} from "./route-transition.js";
|
|
11
|
-
function PendingComponent() {
|
|
12
|
-
return /* @__PURE__ */ jsx(Center, { py: "xl", children: /* @__PURE__ */ jsx(Loader, { size: "sm" }) });
|
|
13
|
-
}
|
|
14
|
-
function ErrorComponent({ error, reset }) {
|
|
15
|
-
return /* @__PURE__ */ jsxs(Stack, { align: "flex-start", gap: "xs", p: "md", children: [
|
|
16
|
-
/* @__PURE__ */ jsx(Text, { fw: 600, children: "Something went wrong" }),
|
|
17
|
-
/* @__PURE__ */ jsx(Text, { c: "dimmed", size: "sm", children: toErrorMessage(error) }),
|
|
18
|
-
/* @__PURE__ */ jsx(Button, { size: "compact-sm", variant: "default", onClick: reset, children: "Try again" })
|
|
19
|
-
] });
|
|
20
|
-
}
|
|
21
|
-
function NotFoundComponent() {
|
|
22
|
-
return /* @__PURE__ */ jsxs(Stack, { gap: 4, p: "md", children: [
|
|
23
|
-
/* @__PURE__ */ jsx(Text, { fw: 600, children: "Page not found" }),
|
|
24
|
-
/* @__PURE__ */ jsx(Text, { c: "dimmed", size: "sm", children: "This address does not match any page." })
|
|
25
|
-
] });
|
|
26
|
-
}
|
|
27
9
|
function basaltRouterOptions(options = {}) {
|
|
28
10
|
return buildRouterOptions(options);
|
|
29
11
|
}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
/* The boundary renders ABOVE MantineProvider, so its fallback is plain HTML styled here
|
|
2
|
-
Mantine primitive, no inline style object (hidden-inline-style).
|
|
1
|
+
/* The boundary renders ABOVE MantineProvider, so its fallback is plain HTML styled here and in the
|
|
2
|
+
shared fallback.module.css — no Mantine primitive, no inline style object (hidden-inline-style). */
|
|
3
3
|
.root {
|
|
4
4
|
max-width: 32rem;
|
|
5
5
|
margin: 0 auto;
|
|
6
|
-
padding: var(--vx-space-stack-xl);
|
|
6
|
+
padding: var(--vx-space-stack-xl, 2rem);
|
|
7
7
|
display: flex;
|
|
8
8
|
flex-direction: column;
|
|
9
|
-
gap: var(--vx-space-stack-md);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.reload {
|
|
13
|
-
align-self: flex-start;
|
|
14
|
-
font: inherit;
|
|
15
|
-
cursor: pointer;
|
|
16
|
-
padding: var(--vx-space-stack-xs) var(--vx-space-stack-md);
|
|
17
|
-
border: 1px solid var(--vx-divider);
|
|
18
|
-
border-radius: var(--vx-radius-ctrl);
|
|
19
|
-
background: transparent;
|
|
20
|
-
color: inherit;
|
|
9
|
+
gap: var(--vx-space-stack-md, 1rem);
|
|
21
10
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* The plain-HTML fallback vocabulary shared by RootBoundary's fallback and the router's default
|
|
2
|
+
screens: both render where Mantine may be absent, so neither can use a Mantine primitive. Every
|
|
3
|
+
--vx-* read carries a literal fallback, so they look right with the provider, with only
|
|
4
|
+
tokens.css, or with nothing. */
|
|
5
|
+
.stack {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
align-items: flex-start;
|
|
9
|
+
gap: var(--vx-space-stack-xs, 0.5rem);
|
|
10
|
+
padding: var(--vx-space-stack-md, 1rem);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.title {
|
|
14
|
+
margin: 0;
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.text {
|
|
19
|
+
margin: 0;
|
|
20
|
+
font-size: var(--vx-text-sm, 0.875rem);
|
|
21
|
+
color: var(--vx-ink2, inherit);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.action {
|
|
25
|
+
align-self: flex-start;
|
|
26
|
+
min-width: 2.75rem;
|
|
27
|
+
min-height: 2.75rem;
|
|
28
|
+
font: inherit;
|
|
29
|
+
font-size: var(--vx-text-sm, 0.875rem);
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
padding: 0.25rem var(--vx-space-stack-md, 0.75rem);
|
|
32
|
+
border: 1px solid currentColor;
|
|
33
|
+
border: 1px solid var(--vx-divider, color-mix(in srgb, currentColor 25%, transparent));
|
|
34
|
+
border-radius: var(--vx-radius-ctrl, 6px);
|
|
35
|
+
background: transparent;
|
|
36
|
+
color: inherit;
|
|
37
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed CSS-module declaration (the S4 CSS-modules path). Named string props — not an index
|
|
3
|
+
* signature — so dot access stays verbatim under the package's strict flags.
|
|
4
|
+
*/
|
|
5
|
+
declare const classes: {
|
|
6
|
+
readonly stack: string
|
|
7
|
+
readonly title: string
|
|
8
|
+
readonly text: string
|
|
9
|
+
readonly action: string
|
|
10
|
+
}
|
|
11
|
+
export default classes
|
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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.tsx"],"names":[],"mappings":"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"}
|
package/dist/provider/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { QueryClientProvider } from "@tanstack/react-query";
|
|
|
5
5
|
import { RouterProvider, useRouter } from "@tanstack/react-router";
|
|
6
6
|
import { Component, Suspense, lazy, useEffect, useMemo, useRef, useState } from "react";
|
|
7
7
|
import fallbackClasses from "./error-fallback.module.css";
|
|
8
|
+
import sharedFallback from "./fallback.module.css";
|
|
8
9
|
import { cssVariablesResolver } from "../theme/index.js";
|
|
9
10
|
import { useLabTheme } from "./lab-theme.js";
|
|
10
11
|
import { buildDensityCss, buildFontsCss, buildPaletteCss, buildRadiusCss } from "../tokens/core.js";
|
|
@@ -13,6 +14,7 @@ import { buildPaletteData } from "../tokens/palette.js";
|
|
|
13
14
|
import { useMediaQuery } from "../common/use-media-query.js";
|
|
14
15
|
import { registerColorSchemeSetter } from "../commands/shell-bridge.js";
|
|
15
16
|
import { useIsomorphicLayoutEffect } from "../common/isomorphic-layout-effect.js";
|
|
17
|
+
import { defineFormat } from "../format/shared.js";
|
|
16
18
|
import { PageTitle } from "../shell/page-title.js";
|
|
17
19
|
import { SizeClassHintContext } from "../shell/use-size-class.js";
|
|
18
20
|
import {
|
|
@@ -38,7 +40,7 @@ function DefaultErrorFallback() {
|
|
|
38
40
|
"button",
|
|
39
41
|
{
|
|
40
42
|
type: "button",
|
|
41
|
-
className:
|
|
43
|
+
className: sharedFallback.action,
|
|
42
44
|
onClick: () => window.location.reload(),
|
|
43
45
|
children: "Reload page"
|
|
44
46
|
}
|
|
@@ -271,12 +273,19 @@ function BasaltProvider({
|
|
|
271
273
|
sizeClassHint = "compact",
|
|
272
274
|
navCommandLabel,
|
|
273
275
|
spotlight = true,
|
|
276
|
+
locale,
|
|
277
|
+
timeZone,
|
|
274
278
|
router: mountedRouter,
|
|
275
279
|
children,
|
|
276
280
|
...rest
|
|
277
281
|
}) {
|
|
278
282
|
useDuplicateProviderGuard();
|
|
279
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
|
+
}
|
|
280
289
|
const sink = telemetry ?? (process.env.NODE_ENV === "production" ? void 0 : devConsoleSink);
|
|
281
290
|
const sinkRef = useRef(sink);
|
|
282
291
|
useEffect(() => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The router's default pending / error / not-found screens. Provider-free on purpose: a route's
|
|
3
|
+
* screen renders at the route that failed, which can sit above `BasaltProvider` (a root-level error,
|
|
4
|
+
* or a pathless-layout provider), so no Mantine primitive. Wired by `createBasaltRouter`.
|
|
5
|
+
*/
|
|
6
|
+
import type { ErrorComponentProps } from '@tanstack/react-router';
|
|
7
|
+
export declare function PendingComponent(): import("react").JSX.Element;
|
|
8
|
+
export declare function ErrorComponent({ error, reset }: ErrorComponentProps): import("react").JSX.Element;
|
|
9
|
+
export declare function NotFoundComponent(): import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=route-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-defaults.d.ts","sourceRoot":"","sources":["../../src/provider/route-defaults.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAKjE,wBAAgB,gBAAgB,gCAM/B;AAGD,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,mBAAmB,+BAUnE;AAED,wBAAgB,iBAAiB,gCAOhC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { toErrorMessage } from "../common/errors.js";
|
|
3
|
+
import fallback from "./fallback.module.css";
|
|
4
|
+
import classes from "./route-defaults.module.css";
|
|
5
|
+
function PendingComponent() {
|
|
6
|
+
return /* @__PURE__ */ jsx("div", { className: classes.center, children: /* @__PURE__ */ jsx("output", { className: classes.spinner, "aria-label": "Loading" }) });
|
|
7
|
+
}
|
|
8
|
+
function ErrorComponent({ error, reset }) {
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", { className: fallback.stack, role: "alert", children: [
|
|
10
|
+
/* @__PURE__ */ jsx("p", { className: fallback.title, children: "Something went wrong" }),
|
|
11
|
+
/* @__PURE__ */ jsx("p", { className: fallback.text, children: toErrorMessage(error) }),
|
|
12
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: fallback.action, onClick: reset, children: "Try again" })
|
|
13
|
+
] });
|
|
14
|
+
}
|
|
15
|
+
function NotFoundComponent() {
|
|
16
|
+
return /* @__PURE__ */ jsxs("div", { className: classes.notFound, children: [
|
|
17
|
+
/* @__PURE__ */ jsx("p", { className: fallback.title, children: "Page not found" }),
|
|
18
|
+
/* @__PURE__ */ jsx("p", { className: fallback.text, children: "This address does not match any page." })
|
|
19
|
+
] });
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
ErrorComponent,
|
|
23
|
+
NotFoundComponent,
|
|
24
|
+
PendingComponent
|
|
25
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* The router's default screens render at the route that failed, which can be ABOVE BasaltProvider.
|
|
2
|
+
Shared stack/title/text/action live in fallback.module.css; same literal-fallback rule. */
|
|
3
|
+
.center {
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
padding: var(--vx-space-stack-xl, 2rem) 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.spinner {
|
|
10
|
+
width: 1.25rem;
|
|
11
|
+
height: 1.25rem;
|
|
12
|
+
border: 2px solid currentColor;
|
|
13
|
+
border-top-color: currentColor;
|
|
14
|
+
border: 2px solid color-mix(in srgb, currentColor 20%, transparent);
|
|
15
|
+
border-top-color: var(--vx-accent, currentColor);
|
|
16
|
+
border-radius: 50%;
|
|
17
|
+
animation: spin 0.8s linear infinite;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@keyframes spin {
|
|
21
|
+
to {
|
|
22
|
+
transform: rotate(360deg);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* A static ring is still a loading mark; the aria-label carries the state. */
|
|
27
|
+
@media (prefers-reduced-motion: reduce) {
|
|
28
|
+
.spinner {
|
|
29
|
+
animation: none;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Not-found is a statement, not an error with an action: its own column, no flex-start alignment. */
|
|
34
|
+
.notFound {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
gap: 4px;
|
|
38
|
+
padding: var(--vx-space-stack-md, 1rem);
|
|
39
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed CSS-module declaration (the S4 CSS-modules path). Named string props — not an index
|
|
3
|
+
* signature — so dot access stays verbatim under the package's strict flags.
|
|
4
|
+
*/
|
|
5
|
+
declare const classes: {
|
|
6
|
+
readonly center: string
|
|
7
|
+
readonly spinner: string
|
|
8
|
+
readonly notFound: string
|
|
9
|
+
}
|
|
10
|
+
export default classes
|