@llui/components 0.0.5 → 0.0.7
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/dist/components/angle-slider.d.ts.map +1 -1
- package/dist/components/angle-slider.js +3 -1
- package/dist/components/carousel.d.ts +6 -6
- package/dist/components/carousel.d.ts.map +1 -1
- package/dist/components/carousel.js +10 -7
- package/dist/components/cascade-select.d.ts +1 -1
- package/dist/components/cascade-select.d.ts.map +1 -1
- package/dist/components/cascade-select.js +4 -1
- package/dist/components/clipboard.d.ts +1 -1
- package/dist/components/clipboard.d.ts.map +1 -1
- package/dist/components/clipboard.js +4 -1
- package/dist/components/color-picker.d.ts +4 -4
- package/dist/components/color-picker.d.ts.map +1 -1
- package/dist/components/color-picker.js +7 -4
- package/dist/components/combobox.d.ts +1 -1
- package/dist/components/combobox.d.ts.map +1 -1
- package/dist/components/combobox.js +4 -2
- package/dist/components/date-input.d.ts +1 -1
- package/dist/components/date-input.d.ts.map +1 -1
- package/dist/components/date-input.js +4 -1
- package/dist/components/date-picker.d.ts +14 -2
- package/dist/components/date-picker.d.ts.map +1 -1
- package/dist/components/date-picker.js +27 -19
- package/dist/components/dialog.d.ts +1 -1
- package/dist/components/dialog.d.ts.map +1 -1
- package/dist/components/dialog.js +4 -2
- package/dist/components/drawer.d.ts +1 -1
- package/dist/components/drawer.d.ts.map +1 -1
- package/dist/components/drawer.js +4 -2
- package/dist/components/enter-view.d.ts +73 -0
- package/dist/components/enter-view.d.ts.map +1 -0
- package/dist/components/enter-view.js +51 -0
- package/dist/components/file-upload.d.ts +5 -4
- package/dist/components/file-upload.d.ts.map +1 -1
- package/dist/components/file-upload.js +6 -2
- package/dist/components/floating-panel.d.ts +4 -4
- package/dist/components/floating-panel.d.ts.map +1 -1
- package/dist/components/floating-panel.js +7 -4
- package/dist/components/form.d.ts +115 -0
- package/dist/components/form.d.ts.map +1 -0
- package/dist/components/form.js +102 -0
- package/dist/components/hover-card.d.ts +0 -1
- package/dist/components/hover-card.d.ts.map +1 -1
- package/dist/components/hover-card.js +0 -1
- package/dist/components/image-cropper.d.ts +1 -1
- package/dist/components/image-cropper.d.ts.map +1 -1
- package/dist/components/image-cropper.js +4 -1
- package/dist/components/in-view.d.ts +69 -0
- package/dist/components/in-view.d.ts.map +1 -0
- package/dist/components/in-view.js +51 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +4 -0
- package/dist/components/navigation-menu.d.ts +1 -1
- package/dist/components/navigation-menu.d.ts.map +1 -1
- package/dist/components/navigation-menu.js +4 -1
- package/dist/components/number-input.d.ts +2 -2
- package/dist/components/number-input.d.ts.map +1 -1
- package/dist/components/number-input.js +5 -2
- package/dist/components/pagination.d.ts +3 -3
- package/dist/components/pagination.d.ts.map +1 -1
- package/dist/components/pagination.js +7 -4
- package/dist/components/password-input.d.ts.map +1 -1
- package/dist/components/password-input.js +8 -3
- package/dist/components/pin-input.d.ts.map +1 -1
- package/dist/components/pin-input.js +7 -4
- package/dist/components/popover.d.ts +1 -1
- package/dist/components/popover.d.ts.map +1 -1
- package/dist/components/popover.js +4 -2
- package/dist/components/progress.d.ts.map +1 -1
- package/dist/components/progress.js +2 -1
- package/dist/components/qr-code.d.ts +2 -2
- package/dist/components/qr-code.d.ts.map +1 -1
- package/dist/components/qr-code.js +5 -2
- package/dist/components/radio-group.d.ts.map +1 -1
- package/dist/components/radio-group.js +3 -1
- package/dist/components/rating-group.d.ts.map +1 -1
- package/dist/components/rating-group.js +3 -1
- package/dist/components/scroll-area.d.ts +1 -0
- package/dist/components/scroll-area.d.ts.map +1 -1
- package/dist/components/scroll-area.js +1 -0
- package/dist/components/signature-pad.d.ts +3 -3
- package/dist/components/signature-pad.d.ts.map +1 -1
- package/dist/components/signature-pad.js +6 -3
- package/dist/components/slider.d.ts.map +1 -1
- package/dist/components/slider.js +3 -1
- package/dist/components/sortable.d.ts +106 -0
- package/dist/components/sortable.d.ts.map +1 -0
- package/dist/components/sortable.js +97 -0
- package/dist/components/splitter.d.ts.map +1 -1
- package/dist/components/splitter.js +3 -1
- package/dist/components/steps.d.ts +1 -1
- package/dist/components/steps.d.ts.map +1 -1
- package/dist/components/steps.js +4 -1
- package/dist/components/tabs.d.ts.map +1 -1
- package/dist/components/tabs.js +3 -1
- package/dist/components/tags-input.d.ts +3 -4
- package/dist/components/tags-input.d.ts.map +1 -1
- package/dist/components/tags-input.js +16 -11
- package/dist/components/theme-switch.d.ts +89 -0
- package/dist/components/theme-switch.d.ts.map +1 -0
- package/dist/components/theme-switch.js +96 -0
- package/dist/components/time-picker.d.ts +4 -4
- package/dist/components/time-picker.d.ts.map +1 -1
- package/dist/components/time-picker.js +7 -4
- package/dist/components/timer.d.ts +3 -3
- package/dist/components/timer.d.ts.map +1 -1
- package/dist/components/timer.js +6 -3
- package/dist/components/toast.d.ts +3 -3
- package/dist/components/toast.d.ts.map +1 -1
- package/dist/components/toast.js +5 -2
- package/dist/components/toc.d.ts +2 -2
- package/dist/components/toc.d.ts.map +1 -1
- package/dist/components/toc.js +5 -2
- package/dist/components/toggle-group.d.ts +0 -1
- package/dist/components/toggle-group.d.ts.map +1 -1
- package/dist/components/toggle-group.js +3 -2
- package/dist/components/tour.d.ts +1 -1
- package/dist/components/tour.d.ts.map +1 -1
- package/dist/components/tour.js +4 -1
- package/dist/components/tree-view.d.ts.map +1 -1
- package/dist/components/tree-view.js +3 -1
- package/dist/format/cache.d.ts +3 -0
- package/dist/format/cache.d.ts.map +1 -0
- package/dist/format/cache.js +24 -0
- package/dist/format/defaults.d.ts +3 -0
- package/dist/format/defaults.d.ts.map +1 -0
- package/dist/format/defaults.js +4 -0
- package/dist/format/format-date.d.ts +41 -0
- package/dist/format/format-date.d.ts.map +1 -0
- package/dist/format/format-date.js +48 -0
- package/dist/format/format-display-name.d.ts +9 -0
- package/dist/format/format-display-name.d.ts.map +1 -0
- package/dist/format/format-display-name.js +21 -0
- package/dist/format/format-file-size.d.ts +7 -0
- package/dist/format/format-file-size.d.ts.map +1 -0
- package/dist/format/format-file-size.js +27 -0
- package/dist/format/format-list.d.ts +7 -0
- package/dist/format/format-list.d.ts.map +1 -0
- package/dist/format/format-list.js +12 -0
- package/dist/format/format-number.d.ts +19 -0
- package/dist/format/format-number.d.ts.map +1 -0
- package/dist/format/format-number.js +37 -0
- package/dist/format/format-plural.d.ts +16 -0
- package/dist/format/format-plural.d.ts.map +1 -0
- package/dist/format/format-plural.js +30 -0
- package/dist/format/format-relative-time.d.ts +8 -0
- package/dist/format/format-relative-time.d.ts.map +1 -0
- package/dist/format/format-relative-time.js +12 -0
- package/dist/format/index.d.ts +8 -0
- package/dist/format/index.d.ts.map +1 -0
- package/dist/format/index.js +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/locale.d.ts +127 -0
- package/dist/locale.d.ts.map +1 -0
- package/dist/locale.js +73 -0
- package/dist/styles/theme.css +2 -2
- package/dist/utils/direction.d.ts +11 -0
- package/dist/utils/direction.d.ts.map +1 -0
- package/dist/utils/direction.js +26 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/validators.d.ts +34 -0
- package/dist/utils/validators.d.ts.map +1 -0
- package/dist/utils/validators.js +83 -0
- package/package.json +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tour.d.ts","sourceRoot":"","sources":["../../src/components/tour.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"tour.d.ts","sourceRoot":"","sources":["../../src/components/tour.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAKrC;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA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;QAC3B,YAAY,EAAE,MAAM,CAAA;QACpB,WAAW,EAAE,cAAc,CAAA;QAC3B,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAA;KACjC,CAAA;IACD,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAA;QACd,YAAY,EAAE,MAAM,CAAA;QACpB,WAAW,EAAE,cAAc,CAAA;QAC3B,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,SAAS,CAAA;QACrC,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAA;KACjC,CAAA;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ,CAAA;QACd,YAAY,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,CAAA;QACzC,YAAY,EAAE,MAAM,CAAA;QACpB,WAAW,EAAE,eAAe,CAAA;QAC5B,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAA;KACjC,CAAA;CACF;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;iDAC6C;IAC7C,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED,wBAAgB,OAAO,CAAC,CAAC,EACvB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,SAAS,EACxB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EACnB,IAAI,EAAE,cAAc,GACnB,SAAS,CAAC,CAAC,CAAC,CAiEd;AAED,eAAO,MAAM,IAAI;;;;;;;;CAQhB,CAAA"}
|
package/dist/components/tour.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useContext } from '@llui/dom';
|
|
2
|
+
import { LocaleContext } from '../locale';
|
|
1
3
|
export function init(opts = {}) {
|
|
2
4
|
const steps = opts.steps ?? [];
|
|
3
5
|
const index = Math.max(0, Math.min(opts.index ?? 0, Math.max(0, steps.length - 1)));
|
|
@@ -58,6 +60,7 @@ export function progress(state) {
|
|
|
58
60
|
return { current: state.index + 1, total: state.steps.length };
|
|
59
61
|
}
|
|
60
62
|
export function connect(get, send, opts) {
|
|
63
|
+
const locale = useContext(LocaleContext);
|
|
61
64
|
const titleId = `${opts.id}:title`;
|
|
62
65
|
const descId = `${opts.id}:description`;
|
|
63
66
|
const closeOnBackdrop = opts.closeOnBackdropClick === true;
|
|
@@ -115,7 +118,7 @@ export function connect(get, send, opts) {
|
|
|
115
118
|
},
|
|
116
119
|
closeTrigger: {
|
|
117
120
|
type: 'button',
|
|
118
|
-
'aria-label': opts.closeLabel ??
|
|
121
|
+
'aria-label': opts.closeLabel ?? ((s) => locale(s).tour.close),
|
|
119
122
|
'data-scope': 'tour',
|
|
120
123
|
'data-part': 'close-trigger',
|
|
121
124
|
onClick: () => send({ type: 'stop' }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-view.d.ts","sourceRoot":"","sources":["../../src/components/tree-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"tree-view.d.ts","sourceRoot":"","sources":["../../src/components/tree-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AASrC;;;;;GAKG;AAEH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAA;AAE9D,MAAM,WAAW,aAAa;IAC5B,gCAAgC;IAChC,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,sDAAsD;IACtD,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB;;+DAE2D;IAC3D,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,iCAAiC;IACjC,OAAO,EAAE,MAAM,GA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AED,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAA;QACZ,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,SAAS,CAAA;QACzC,sBAAsB,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,SAAS,CAAA;QACpD,eAAe,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,SAAS,CAAA;QAC7C,YAAY,EAAE,WAAW,CAAA;QACzB,WAAW,EAAE,MAAM,CAAA;QACnB,eAAe,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,SAAS,CAAA;KAC1C,CAAA;IACD,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,CAAA;CACnG;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,wBAAgB,OAAO,CAAC,CAAC,EACvB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,aAAa,EAC5B,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,EACvB,IAAI,EAAE,cAAc,GACnB,aAAa,CAAC,CAAC,CAAC,CAmHlB;AAED,eAAO,MAAM,QAAQ;;;;;;;;;;CAUpB,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { flipArrow } from '../utils/direction';
|
|
1
2
|
import { typeaheadAccumulate, typeaheadMatch, isTypeaheadKey, TYPEAHEAD_TIMEOUT_MS, } from '../utils/typeahead';
|
|
2
3
|
export function init(opts = {}) {
|
|
3
4
|
return {
|
|
@@ -213,7 +214,8 @@ export function connect(get, send, opts) {
|
|
|
213
214
|
},
|
|
214
215
|
onFocus: () => send({ type: 'focus', id }),
|
|
215
216
|
onKeyDown: (e) => {
|
|
216
|
-
|
|
217
|
+
const key = flipArrow(e.key, e.currentTarget);
|
|
218
|
+
switch (key) {
|
|
217
219
|
case 'ArrowDown':
|
|
218
220
|
e.preventDefault();
|
|
219
221
|
send({ type: 'focusNext' });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/format/cache.ts"],"names":[],"mappings":"AAIA,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAUzD;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAO9F"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** LRU cache for Intl formatter instances (expensive to construct). */
|
|
2
|
+
const cache = new Map();
|
|
3
|
+
const MAX_CACHE = 64;
|
|
4
|
+
export function cached(key, create) {
|
|
5
|
+
const existing = cache.get(key);
|
|
6
|
+
if (existing)
|
|
7
|
+
return existing;
|
|
8
|
+
if (cache.size >= MAX_CACHE) {
|
|
9
|
+
const first = cache.keys().next().value;
|
|
10
|
+
cache.delete(first);
|
|
11
|
+
}
|
|
12
|
+
const instance = create();
|
|
13
|
+
cache.set(key, instance);
|
|
14
|
+
return instance;
|
|
15
|
+
}
|
|
16
|
+
export function cacheKey(prefix, locale, opts) {
|
|
17
|
+
let key = `${prefix}:${locale}`;
|
|
18
|
+
for (const k of Object.keys(opts).sort()) {
|
|
19
|
+
const v = opts[k];
|
|
20
|
+
if (v !== undefined)
|
|
21
|
+
key += `:${k}=${v}`;
|
|
22
|
+
}
|
|
23
|
+
return key;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/format/defaults.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type DateValue = Date | string | number;
|
|
2
|
+
type DateStyle = 'full' | 'long' | 'medium' | 'short';
|
|
3
|
+
export interface FormatDateOptions {
|
|
4
|
+
locale?: string;
|
|
5
|
+
dateStyle?: DateStyle;
|
|
6
|
+
calendar?: string;
|
|
7
|
+
numberingSystem?: string;
|
|
8
|
+
timeZone?: string;
|
|
9
|
+
weekday?: 'long' | 'short' | 'narrow';
|
|
10
|
+
year?: 'numeric' | '2-digit';
|
|
11
|
+
month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow';
|
|
12
|
+
day?: 'numeric' | '2-digit';
|
|
13
|
+
era?: 'long' | 'short' | 'narrow';
|
|
14
|
+
}
|
|
15
|
+
export interface FormatTimeOptions {
|
|
16
|
+
locale?: string;
|
|
17
|
+
timeStyle?: DateStyle;
|
|
18
|
+
timeZone?: string;
|
|
19
|
+
hour12?: boolean;
|
|
20
|
+
hourCycle?: 'h11' | 'h12' | 'h23' | 'h24';
|
|
21
|
+
hour?: 'numeric' | '2-digit';
|
|
22
|
+
minute?: 'numeric' | '2-digit';
|
|
23
|
+
second?: 'numeric' | '2-digit';
|
|
24
|
+
fractionalSecondDigits?: 0 | 1 | 2 | 3;
|
|
25
|
+
timeZoneName?: 'long' | 'short' | 'shortOffset' | 'longOffset' | 'shortGeneric' | 'longGeneric';
|
|
26
|
+
dayPeriod?: 'narrow' | 'short' | 'long';
|
|
27
|
+
}
|
|
28
|
+
export interface FormatDateTimeOptions {
|
|
29
|
+
locale?: string;
|
|
30
|
+
dateStyle?: DateStyle;
|
|
31
|
+
timeStyle?: DateStyle;
|
|
32
|
+
timeZone?: string;
|
|
33
|
+
calendar?: string;
|
|
34
|
+
hour12?: boolean;
|
|
35
|
+
hourCycle?: 'h11' | 'h12' | 'h23' | 'h24';
|
|
36
|
+
}
|
|
37
|
+
export declare function formatDate(value: DateValue, opts?: FormatDateOptions): string;
|
|
38
|
+
export declare function formatTime(value: DateValue, opts?: FormatTimeOptions): string;
|
|
39
|
+
export declare function formatDateTime(value: DateValue, opts?: FormatDateTimeOptions): string;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=format-date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-date.d.ts","sourceRoot":"","sources":["../../src/format/format-date.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;AAQ9C,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;AAErD,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;IACrC,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IAC5B,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;IAC3D,GAAG,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IAC3B,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;CAClC;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;IACzC,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IAC5B,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IAC9B,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IAC9B,sBAAsB,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACtC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,aAAa,GAAG,YAAY,GAAG,cAAc,GAAG,aAAa,CAAA;IAC/F,SAAS,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;CACxC;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;CAC1C;AAqBD,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,GAAE,iBAAsB,GAAG,MAAM,CAOjF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,GAAE,iBAAsB,GAAG,MAAM,CAQjF;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,GAAE,qBAA0B,GAAG,MAAM,CAQzF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { cached, cacheKey } from './cache';
|
|
2
|
+
import { defaultLocale } from './defaults';
|
|
3
|
+
function toDate(value) {
|
|
4
|
+
if (value instanceof Date)
|
|
5
|
+
return value;
|
|
6
|
+
if (typeof value === 'string')
|
|
7
|
+
return new Date(value);
|
|
8
|
+
return new Date(value);
|
|
9
|
+
}
|
|
10
|
+
function buildIntlOpts(opts) {
|
|
11
|
+
const result = {};
|
|
12
|
+
for (const [k, v] of Object.entries(opts)) {
|
|
13
|
+
if (v !== undefined && k !== 'locale') {
|
|
14
|
+
;
|
|
15
|
+
result[k] = v;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
function fmt(prefix, locale, intlOpts) {
|
|
21
|
+
const key = cacheKey(prefix, locale, intlOpts);
|
|
22
|
+
return cached(key, () => new Intl.DateTimeFormat(locale, intlOpts));
|
|
23
|
+
}
|
|
24
|
+
export function formatDate(value, opts = {}) {
|
|
25
|
+
const locale = opts.locale ?? defaultLocale();
|
|
26
|
+
const hasFineGrained = opts.weekday || opts.year || opts.month || opts.day || opts.era;
|
|
27
|
+
const intlOpts = hasFineGrained
|
|
28
|
+
? buildIntlOpts(opts)
|
|
29
|
+
: buildIntlOpts({ ...opts, dateStyle: opts.dateStyle ?? 'medium' });
|
|
30
|
+
return fmt('date', locale, intlOpts).format(toDate(value));
|
|
31
|
+
}
|
|
32
|
+
export function formatTime(value, opts = {}) {
|
|
33
|
+
const locale = opts.locale ?? defaultLocale();
|
|
34
|
+
const hasFineGrained = opts.hour || opts.minute || opts.second || opts.fractionalSecondDigits || opts.dayPeriod;
|
|
35
|
+
const intlOpts = hasFineGrained
|
|
36
|
+
? buildIntlOpts(opts)
|
|
37
|
+
: buildIntlOpts({ ...opts, timeStyle: opts.timeStyle ?? 'medium' });
|
|
38
|
+
return fmt('time', locale, intlOpts).format(toDate(value));
|
|
39
|
+
}
|
|
40
|
+
export function formatDateTime(value, opts = {}) {
|
|
41
|
+
const locale = opts.locale ?? defaultLocale();
|
|
42
|
+
const intlOpts = buildIntlOpts({
|
|
43
|
+
...opts,
|
|
44
|
+
dateStyle: opts.dateStyle ?? 'medium',
|
|
45
|
+
timeStyle: opts.timeStyle ?? 'short',
|
|
46
|
+
});
|
|
47
|
+
return fmt('dt', locale, intlOpts).format(toDate(value));
|
|
48
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type DisplayNameType = 'language' | 'region' | 'script' | 'currency' | 'calendar' | 'dateTimeField';
|
|
2
|
+
export interface FormatDisplayNameOptions {
|
|
3
|
+
locale?: string;
|
|
4
|
+
style?: 'long' | 'short' | 'narrow';
|
|
5
|
+
languageDisplay?: 'dialect' | 'standard';
|
|
6
|
+
fallback?: 'code' | 'none';
|
|
7
|
+
}
|
|
8
|
+
export declare function formatDisplayName(value: string, type: DisplayNameType, opts?: FormatDisplayNameOptions): string | undefined;
|
|
9
|
+
//# sourceMappingURL=format-display-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-display-name.d.ts","sourceRoot":"","sources":["../../src/format/format-display-name.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,UAAU,GACV,eAAe,CAAA;AAEnB,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;IACnC,eAAe,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;IACxC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAC3B;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,eAAe,EACrB,IAAI,GAAE,wBAA6B,GAClC,MAAM,GAAG,SAAS,CAiBpB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { cached, cacheKey } from './cache';
|
|
2
|
+
import { defaultLocale } from './defaults';
|
|
3
|
+
export function formatDisplayName(value, type, opts = {}) {
|
|
4
|
+
const locale = opts.locale ?? defaultLocale();
|
|
5
|
+
const intlOpts = {
|
|
6
|
+
type,
|
|
7
|
+
style: opts.style ?? 'long',
|
|
8
|
+
fallback: opts.fallback ?? 'code',
|
|
9
|
+
};
|
|
10
|
+
if (opts.languageDisplay !== undefined && type === 'language') {
|
|
11
|
+
intlOpts.languageDisplay = opts.languageDisplay;
|
|
12
|
+
}
|
|
13
|
+
const key = cacheKey('dn', locale, { ...intlOpts });
|
|
14
|
+
const dn = cached(key, () => new Intl.DisplayNames(locale, intlOpts));
|
|
15
|
+
try {
|
|
16
|
+
return dn.of(value);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return opts.fallback === 'none' ? undefined : value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-file-size.d.ts","sourceRoot":"","sources":["../../src/format/format-file-size.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,GAAE,qBAA0B,GAAG,MAAM,CA4B/F"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cached, cacheKey } from './cache';
|
|
2
|
+
import { defaultLocale } from './defaults';
|
|
3
|
+
const DEFAULT_UNITS = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
4
|
+
export function formatFileSize(value, opts = {}) {
|
|
5
|
+
const locale = opts.locale ?? defaultLocale();
|
|
6
|
+
const units = opts.units ?? DEFAULT_UNITS;
|
|
7
|
+
const decimals = opts.decimalPlaces ?? 1;
|
|
8
|
+
let num = typeof value === 'bigint' ? Number(value) : value;
|
|
9
|
+
let unitIndex = 0;
|
|
10
|
+
while (num >= 1024 && unitIndex < units.length - 1) {
|
|
11
|
+
num /= 1024;
|
|
12
|
+
unitIndex++;
|
|
13
|
+
}
|
|
14
|
+
const fractionDigits = unitIndex === 0 ? 0 : decimals;
|
|
15
|
+
const intlOpts = {
|
|
16
|
+
minimumFractionDigits: fractionDigits,
|
|
17
|
+
maximumFractionDigits: fractionDigits,
|
|
18
|
+
};
|
|
19
|
+
const key = cacheKey('fs', locale, intlOpts);
|
|
20
|
+
const fmt = cached(key, () => new Intl.NumberFormat(locale, intlOpts));
|
|
21
|
+
const formatted = fmt.format(num);
|
|
22
|
+
// Strip trailing zeros when using default decimal places
|
|
23
|
+
const display = opts.decimalPlaces === undefined && unitIndex > 0
|
|
24
|
+
? formatted.replace(/([.,]\d*?)0+$/, '$1').replace(/[.,]$/, '')
|
|
25
|
+
: formatted;
|
|
26
|
+
return `${display} ${units[unitIndex]}`;
|
|
27
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface FormatListOptions {
|
|
2
|
+
locale?: string;
|
|
3
|
+
type?: 'conjunction' | 'disjunction' | 'unit';
|
|
4
|
+
style?: 'long' | 'short' | 'narrow';
|
|
5
|
+
}
|
|
6
|
+
export declare function formatList(value: string[], opts?: FormatListOptions): string;
|
|
7
|
+
//# sourceMappingURL=format-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-list.d.ts","sourceRoot":"","sources":["../../src/format/format-list.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,MAAM,CAAA;IAC7C,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;CACpC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,iBAAsB,GAAG,MAAM,CAShF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { cached, cacheKey } from './cache';
|
|
2
|
+
import { defaultLocale } from './defaults';
|
|
3
|
+
export function formatList(value, opts = {}) {
|
|
4
|
+
const locale = opts.locale ?? defaultLocale();
|
|
5
|
+
const intlOpts = {
|
|
6
|
+
type: opts.type ?? 'conjunction',
|
|
7
|
+
style: opts.style ?? 'long',
|
|
8
|
+
};
|
|
9
|
+
const key = cacheKey('list', locale, intlOpts);
|
|
10
|
+
const fmt = cached(key, () => new Intl.ListFormat(locale, intlOpts));
|
|
11
|
+
return fmt.format(value);
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface FormatNumberOptions {
|
|
2
|
+
locale?: string;
|
|
3
|
+
style?: 'decimal' | 'currency' | 'percent' | 'unit';
|
|
4
|
+
currency?: string;
|
|
5
|
+
currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name';
|
|
6
|
+
signDisplay?: 'auto' | 'never' | 'always' | 'exceptZero';
|
|
7
|
+
notation?: 'standard' | 'scientific' | 'engineering' | 'compact';
|
|
8
|
+
compactDisplay?: 'short' | 'long';
|
|
9
|
+
unit?: string;
|
|
10
|
+
unitDisplay?: 'short' | 'long' | 'narrow';
|
|
11
|
+
useGrouping?: boolean;
|
|
12
|
+
minimumIntegerDigits?: number;
|
|
13
|
+
minimumFractionDigits?: number;
|
|
14
|
+
maximumFractionDigits?: number;
|
|
15
|
+
minimumSignificantDigits?: number;
|
|
16
|
+
maximumSignificantDigits?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function formatNumber(value: number, opts?: FormatNumberOptions): string;
|
|
19
|
+
//# sourceMappingURL=format-number.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-number.d.ts","sourceRoot":"","sources":["../../src/format/format-number.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CAAA;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,QAAQ,GAAG,cAAc,GAAG,MAAM,GAAG,MAAM,CAAA;IAC7D,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,YAAY,CAAA;IACxD,QAAQ,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,SAAS,CAAA;IAChE,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAA;IACzC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,mBAAwB,GAAG,MAAM,CA0BlF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { cached, cacheKey } from './cache';
|
|
2
|
+
import { defaultLocale } from './defaults';
|
|
3
|
+
export function formatNumber(value, opts = {}) {
|
|
4
|
+
const locale = opts.locale ?? defaultLocale();
|
|
5
|
+
const intlOpts = {};
|
|
6
|
+
if (opts.style !== undefined)
|
|
7
|
+
intlOpts.style = opts.style;
|
|
8
|
+
if (opts.currency !== undefined)
|
|
9
|
+
intlOpts.currency = opts.currency;
|
|
10
|
+
if (opts.currencyDisplay !== undefined)
|
|
11
|
+
intlOpts.currencyDisplay = opts.currencyDisplay;
|
|
12
|
+
if (opts.signDisplay !== undefined)
|
|
13
|
+
intlOpts.signDisplay = opts.signDisplay;
|
|
14
|
+
if (opts.notation !== undefined)
|
|
15
|
+
intlOpts.notation = opts.notation;
|
|
16
|
+
if (opts.compactDisplay !== undefined)
|
|
17
|
+
intlOpts.compactDisplay = opts.compactDisplay;
|
|
18
|
+
if (opts.unit !== undefined)
|
|
19
|
+
intlOpts.unit = opts.unit;
|
|
20
|
+
if (opts.unitDisplay !== undefined)
|
|
21
|
+
intlOpts.unitDisplay = opts.unitDisplay;
|
|
22
|
+
if (opts.useGrouping !== undefined)
|
|
23
|
+
intlOpts.useGrouping = opts.useGrouping;
|
|
24
|
+
if (opts.minimumIntegerDigits !== undefined)
|
|
25
|
+
intlOpts.minimumIntegerDigits = opts.minimumIntegerDigits;
|
|
26
|
+
if (opts.minimumFractionDigits !== undefined)
|
|
27
|
+
intlOpts.minimumFractionDigits = opts.minimumFractionDigits;
|
|
28
|
+
if (opts.maximumFractionDigits !== undefined)
|
|
29
|
+
intlOpts.maximumFractionDigits = opts.maximumFractionDigits;
|
|
30
|
+
if (opts.minimumSignificantDigits !== undefined)
|
|
31
|
+
intlOpts.minimumSignificantDigits = opts.minimumSignificantDigits;
|
|
32
|
+
if (opts.maximumSignificantDigits !== undefined)
|
|
33
|
+
intlOpts.maximumSignificantDigits = opts.maximumSignificantDigits;
|
|
34
|
+
const key = cacheKey('num', locale, intlOpts);
|
|
35
|
+
const fmt = cached(key, () => new Intl.NumberFormat(locale, intlOpts));
|
|
36
|
+
return fmt.format(value);
|
|
37
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type PluralCategory = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other';
|
|
2
|
+
export type PluralMessages = Partial<Record<PluralCategory, string>> & {
|
|
3
|
+
other: string;
|
|
4
|
+
};
|
|
5
|
+
export interface FormatPluralOptions {
|
|
6
|
+
locale?: string;
|
|
7
|
+
type?: 'cardinal' | 'ordinal';
|
|
8
|
+
minimumIntegerDigits?: number;
|
|
9
|
+
minimumFractionDigits?: number;
|
|
10
|
+
maximumFractionDigits?: number;
|
|
11
|
+
minimumSignificantDigits?: number;
|
|
12
|
+
maximumSignificantDigits?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function resolvePluralCategory(value: number, opts?: FormatPluralOptions): PluralCategory;
|
|
15
|
+
export declare function formatPlural(value: number, messages: PluralMessages, opts?: FormatPluralOptions): string;
|
|
16
|
+
//# sourceMappingURL=format-plural.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-plural.d.ts","sourceRoot":"","sources":["../../src/format/format-plural.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAA;AAC9E,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAExF,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,CAAA;IAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,mBAAwB,GAC7B,cAAc,CAiBhB;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,cAAc,EACxB,IAAI,GAAE,mBAAwB,GAC7B,MAAM,CASR"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { cached, cacheKey } from './cache';
|
|
2
|
+
import { defaultLocale } from './defaults';
|
|
3
|
+
export function resolvePluralCategory(value, opts = {}) {
|
|
4
|
+
const locale = opts.locale ?? defaultLocale();
|
|
5
|
+
const intlOpts = { type: opts.type ?? 'cardinal' };
|
|
6
|
+
if (opts.minimumIntegerDigits !== undefined)
|
|
7
|
+
intlOpts.minimumIntegerDigits = opts.minimumIntegerDigits;
|
|
8
|
+
if (opts.minimumFractionDigits !== undefined)
|
|
9
|
+
intlOpts.minimumFractionDigits = opts.minimumFractionDigits;
|
|
10
|
+
if (opts.maximumFractionDigits !== undefined)
|
|
11
|
+
intlOpts.maximumFractionDigits = opts.maximumFractionDigits;
|
|
12
|
+
if (opts.minimumSignificantDigits !== undefined)
|
|
13
|
+
intlOpts.minimumSignificantDigits = opts.minimumSignificantDigits;
|
|
14
|
+
if (opts.maximumSignificantDigits !== undefined)
|
|
15
|
+
intlOpts.maximumSignificantDigits = opts.maximumSignificantDigits;
|
|
16
|
+
const key = cacheKey('plural', locale, intlOpts);
|
|
17
|
+
const rules = cached(key, () => new Intl.PluralRules(locale, intlOpts));
|
|
18
|
+
return rules.select(value);
|
|
19
|
+
}
|
|
20
|
+
export function formatPlural(value, messages, opts = {}) {
|
|
21
|
+
// Check for explicit zero/one/two messages before CLDR rules
|
|
22
|
+
// (English PluralRules returns 'other' for 0, but apps may want a 'zero' message)
|
|
23
|
+
if (value === 0 && messages.zero !== undefined)
|
|
24
|
+
return messages.zero;
|
|
25
|
+
const category = resolvePluralCategory(value, opts);
|
|
26
|
+
const template = messages[category] ?? messages.other;
|
|
27
|
+
const locale = opts.locale ?? defaultLocale();
|
|
28
|
+
const formatted = new Intl.NumberFormat(locale).format(value);
|
|
29
|
+
return template.replace(/\{count\}/g, formatted);
|
|
30
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type RelativeTimeUnit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
|
|
2
|
+
export interface FormatRelativeTimeOptions {
|
|
3
|
+
locale?: string;
|
|
4
|
+
numeric?: 'always' | 'auto';
|
|
5
|
+
style?: 'long' | 'short' | 'narrow';
|
|
6
|
+
}
|
|
7
|
+
export declare function formatRelativeTime(value: number, unit: RelativeTimeUnit, opts?: FormatRelativeTimeOptions): string;
|
|
8
|
+
//# sourceMappingURL=format-relative-time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-relative-time.d.ts","sourceRoot":"","sources":["../../src/format/format-relative-time.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,SAAS,GACT,OAAO,GACP,MAAM,GACN,KAAK,GACL,MAAM,GACN,QAAQ,GACR,QAAQ,CAAA;AAEZ,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;CACpC;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,gBAAgB,EACtB,IAAI,GAAE,yBAA8B,GACnC,MAAM,CASR"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { cached, cacheKey } from './cache';
|
|
2
|
+
import { defaultLocale } from './defaults';
|
|
3
|
+
export function formatRelativeTime(value, unit, opts = {}) {
|
|
4
|
+
const locale = opts.locale ?? defaultLocale();
|
|
5
|
+
const intlOpts = {
|
|
6
|
+
numeric: opts.numeric ?? 'auto',
|
|
7
|
+
style: opts.style ?? 'long',
|
|
8
|
+
};
|
|
9
|
+
const key = cacheKey('rel', locale, intlOpts);
|
|
10
|
+
const fmt = cached(key, () => new Intl.RelativeTimeFormat(locale, intlOpts));
|
|
11
|
+
return fmt.format(value, unit);
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { formatNumber, type FormatNumberOptions } from './format-number';
|
|
2
|
+
export { formatDate, formatTime, formatDateTime, type DateValue, type FormatDateOptions, type FormatTimeOptions, type FormatDateTimeOptions, } from './format-date';
|
|
3
|
+
export { formatRelativeTime, type RelativeTimeUnit, type FormatRelativeTimeOptions, } from './format-relative-time';
|
|
4
|
+
export { formatList, type FormatListOptions } from './format-list';
|
|
5
|
+
export { formatPlural, resolvePluralCategory, type PluralCategory, type PluralMessages, type FormatPluralOptions, } from './format-plural';
|
|
6
|
+
export { formatDisplayName, type DisplayNameType, type FormatDisplayNameOptions, } from './format-display-name';
|
|
7
|
+
export { formatFileSize, type FormatFileSizeOptions } from './format-file-size';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/format/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACxE,OAAO,EACL,UAAU,EACV,UAAU,EACV,cAAc,EACd,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,GAC/B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,wBAAwB,GAC9B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { formatNumber } from './format-number';
|
|
2
|
+
export { formatDate, formatTime, formatDateTime, } from './format-date';
|
|
3
|
+
export { formatRelativeTime, } from './format-relative-time';
|
|
4
|
+
export { formatList } from './format-list';
|
|
5
|
+
export { formatPlural, resolvePluralCategory, } from './format-plural';
|
|
6
|
+
export { formatDisplayName, } from './format-display-name';
|
|
7
|
+
export { formatFileSize } from './format-file-size';
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,eAAe,CAAA;AAE7B,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAEzD,cAAc,gBAAgB,CAAA;AAE9B,cAAc,eAAe,CAAA;AAE7B,cAAc,oBAAoB,CAAA"}
|