@zag-js/i18n-utils 1.35.1 → 1.35.3
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/collator.js +1 -1
- package/dist/filter.js +1 -1
- package/dist/format-bytes.js +1 -1
- package/dist/format-list.js +1 -1
- package/dist/format-number.js +1 -1
- package/dist/format-relative-time.js +1 -1
- package/dist/format-time.d.mts +3 -6
- package/dist/format-time.d.ts +3 -6
- package/dist/format-time.js +8 -4
- package/dist/format-time.mjs +7 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -19
- package/dist/locale.js +1 -1
- package/dist/track-locale.js +1 -1
- package/package.json +2 -2
package/dist/collator.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(collator_exports, {
|
|
|
23
23
|
createCollator: () => createCollator
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(collator_exports);
|
|
26
|
-
var import_cache = require("./cache.
|
|
26
|
+
var import_cache = require("./cache.js");
|
|
27
27
|
var getCollator = (0, import_cache.i18nCache)(Intl.Collator);
|
|
28
28
|
function createCollator(locale = "en-US", options = {}) {
|
|
29
29
|
return getCollator(locale, options);
|
package/dist/filter.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(filter_exports, {
|
|
|
23
23
|
createFilter: () => createFilter
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(filter_exports);
|
|
26
|
-
var import_cache = require("./cache.
|
|
26
|
+
var import_cache = require("./cache.js");
|
|
27
27
|
var collatorCache = (0, import_cache.i18nCache)(Intl.Collator);
|
|
28
28
|
function createFilter(options) {
|
|
29
29
|
const { locale, ...rest } = options || {};
|
package/dist/format-bytes.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(format_bytes_exports, {
|
|
|
23
23
|
formatBytes: () => formatBytes
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(format_bytes_exports);
|
|
26
|
-
var import_format_number = require("./format-number.
|
|
26
|
+
var import_format_number = require("./format-number.js");
|
|
27
27
|
var bitPrefixes = ["", "kilo", "mega", "giga", "tera"];
|
|
28
28
|
var bytePrefixes = ["", "kilo", "mega", "giga", "tera", "peta"];
|
|
29
29
|
var formatBytes = (bytes, locale = "en-US", options = {}) => {
|
package/dist/format-list.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(format_list_exports, {
|
|
|
23
23
|
formatList: () => formatList
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(format_list_exports);
|
|
26
|
-
var import_cache = require("./cache.
|
|
26
|
+
var import_cache = require("./cache.js");
|
|
27
27
|
var getListFormatter = (0, import_cache.i18nCache)(Intl.ListFormat);
|
|
28
28
|
function formatList(list, locale, options = {}) {
|
|
29
29
|
const formatter = getListFormatter(locale, options);
|
package/dist/format-number.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(format_number_exports, {
|
|
|
23
23
|
formatNumber: () => formatNumber
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(format_number_exports);
|
|
26
|
-
var import_cache = require("./cache.
|
|
26
|
+
var import_cache = require("./cache.js");
|
|
27
27
|
var getNumberFormatter = (0, import_cache.i18nCache)(Intl.NumberFormat);
|
|
28
28
|
function formatNumber(v, locale, options = {}) {
|
|
29
29
|
const formatter = getNumberFormatter(locale, options);
|
|
@@ -23,7 +23,7 @@ __export(format_relative_time_exports, {
|
|
|
23
23
|
formatRelativeTime: () => formatRelativeTime
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(format_relative_time_exports);
|
|
26
|
-
var import_cache = require("./cache.
|
|
26
|
+
var import_cache = require("./cache.js");
|
|
27
27
|
var getRelativeTimeFormatter = (0, import_cache.i18nCache)(Intl.RelativeTimeFormat);
|
|
28
28
|
function formatRelativeTime(value, locale, options = {}) {
|
|
29
29
|
const rtf = getRelativeTimeFormatter(locale, options);
|
package/dist/format-time.d.mts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
type TimeFormat = "12h" | "24h";
|
|
2
|
-
interface AmPmLabels {
|
|
3
|
-
am: string;
|
|
4
|
-
pm: string;
|
|
5
|
-
}
|
|
6
2
|
interface FormatTimeOptions {
|
|
7
3
|
format?: TimeFormat;
|
|
8
|
-
|
|
4
|
+
amLabel?: string;
|
|
5
|
+
pmLabel?: string;
|
|
9
6
|
withSeconds?: boolean;
|
|
10
7
|
}
|
|
11
8
|
declare function formatTime(value: string | Date, locale: string, options?: FormatTimeOptions): string | null;
|
|
12
9
|
|
|
13
|
-
export { type
|
|
10
|
+
export { type FormatTimeOptions, type TimeFormat, formatTime };
|
package/dist/format-time.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
type TimeFormat = "12h" | "24h";
|
|
2
|
-
interface AmPmLabels {
|
|
3
|
-
am: string;
|
|
4
|
-
pm: string;
|
|
5
|
-
}
|
|
6
2
|
interface FormatTimeOptions {
|
|
7
3
|
format?: TimeFormat;
|
|
8
|
-
|
|
4
|
+
amLabel?: string;
|
|
5
|
+
pmLabel?: string;
|
|
9
6
|
withSeconds?: boolean;
|
|
10
7
|
}
|
|
11
8
|
declare function formatTime(value: string | Date, locale: string, options?: FormatTimeOptions): string | null;
|
|
12
9
|
|
|
13
|
-
export { type
|
|
10
|
+
export { type FormatTimeOptions, type TimeFormat, formatTime };
|
package/dist/format-time.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(format_time_exports, {
|
|
|
23
23
|
formatTime: () => formatTime
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(format_time_exports);
|
|
26
|
-
var import_cache = require("./cache.
|
|
26
|
+
var import_cache = require("./cache.js");
|
|
27
27
|
var getTimeFormatter = (0, import_cache.i18nCache)(Intl.DateTimeFormat);
|
|
28
28
|
function splitTimeString(timeString) {
|
|
29
29
|
const [hours = null, minutes = null, seconds = null] = timeString.split(":");
|
|
@@ -55,7 +55,7 @@ function getTimeParts(value) {
|
|
|
55
55
|
return { date, hours, minutes, seconds: seconds ?? 0 };
|
|
56
56
|
}
|
|
57
57
|
function formatTime(value, locale, options = {}) {
|
|
58
|
-
const { format = "24h",
|
|
58
|
+
const { format = "24h", amLabel, pmLabel, withSeconds = false } = options;
|
|
59
59
|
const parts = getTimeParts(value);
|
|
60
60
|
if (!parts) return null;
|
|
61
61
|
const formatter = getTimeFormatter(locale, {
|
|
@@ -64,12 +64,16 @@ function formatTime(value, locale, options = {}) {
|
|
|
64
64
|
second: withSeconds ? "2-digit" : void 0,
|
|
65
65
|
hour12: format === "12h"
|
|
66
66
|
});
|
|
67
|
-
if (format !== "12h"
|
|
67
|
+
if (format !== "12h") {
|
|
68
68
|
return formatter.format(parts.date);
|
|
69
69
|
}
|
|
70
70
|
const isPm = parts.hours >= 12;
|
|
71
71
|
const tokens = formatter.formatToParts(parts.date);
|
|
72
|
-
return tokens.map((token) =>
|
|
72
|
+
return tokens.map((token) => {
|
|
73
|
+
if (token.type !== "dayPeriod") return token.value;
|
|
74
|
+
if (isPm) return pmLabel ?? token.value;
|
|
75
|
+
return amLabel ?? token.value;
|
|
76
|
+
}).join("");
|
|
73
77
|
}
|
|
74
78
|
// Annotate the CommonJS export names for ESM import in node:
|
|
75
79
|
0 && (module.exports = {
|
package/dist/format-time.mjs
CHANGED
|
@@ -31,7 +31,7 @@ function getTimeParts(value) {
|
|
|
31
31
|
return { date, hours, minutes, seconds: seconds ?? 0 };
|
|
32
32
|
}
|
|
33
33
|
function formatTime(value, locale, options = {}) {
|
|
34
|
-
const { format = "24h",
|
|
34
|
+
const { format = "24h", amLabel, pmLabel, withSeconds = false } = options;
|
|
35
35
|
const parts = getTimeParts(value);
|
|
36
36
|
if (!parts) return null;
|
|
37
37
|
const formatter = getTimeFormatter(locale, {
|
|
@@ -40,12 +40,16 @@ function formatTime(value, locale, options = {}) {
|
|
|
40
40
|
second: withSeconds ? "2-digit" : void 0,
|
|
41
41
|
hour12: format === "12h"
|
|
42
42
|
});
|
|
43
|
-
if (format !== "12h"
|
|
43
|
+
if (format !== "12h") {
|
|
44
44
|
return formatter.format(parts.date);
|
|
45
45
|
}
|
|
46
46
|
const isPm = parts.hours >= 12;
|
|
47
47
|
const tokens = formatter.formatToParts(parts.date);
|
|
48
|
-
return tokens.map((token) =>
|
|
48
|
+
return tokens.map((token) => {
|
|
49
|
+
if (token.type !== "dayPeriod") return token.value;
|
|
50
|
+
if (isPm) return pmLabel ?? token.value;
|
|
51
|
+
return amLabel ?? token.value;
|
|
52
|
+
}).join("");
|
|
49
53
|
}
|
|
50
54
|
export {
|
|
51
55
|
formatTime
|
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ export { formatDate } from './format-date.mjs';
|
|
|
5
5
|
export { formatList } from './format-list.mjs';
|
|
6
6
|
export { formatNumber } from './format-number.mjs';
|
|
7
7
|
export { formatRelativeTime } from './format-relative-time.mjs';
|
|
8
|
-
export {
|
|
8
|
+
export { FormatTimeOptions, TimeFormat, formatTime } from './format-time.mjs';
|
|
9
9
|
export { getLocaleDir, isRTL } from './is-rtl.mjs';
|
|
10
10
|
export { Locale, getDefaultLocale } from './locale.mjs';
|
|
11
11
|
export { LocaleOptions, trackLocale } from './track-locale.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { formatDate } from './format-date.js';
|
|
|
5
5
|
export { formatList } from './format-list.js';
|
|
6
6
|
export { formatNumber } from './format-number.js';
|
|
7
7
|
export { formatRelativeTime } from './format-relative-time.js';
|
|
8
|
-
export {
|
|
8
|
+
export { FormatTimeOptions, TimeFormat, formatTime } from './format-time.js';
|
|
9
9
|
export { getLocaleDir, isRTL } from './is-rtl.js';
|
|
10
10
|
export { Locale, getDefaultLocale } from './locale.js';
|
|
11
11
|
export { LocaleOptions, trackLocale } from './track-locale.js';
|
package/dist/index.js
CHANGED
|
@@ -27,29 +27,29 @@ __export(index_exports, {
|
|
|
27
27
|
trackLocale: () => import_track_locale.trackLocale
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(index_exports);
|
|
30
|
-
__reExport(index_exports, require("./collator.
|
|
31
|
-
__reExport(index_exports, require("./filter.
|
|
32
|
-
__reExport(index_exports, require("./format-bytes.
|
|
33
|
-
__reExport(index_exports, require("./format-date.
|
|
34
|
-
__reExport(index_exports, require("./format-list.
|
|
35
|
-
__reExport(index_exports, require("./format-number.
|
|
36
|
-
__reExport(index_exports, require("./format-relative-time.
|
|
37
|
-
__reExport(index_exports, require("./format-time.
|
|
38
|
-
var import_is_rtl = require("./is-rtl.
|
|
39
|
-
var import_locale = require("./locale.
|
|
40
|
-
var import_track_locale = require("./track-locale.
|
|
30
|
+
__reExport(index_exports, require("./collator.js"), module.exports);
|
|
31
|
+
__reExport(index_exports, require("./filter.js"), module.exports);
|
|
32
|
+
__reExport(index_exports, require("./format-bytes.js"), module.exports);
|
|
33
|
+
__reExport(index_exports, require("./format-date.js"), module.exports);
|
|
34
|
+
__reExport(index_exports, require("./format-list.js"), module.exports);
|
|
35
|
+
__reExport(index_exports, require("./format-number.js"), module.exports);
|
|
36
|
+
__reExport(index_exports, require("./format-relative-time.js"), module.exports);
|
|
37
|
+
__reExport(index_exports, require("./format-time.js"), module.exports);
|
|
38
|
+
var import_is_rtl = require("./is-rtl.js");
|
|
39
|
+
var import_locale = require("./locale.js");
|
|
40
|
+
var import_track_locale = require("./track-locale.js");
|
|
41
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
42
|
0 && (module.exports = {
|
|
43
43
|
getDefaultLocale,
|
|
44
44
|
getLocaleDir,
|
|
45
45
|
isRTL,
|
|
46
46
|
trackLocale,
|
|
47
|
-
...require("./collator.
|
|
48
|
-
...require("./filter.
|
|
49
|
-
...require("./format-bytes.
|
|
50
|
-
...require("./format-date.
|
|
51
|
-
...require("./format-list.
|
|
52
|
-
...require("./format-number.
|
|
53
|
-
...require("./format-relative-time.
|
|
54
|
-
...require("./format-time.
|
|
47
|
+
...require("./collator.js"),
|
|
48
|
+
...require("./filter.js"),
|
|
49
|
+
...require("./format-bytes.js"),
|
|
50
|
+
...require("./format-date.js"),
|
|
51
|
+
...require("./format-list.js"),
|
|
52
|
+
...require("./format-number.js"),
|
|
53
|
+
...require("./format-relative-time.js"),
|
|
54
|
+
...require("./format-time.js")
|
|
55
55
|
});
|
package/dist/locale.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(locale_exports, {
|
|
|
23
23
|
getDefaultLocale: () => getDefaultLocale
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(locale_exports);
|
|
26
|
-
var import_is_rtl = require("./is-rtl.
|
|
26
|
+
var import_is_rtl = require("./is-rtl.js");
|
|
27
27
|
function getDefaultLocale() {
|
|
28
28
|
let locale = typeof navigator !== "undefined" && (navigator.language || navigator.userLanguage) || "en-US";
|
|
29
29
|
try {
|
package/dist/track-locale.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(track_locale_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(track_locale_exports);
|
|
26
26
|
var import_dom_query = require("@zag-js/dom-query");
|
|
27
|
-
var import_locale = require("./locale.
|
|
27
|
+
var import_locale = require("./locale.js");
|
|
28
28
|
function trackLocale(options = {}) {
|
|
29
29
|
const { getRootNode, onLocaleChange } = options;
|
|
30
30
|
onLocaleChange?.((0, import_locale.getDefaultLocale)());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/i18n-utils",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.3",
|
|
4
4
|
"description": "Interationalization utilities for Zag.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"clean-package": "../../../clean-package.config.json",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@zag-js/dom-query": "1.35.
|
|
27
|
+
"@zag-js/dom-query": "1.35.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"clean-package": "2.2.0",
|