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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-tabs.d.ts","sourceRoot":"","sources":["../../src/controls/view-tabs.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"view-tabs.d.ts","sourceRoot":"","sources":["../../src/controls/view-tabs.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAItD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAgBvD,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG;IAC/D,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACpC,CAAA;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,IAAI,iBAAiB,GAC7D,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG;IAC7B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACzC,wFAAwF;IACxF,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,cAAc,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/C;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAEH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,SAAS,CA0G7E"}
|
|
@@ -4,14 +4,21 @@ import { cx } from "../common/props.js";
|
|
|
4
4
|
import { assertRequiredProps } from "../common/validate.js";
|
|
5
5
|
import classes from "./controls.module.css";
|
|
6
6
|
import { useFilterSurface } from "./filter-context.js";
|
|
7
|
-
import { useControlName } from "./
|
|
7
|
+
import { useControlName } from "./control-name.js";
|
|
8
8
|
import { PanelChoice, PanelRow, useTrackFits } from "./panel-row.js";
|
|
9
|
+
function toSegmentData(options) {
|
|
10
|
+
return options.map((option) => ({
|
|
11
|
+
value: option.value,
|
|
12
|
+
label: option.label,
|
|
13
|
+
disabled: option.disabled === true
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
9
16
|
const PHONE_TRACK_MAX = 3;
|
|
10
17
|
function ViewTabs(props) {
|
|
11
18
|
assertRequiredProps("ViewTabs", props, ["field"], {
|
|
12
19
|
field: "bind it to a store field (`store.field.<name>`), never a value/onChange pair."
|
|
13
20
|
});
|
|
14
|
-
const { field, options, label = "View", className, style } = props;
|
|
21
|
+
const { field, options, label = "View", disabled, className, style } = props;
|
|
15
22
|
const [value, setValue] = field.use();
|
|
16
23
|
const surface = useFilterSurface();
|
|
17
24
|
const inPanel = surface === "panel";
|
|
@@ -22,7 +29,7 @@ function ViewTabs(props) {
|
|
|
22
29
|
const commit = (next) => {
|
|
23
30
|
setValue(next);
|
|
24
31
|
};
|
|
25
|
-
const phoneData = phone
|
|
32
|
+
const phoneData = toSegmentData(phone);
|
|
26
33
|
const phoneCountFits = phone.length <= PHONE_TRACK_MAX;
|
|
27
34
|
const { rootRef: phoneRootRef, fits: phoneFits } = useTrackFits(
|
|
28
35
|
phoneCountFits,
|
|
@@ -36,7 +43,16 @@ function ViewTabs(props) {
|
|
|
36
43
|
labelId,
|
|
37
44
|
...className !== void 0 && { className },
|
|
38
45
|
...style !== void 0 && { style },
|
|
39
|
-
children: /* @__PURE__ */ jsx(
|
|
46
|
+
children: /* @__PURE__ */ jsx(
|
|
47
|
+
PanelChoice,
|
|
48
|
+
{
|
|
49
|
+
nameProps,
|
|
50
|
+
value,
|
|
51
|
+
options: all,
|
|
52
|
+
onChange: commit,
|
|
53
|
+
...disabled === true && { disabled: true }
|
|
54
|
+
}
|
|
55
|
+
)
|
|
40
56
|
}
|
|
41
57
|
);
|
|
42
58
|
}
|
|
@@ -47,8 +63,9 @@ function ViewTabs(props) {
|
|
|
47
63
|
"aria-label": label,
|
|
48
64
|
visibleFrom: "sm",
|
|
49
65
|
size: "ctl",
|
|
66
|
+
...disabled === true && { disabled: true },
|
|
50
67
|
value,
|
|
51
|
-
data: desktop
|
|
68
|
+
data: toSegmentData(desktop),
|
|
52
69
|
onChange: commit,
|
|
53
70
|
...className !== void 0 && { className },
|
|
54
71
|
...style !== void 0 && { style }
|
|
@@ -62,6 +79,7 @@ function ViewTabs(props) {
|
|
|
62
79
|
hiddenFrom: "sm",
|
|
63
80
|
size: "ctl",
|
|
64
81
|
fullWidth: true,
|
|
82
|
+
...disabled === true && { disabled: true },
|
|
65
83
|
value,
|
|
66
84
|
data: phoneData,
|
|
67
85
|
onChange: commit,
|
|
@@ -78,6 +96,7 @@ function ViewTabs(props) {
|
|
|
78
96
|
...style !== void 0 && { style },
|
|
79
97
|
value,
|
|
80
98
|
allowDeselect: false,
|
|
99
|
+
...disabled === true && { disabled: true },
|
|
81
100
|
data: phoneData,
|
|
82
101
|
onChange: (next) => {
|
|
83
102
|
if (next !== null) commit(next);
|
package/dist/format/date.d.ts
CHANGED
|
@@ -1,28 +1,61 @@
|
|
|
1
1
|
import type { LocaleOption } from './shared.js';
|
|
2
|
+
type DateInput = Date | number | string | null | undefined;
|
|
2
3
|
export type WeekdayOptions = LocaleOption & {
|
|
3
4
|
/** `Intl.DateTimeFormat`'s own weekday widths. Default `'short'` (`"Mon"`). */
|
|
4
5
|
format?: 'short' | 'long' | 'narrow';
|
|
5
6
|
};
|
|
6
7
|
/** Weekday name — seeded from `astro-window/formulas.ts#fmtWeekday`. A plain `YYYY-MM-DD` string
|
|
7
8
|
* is parsed as a LOCAL calendar date (never UTC), matching that seed's own rationale: the weekday
|
|
8
|
-
* must not shift a day depending on the reader's timezone. A non-finite/unparseable input
|
|
9
|
-
* {@link NON_FINITE}. */
|
|
9
|
+
* must not shift a day depending on the reader's timezone. A non-finite/unparseable input (or a
|
|
10
|
+
* day that does not exist, `2026-02-31`) prints {@link NON_FINITE}. */
|
|
10
11
|
export declare function weekday(value: Date | number | string, options?: WeekdayOptions): string;
|
|
11
12
|
export type RelativeTimeOptions = LocaleOption & {
|
|
13
|
+
/** `Intl.RelativeTimeFormat` width. Default `'long'` (`"3 hours ago"`); `'short'` is `"3 hr. ago"`. */
|
|
14
|
+
style?: 'long' | 'short' | 'narrow';
|
|
15
|
+
/** `'auto'` (default) uses idioms (`"yesterday"`, `"now"`); `'always'` keeps the number. */
|
|
16
|
+
numeric?: 'auto' | 'always';
|
|
12
17
|
/** The reference "now" instant, epoch ms. Default `Date.now()` — mainly for tests. */
|
|
13
18
|
now?: number;
|
|
14
19
|
};
|
|
15
20
|
/**
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
18
|
-
*
|
|
19
|
-
* `
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* render-path code where one bad timestamp must not blank a whole list.
|
|
21
|
+
* THE relative-time formatter on `Intl.RelativeTimeFormat` — `"3 hours ago"`, `"in 2 days"`,
|
|
22
|
+
* `"now"`. Under a minute is `format(0, 'second')`, so "now" is the locale's own word. The count is
|
|
23
|
+
* rounded before the unit is chosen, so 59.98 minutes reads `"1 hour ago"`, never
|
|
24
|
+
* `"60 minutes ago"`. Accepts epoch ms, `Date` or an ISO string; `null`/`undefined`/unparseable
|
|
25
|
+
* prints {@link NON_FINITE} (`Intl` throws a `RangeError` on non-finite input, and this is
|
|
26
|
+
* render-path code where one bad timestamp must not blank a list).
|
|
23
27
|
*/
|
|
24
|
-
export declare function relativeTime(value:
|
|
28
|
+
export declare function relativeTime(value: DateInput, options?: RelativeTimeOptions): string;
|
|
29
|
+
export type DateOptions = LocaleOption & {
|
|
30
|
+
/** `Intl.DateTimeFormat` `dateStyle`/`timeStyle` width. Default `'medium'`. */
|
|
31
|
+
format?: 'short' | 'medium' | 'long';
|
|
32
|
+
/** IANA zone. Default `undefined` — passed straight through to `Intl`. Ignored for a plain
|
|
33
|
+
* `YYYY-MM-DD` string, which is a calendar date and prints the same day in every zone. */
|
|
34
|
+
timeZone?: string;
|
|
35
|
+
};
|
|
36
|
+
/** Calendar date — `"Sep 2, 2026"`. `null`/`undefined`/unparseable prints {@link NON_FINITE}. */
|
|
37
|
+
export declare function date(value: DateInput, options?: DateOptions): string;
|
|
38
|
+
/** Time of day — `"3:04:05 PM"` (`format: 'short'`: `"3:04 PM"`). A plain `YYYY-MM-DD` string reads as midnight UTC. */
|
|
39
|
+
export declare function time(value: DateInput, options?: DateOptions): string;
|
|
40
|
+
/** Date and time — `"Sep 2, 2026, 3:04:05 PM"` (`format: 'short'`: `"9/2/26, 3:04 PM"`; the date/time
|
|
41
|
+
* separator is the runtime's). */
|
|
42
|
+
export declare function dateTime(value: DateInput, options?: DateOptions): string;
|
|
25
43
|
/** Clock-style duration — `"1:02:03"`, `"04:12"`. Seeded from `walking-pad/
|
|
26
44
|
* formatters.ts#formatDurationClock`. A non-finite value prints {@link NON_FINITE}. */
|
|
27
45
|
export declare function durationClock(seconds: number): string;
|
|
46
|
+
export type DurationOptions = LocaleOption & {
|
|
47
|
+
/** `'clock'` (default) `"1:02:03"`; `'compact'` `"1h 02m 03s"`; `'long'` `"1 hour 2 minutes 3 seconds"`. */
|
|
48
|
+
style?: 'clock' | 'compact' | 'long';
|
|
49
|
+
/** Largest unit `'compact'`/`'long'` break down to. Default `'hour'` (90 000 s is `"25h"`). */
|
|
50
|
+
largest?: 'day' | 'hour' | 'minute';
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* THE duration formatter. `'clock'` is {@link durationClock}; `'compact'` and `'long'` trim leading
|
|
54
|
+
* and trailing zero units but keep a zero between two non-zero ones (`"1h 00m 03s"`); zero is
|
|
55
|
+
* `"0s"` / `"0 seconds"`. `'long'` labels through `Intl.NumberFormat` unit style (locale-aware) —
|
|
56
|
+
* `Intl.DurationFormat` is not in the pinned TS lib. `null`/`undefined`/non-finite prints
|
|
57
|
+
* {@link NON_FINITE}; negatives clamp to zero.
|
|
58
|
+
*/
|
|
59
|
+
export declare function duration(seconds: number | null | undefined, options?: DurationOptions): string;
|
|
60
|
+
export {};
|
|
28
61
|
//# sourceMappingURL=date.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/format/date.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAE5C,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG;IAC1C,+EAA+E;IAC/E,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAA;CACrC,CAAA;AAED;;;
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/format/date.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAE5C,KAAK,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;AAiC1D,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG;IAC1C,+EAA+E;IAC/E,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAA;CACrC,CAAA;AAED;;;uEAGuE;AACvE,wBAAgB,OAAO,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,MAAM,CAM3F;AAED,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG;IAC/C,uGAAuG;IACvG,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;IACnC,4FAA4F;IAC5F,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC3B,sFAAsF;IACtF,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAqCD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,GAAE,mBAAwB,GAAG,MAAM,CAmBxF;AAED,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG;IACvC,+EAA+E;IAC/E,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IACpC;8FAC0F;IAC1F,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAeD,iGAAiG;AACjG,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAOxE;AAED,wHAAwH;AACxH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAOxE;AAED;kCACkC;AAClC,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAS5E;AAED;uFACuF;AACvF,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CASrD;AAED,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG;IAC3C,4GAA4G;IAC5G,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAA;IACpC,+FAA+F;IAC/F,OAAO,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAA;CACpC,CAAA;AASD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAClC,OAAO,GAAE,eAAoB,GAC5B,MAAM,CAwBR"}
|
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"}
|