preact-intlayer 5.8.0-canary.0 → 5.8.1
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/cjs/client/format/index.cjs +50 -0
- package/dist/cjs/client/format/index.cjs.map +1 -0
- package/dist/cjs/client/format/useCompact.cjs +42 -0
- package/dist/cjs/client/format/useCompact.cjs.map +1 -0
- package/dist/cjs/client/format/useCurrency.cjs +42 -0
- package/dist/cjs/client/format/useCurrency.cjs.map +1 -0
- package/dist/cjs/client/format/useDate.cjs +39 -0
- package/dist/cjs/client/format/useDate.cjs.map +1 -0
- package/dist/cjs/client/format/useList.cjs +42 -0
- package/dist/cjs/client/format/useList.cjs.map +1 -0
- package/dist/cjs/client/format/useNumber.cjs +42 -0
- package/dist/cjs/client/format/useNumber.cjs.map +1 -0
- package/dist/cjs/client/format/usePercentage.cjs +42 -0
- package/dist/cjs/client/format/usePercentage.cjs.map +1 -0
- package/dist/cjs/client/format/useRelativeTime.cjs +42 -0
- package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -0
- package/dist/cjs/client/format/useUnit.cjs +42 -0
- package/dist/cjs/client/format/useUnit.cjs.map +1 -0
- package/dist/esm/client/format/index.mjs +19 -0
- package/dist/esm/client/format/index.mjs.map +1 -0
- package/dist/esm/client/format/useCompact.mjs +18 -0
- package/dist/esm/client/format/useCompact.mjs.map +1 -0
- package/dist/esm/client/format/useCurrency.mjs +18 -0
- package/dist/esm/client/format/useCurrency.mjs.map +1 -0
- package/dist/esm/client/format/useDate.mjs +15 -0
- package/dist/esm/client/format/useDate.mjs.map +1 -0
- package/dist/esm/client/format/useList.mjs +18 -0
- package/dist/esm/client/format/useList.mjs.map +1 -0
- package/dist/esm/client/format/useNumber.mjs +18 -0
- package/dist/esm/client/format/useNumber.mjs.map +1 -0
- package/dist/esm/client/format/usePercentage.mjs +18 -0
- package/dist/esm/client/format/usePercentage.mjs.map +1 -0
- package/dist/esm/client/format/useRelativeTime.mjs +18 -0
- package/dist/esm/client/format/useRelativeTime.mjs.map +1 -0
- package/dist/esm/client/format/useUnit.mjs +18 -0
- package/dist/esm/client/format/useUnit.mjs.map +1 -0
- package/dist/types/client/format/index.d.ts +9 -0
- package/dist/types/client/format/index.d.ts.map +1 -0
- package/dist/types/client/format/useCompact.d.ts +14 -0
- package/dist/types/client/format/useCompact.d.ts.map +1 -0
- package/dist/types/client/format/useCurrency.d.ts +28 -0
- package/dist/types/client/format/useCurrency.d.ts.map +1 -0
- package/dist/types/client/format/useDate.d.ts +29 -0
- package/dist/types/client/format/useDate.d.ts.map +1 -0
- package/dist/types/client/format/useList.d.ts +25 -0
- package/dist/types/client/format/useList.d.ts.map +1 -0
- package/dist/types/client/format/useNumber.d.ts +26 -0
- package/dist/types/client/format/useNumber.d.ts.map +1 -0
- package/dist/types/client/format/usePercentage.d.ts +22 -0
- package/dist/types/client/format/usePercentage.d.ts.map +1 -0
- package/dist/types/client/format/useRelativeTime.d.ts +23 -0
- package/dist/types/client/format/useRelativeTime.d.ts.map +1 -0
- package/dist/types/client/format/useUnit.d.ts +21 -0
- package/dist/types/client/format/useUnit.d.ts.map +1 -0
- package/package.json +19 -14
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var format_exports = {};
|
|
20
|
+
__export(format_exports, {
|
|
21
|
+
useCompact: () => import_useCompact.useCompact,
|
|
22
|
+
useCurrency: () => import_useCurrency.useCurrency,
|
|
23
|
+
useDate: () => import_useDate.useDate,
|
|
24
|
+
useList: () => import_useList.useList,
|
|
25
|
+
useNumber: () => import_useNumber.useNumber,
|
|
26
|
+
usePercentage: () => import_usePercentage.usePercentage,
|
|
27
|
+
useRelativeTime: () => import_useRelativeTime.useRelativeTime,
|
|
28
|
+
useUnit: () => import_useUnit.useUnit
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(format_exports);
|
|
31
|
+
var import_useCompact = require('./useCompact.cjs');
|
|
32
|
+
var import_useCurrency = require('./useCurrency.cjs');
|
|
33
|
+
var import_useDate = require('./useDate.cjs');
|
|
34
|
+
var import_useList = require('./useList.cjs');
|
|
35
|
+
var import_useNumber = require('./useNumber.cjs');
|
|
36
|
+
var import_usePercentage = require('./usePercentage.cjs');
|
|
37
|
+
var import_useRelativeTime = require('./useRelativeTime.cjs');
|
|
38
|
+
var import_useUnit = require('./useUnit.cjs');
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
useCompact,
|
|
42
|
+
useCurrency,
|
|
43
|
+
useDate,
|
|
44
|
+
useList,
|
|
45
|
+
useNumber,
|
|
46
|
+
usePercentage,
|
|
47
|
+
useRelativeTime,
|
|
48
|
+
useUnit
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/index.ts"],"sourcesContent":["export { useCompact } from './useCompact';\nexport { useCurrency } from './useCurrency';\nexport { useDate } from './useDate';\nexport { useList } from './useList';\nexport { useNumber } from './useNumber';\nexport { usePercentage } from './usePercentage';\nexport { useRelativeTime } from './useRelativeTime';\nexport { useUnit } from './useUnit';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA2B;AAC3B,yBAA4B;AAC5B,qBAAwB;AACxB,qBAAwB;AACxB,uBAA0B;AAC1B,2BAA8B;AAC9B,6BAAgC;AAChC,qBAAwB;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var useCompact_exports = {};
|
|
21
|
+
__export(useCompact_exports, {
|
|
22
|
+
useCompact: () => useCompact
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useCompact_exports);
|
|
25
|
+
var import_core = require("@intlayer/core");
|
|
26
|
+
var import_hooks = require("preact/hooks");
|
|
27
|
+
var import_IntlayerProvider = require('../IntlayerProvider.cjs');
|
|
28
|
+
const useCompact = () => {
|
|
29
|
+
const { locale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
|
|
30
|
+
return (0, import_hooks.useCallback)(
|
|
31
|
+
(...args) => (0, import_core.compact)(args[0], {
|
|
32
|
+
...args[1],
|
|
33
|
+
locale: args[1]?.locale ?? locale
|
|
34
|
+
}),
|
|
35
|
+
[locale]
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
useCompact
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=useCompact.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["'use client';\n\nimport { compact } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAwB;AACxB,mBAAwC;AACxC,8BAAsC;AAY/B,MAAM,aAAa,MAAM;AAC9B,QAAM,EAAE,OAAO,QAAI,yBAAW,6CAAqB;AAEnD,aAAO;AAAA,IACL,IAAI,aACF,qBAAQ,KAAK,CAAC,GAAG;AAAA,MACf,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var useCurrency_exports = {};
|
|
21
|
+
__export(useCurrency_exports, {
|
|
22
|
+
useCurrency: () => useCurrency
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useCurrency_exports);
|
|
25
|
+
var import_core = require("@intlayer/core");
|
|
26
|
+
var import_hooks = require("preact/hooks");
|
|
27
|
+
var import_IntlayerProvider = require('../IntlayerProvider.cjs');
|
|
28
|
+
const useCurrency = () => {
|
|
29
|
+
const { locale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
|
|
30
|
+
return (0, import_hooks.useCallback)(
|
|
31
|
+
(...args) => (0, import_core.currency)(args[0], {
|
|
32
|
+
...args[1],
|
|
33
|
+
locale: args[1]?.locale ?? locale
|
|
34
|
+
}),
|
|
35
|
+
[locale]
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
useCurrency
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=useCurrency.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["'use client';\n\nimport { currency } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAyB;AACzB,mBAAwC;AACxC,8BAAsC;AA0B/B,MAAM,cAAc,MAAM;AAC/B,QAAM,EAAE,OAAO,QAAI,yBAAW,6CAAqB;AAEnD,aAAO;AAAA,IACL,IAAI,aACF,sBAAS,KAAK,CAAC,GAAG;AAAA,MAChB,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var useDate_exports = {};
|
|
21
|
+
__export(useDate_exports, {
|
|
22
|
+
useDate: () => useDate
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useDate_exports);
|
|
25
|
+
var import_core = require("@intlayer/core");
|
|
26
|
+
var import_hooks = require("preact/hooks");
|
|
27
|
+
var import_IntlayerProvider = require('../IntlayerProvider.cjs');
|
|
28
|
+
const useDate = () => {
|
|
29
|
+
const { locale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
|
|
30
|
+
return (...args) => (0, import_core.date)(args[0], {
|
|
31
|
+
...args[1],
|
|
32
|
+
locale: args[1]?.locale ?? locale
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
useDate
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=useDate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date } from '@intlayer/core';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAqB;AACrB,mBAA2B;AAC3B,8BAAsC;AA4B/B,MAAM,UAAU,MAAM;AAC3B,QAAM,EAAE,OAAO,QAAI,yBAAW,6CAAqB;AAEnD,SAAO,IAAI,aACT,kBAAK,KAAK,CAAC,GAAG;AAAA,IACZ,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var useList_exports = {};
|
|
21
|
+
__export(useList_exports, {
|
|
22
|
+
useList: () => useList
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useList_exports);
|
|
25
|
+
var import_core = require("@intlayer/core");
|
|
26
|
+
var import_hooks = require("preact/hooks");
|
|
27
|
+
var import_IntlayerProvider = require('../IntlayerProvider.cjs');
|
|
28
|
+
const useList = () => {
|
|
29
|
+
const { locale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
|
|
30
|
+
return (0, import_hooks.useCallback)(
|
|
31
|
+
(...args) => (0, import_core.list)(args[0], {
|
|
32
|
+
...args[1],
|
|
33
|
+
locale: args[1]?.locale ?? locale
|
|
34
|
+
}),
|
|
35
|
+
[locale]
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
useList
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=useList.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["'use client';\n\nimport { list } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAqB;AACrB,mBAAwC;AACxC,8BAAsC;AAuB/B,MAAM,UAAU,MAAM;AAC3B,QAAM,EAAE,OAAO,QAAI,yBAAW,6CAAqB;AAEnD,aAAO;AAAA,IACL,IAAI,aACF,kBAAK,KAAK,CAAC,GAAG;AAAA,MACZ,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var useNumber_exports = {};
|
|
21
|
+
__export(useNumber_exports, {
|
|
22
|
+
useNumber: () => useNumber
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useNumber_exports);
|
|
25
|
+
var import_core = require("@intlayer/core");
|
|
26
|
+
var import_hooks = require("preact/hooks");
|
|
27
|
+
var import_IntlayerProvider = require('../IntlayerProvider.cjs');
|
|
28
|
+
const useNumber = () => {
|
|
29
|
+
const { locale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
|
|
30
|
+
return (0, import_hooks.useCallback)(
|
|
31
|
+
(...args) => (0, import_core.number)(args[0], {
|
|
32
|
+
...args[1],
|
|
33
|
+
locale: args[1]?.locale ?? locale
|
|
34
|
+
}),
|
|
35
|
+
[locale]
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
useNumber
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=useNumber.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useNumber.ts"],"sourcesContent":["'use client';\n\nimport { number } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAuB;AACvB,mBAAwC;AACxC,8BAAsC;AAwB/B,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,OAAO,QAAI,yBAAW,6CAAqB;AAEnD,aAAO;AAAA,IACL,IAAI,aACF,oBAAO,KAAK,CAAC,GAAG;AAAA,MACd,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var usePercentage_exports = {};
|
|
21
|
+
__export(usePercentage_exports, {
|
|
22
|
+
usePercentage: () => usePercentage
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(usePercentage_exports);
|
|
25
|
+
var import_core = require("@intlayer/core");
|
|
26
|
+
var import_hooks = require("preact/hooks");
|
|
27
|
+
var import_IntlayerProvider = require('../IntlayerProvider.cjs');
|
|
28
|
+
const usePercentage = () => {
|
|
29
|
+
const { locale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
|
|
30
|
+
return (0, import_hooks.useCallback)(
|
|
31
|
+
(...args) => (0, import_core.percentage)(args[0], {
|
|
32
|
+
...args[1],
|
|
33
|
+
locale: args[1]?.locale ?? locale
|
|
34
|
+
}),
|
|
35
|
+
[locale]
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
usePercentage
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=usePercentage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/usePercentage.ts"],"sourcesContent":["'use client';\n\nimport { percentage } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAA2B;AAC3B,mBAAwC;AACxC,8BAAsC;AAoB/B,MAAM,gBAAgB,MAAM;AACjC,QAAM,EAAE,OAAO,QAAI,yBAAW,6CAAqB;AAEnD,aAAO;AAAA,IACL,IAAI,aACF,wBAAW,KAAK,CAAC,GAAG;AAAA,MAClB,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var useRelativeTime_exports = {};
|
|
21
|
+
__export(useRelativeTime_exports, {
|
|
22
|
+
useRelativeTime: () => useRelativeTime
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useRelativeTime_exports);
|
|
25
|
+
var import_core = require("@intlayer/core");
|
|
26
|
+
var import_hooks = require("preact/hooks");
|
|
27
|
+
var import_IntlayerProvider = require('../IntlayerProvider.cjs');
|
|
28
|
+
const useRelativeTime = () => {
|
|
29
|
+
const { locale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
|
|
30
|
+
return (0, import_hooks.useCallback)(
|
|
31
|
+
(...args) => (0, import_core.relativeTime)(args[0], args[1], {
|
|
32
|
+
...args[2],
|
|
33
|
+
locale: args[2]?.locale ?? locale
|
|
34
|
+
}),
|
|
35
|
+
[locale]
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
useRelativeTime
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=useRelativeTime.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useRelativeTime.ts"],"sourcesContent":["'use client';\n\nimport { relativeTime } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAA6B;AAC7B,mBAAwC;AACxC,8BAAsC;AAoB/B,MAAM,kBAAkB,MAAM;AACnC,QAAM,EAAE,OAAO,QAAI,yBAAW,6CAAqB;AAEnD,aAAO;AAAA,IACL,IAAI,aACF,0BAAa,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG;AAAA,MAC7B,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var useUnit_exports = {};
|
|
21
|
+
__export(useUnit_exports, {
|
|
22
|
+
useUnit: () => useUnit
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useUnit_exports);
|
|
25
|
+
var import_core = require("@intlayer/core");
|
|
26
|
+
var import_hooks = require("preact/hooks");
|
|
27
|
+
var import_IntlayerProvider = require('../IntlayerProvider.cjs');
|
|
28
|
+
const useUnit = () => {
|
|
29
|
+
const { locale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
|
|
30
|
+
return (0, import_hooks.useCallback)(
|
|
31
|
+
(...args) => (0, import_core.units)(args[0], {
|
|
32
|
+
...args[1],
|
|
33
|
+
locale: args[1]?.locale ?? locale
|
|
34
|
+
}),
|
|
35
|
+
[locale]
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
useUnit
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=useUnit.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useUnit.ts"],"sourcesContent":["'use client';\n\nimport { units } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAsB;AACtB,mBAAwC;AACxC,8BAAsC;AAmB/B,MAAM,UAAU,MAAM;AAC3B,QAAM,EAAE,OAAO,QAAI,yBAAW,6CAAqB;AAEnD,aAAO;AAAA,IACL,IAAI,aACF,mBAAM,KAAK,CAAC,GAAG;AAAA,MACb,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useCompact } from "./useCompact.mjs";
|
|
2
|
+
import { useCurrency } from "./useCurrency.mjs";
|
|
3
|
+
import { useDate } from "./useDate.mjs";
|
|
4
|
+
import { useList } from "./useList.mjs";
|
|
5
|
+
import { useNumber } from "./useNumber.mjs";
|
|
6
|
+
import { usePercentage } from "./usePercentage.mjs";
|
|
7
|
+
import { useRelativeTime } from "./useRelativeTime.mjs";
|
|
8
|
+
import { useUnit } from "./useUnit.mjs";
|
|
9
|
+
export {
|
|
10
|
+
useCompact,
|
|
11
|
+
useCurrency,
|
|
12
|
+
useDate,
|
|
13
|
+
useList,
|
|
14
|
+
useNumber,
|
|
15
|
+
usePercentage,
|
|
16
|
+
useRelativeTime,
|
|
17
|
+
useUnit
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/index.ts"],"sourcesContent":["export { useCompact } from './useCompact';\nexport { useCurrency } from './useCurrency';\nexport { useDate } from './useDate';\nexport { useList } from './useList';\nexport { useNumber } from './useNumber';\nexport { usePercentage } from './usePercentage';\nexport { useRelativeTime } from './useRelativeTime';\nexport { useUnit } from './useUnit';\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,SAAS,eAAe;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { compact } from "@intlayer/core";
|
|
3
|
+
import { useCallback, useContext } from "preact/hooks";
|
|
4
|
+
import { IntlayerClientContext } from "../IntlayerProvider.mjs";
|
|
5
|
+
const useCompact = () => {
|
|
6
|
+
const { locale } = useContext(IntlayerClientContext);
|
|
7
|
+
return useCallback(
|
|
8
|
+
(...args) => compact(args[0], {
|
|
9
|
+
...args[1],
|
|
10
|
+
locale: args[1]?.locale ?? locale
|
|
11
|
+
}),
|
|
12
|
+
[locale]
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
useCompact
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useCompact.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["'use client';\n\nimport { compact } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";AAEA,SAAS,eAAe;AACxB,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AAY/B,MAAM,aAAa,MAAM;AAC9B,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,QAAQ,KAAK,CAAC,GAAG;AAAA,MACf,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { currency } from "@intlayer/core";
|
|
3
|
+
import { useCallback, useContext } from "preact/hooks";
|
|
4
|
+
import { IntlayerClientContext } from "../IntlayerProvider.mjs";
|
|
5
|
+
const useCurrency = () => {
|
|
6
|
+
const { locale } = useContext(IntlayerClientContext);
|
|
7
|
+
return useCallback(
|
|
8
|
+
(...args) => currency(args[0], {
|
|
9
|
+
...args[1],
|
|
10
|
+
locale: args[1]?.locale ?? locale
|
|
11
|
+
}),
|
|
12
|
+
[locale]
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
useCurrency
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useCurrency.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["'use client';\n\nimport { currency } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AA0B/B,MAAM,cAAc,MAAM;AAC/B,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,SAAS,KAAK,CAAC,GAAG;AAAA,MAChB,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { date } from "@intlayer/core";
|
|
3
|
+
import { useContext } from "preact/hooks";
|
|
4
|
+
import { IntlayerClientContext } from "../IntlayerProvider.mjs";
|
|
5
|
+
const useDate = () => {
|
|
6
|
+
const { locale } = useContext(IntlayerClientContext);
|
|
7
|
+
return (...args) => date(args[0], {
|
|
8
|
+
...args[1],
|
|
9
|
+
locale: args[1]?.locale ?? locale
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
useDate
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useDate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date } from '@intlayer/core';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";AAEA,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AA4B/B,MAAM,UAAU,MAAM;AAC3B,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO,IAAI,SACT,KAAK,KAAK,CAAC,GAAG;AAAA,IACZ,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { list } from "@intlayer/core";
|
|
3
|
+
import { useCallback, useContext } from "preact/hooks";
|
|
4
|
+
import { IntlayerClientContext } from "../IntlayerProvider.mjs";
|
|
5
|
+
const useList = () => {
|
|
6
|
+
const { locale } = useContext(IntlayerClientContext);
|
|
7
|
+
return useCallback(
|
|
8
|
+
(...args) => list(args[0], {
|
|
9
|
+
...args[1],
|
|
10
|
+
locale: args[1]?.locale ?? locale
|
|
11
|
+
}),
|
|
12
|
+
[locale]
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
useList
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useList.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["'use client';\n\nimport { list } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";AAEA,SAAS,YAAY;AACrB,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AAuB/B,MAAM,UAAU,MAAM;AAC3B,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,KAAK,KAAK,CAAC,GAAG;AAAA,MACZ,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { number } from "@intlayer/core";
|
|
3
|
+
import { useCallback, useContext } from "preact/hooks";
|
|
4
|
+
import { IntlayerClientContext } from "../IntlayerProvider.mjs";
|
|
5
|
+
const useNumber = () => {
|
|
6
|
+
const { locale } = useContext(IntlayerClientContext);
|
|
7
|
+
return useCallback(
|
|
8
|
+
(...args) => number(args[0], {
|
|
9
|
+
...args[1],
|
|
10
|
+
locale: args[1]?.locale ?? locale
|
|
11
|
+
}),
|
|
12
|
+
[locale]
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
useNumber
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useNumber.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useNumber.ts"],"sourcesContent":["'use client';\n\nimport { number } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";AAEA,SAAS,cAAc;AACvB,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AAwB/B,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,OAAO,KAAK,CAAC,GAAG;AAAA,MACd,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { percentage } from "@intlayer/core";
|
|
3
|
+
import { useCallback, useContext } from "preact/hooks";
|
|
4
|
+
import { IntlayerClientContext } from "../IntlayerProvider.mjs";
|
|
5
|
+
const usePercentage = () => {
|
|
6
|
+
const { locale } = useContext(IntlayerClientContext);
|
|
7
|
+
return useCallback(
|
|
8
|
+
(...args) => percentage(args[0], {
|
|
9
|
+
...args[1],
|
|
10
|
+
locale: args[1]?.locale ?? locale
|
|
11
|
+
}),
|
|
12
|
+
[locale]
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
usePercentage
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=usePercentage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/usePercentage.ts"],"sourcesContent":["'use client';\n\nimport { percentage } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";AAEA,SAAS,kBAAkB;AAC3B,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AAoB/B,MAAM,gBAAgB,MAAM;AACjC,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,WAAW,KAAK,CAAC,GAAG;AAAA,MAClB,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { relativeTime } from "@intlayer/core";
|
|
3
|
+
import { useCallback, useContext } from "preact/hooks";
|
|
4
|
+
import { IntlayerClientContext } from "../IntlayerProvider.mjs";
|
|
5
|
+
const useRelativeTime = () => {
|
|
6
|
+
const { locale } = useContext(IntlayerClientContext);
|
|
7
|
+
return useCallback(
|
|
8
|
+
(...args) => relativeTime(args[0], args[1], {
|
|
9
|
+
...args[2],
|
|
10
|
+
locale: args[2]?.locale ?? locale
|
|
11
|
+
}),
|
|
12
|
+
[locale]
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
useRelativeTime
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useRelativeTime.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useRelativeTime.ts"],"sourcesContent":["'use client';\n\nimport { relativeTime } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";AAEA,SAAS,oBAAoB;AAC7B,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AAoB/B,MAAM,kBAAkB,MAAM;AACnC,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,aAAa,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG;AAAA,MAC7B,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { units } from "@intlayer/core";
|
|
3
|
+
import { useCallback, useContext } from "preact/hooks";
|
|
4
|
+
import { IntlayerClientContext } from "../IntlayerProvider.mjs";
|
|
5
|
+
const useUnit = () => {
|
|
6
|
+
const { locale } = useContext(IntlayerClientContext);
|
|
7
|
+
return useCallback(
|
|
8
|
+
(...args) => units(args[0], {
|
|
9
|
+
...args[1],
|
|
10
|
+
locale: args[1]?.locale ?? locale
|
|
11
|
+
}),
|
|
12
|
+
[locale]
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
useUnit
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useUnit.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/client/format/useUnit.ts"],"sourcesContent":["'use client';\n\nimport { units } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";AAEA,SAAS,aAAa;AACtB,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AAmB/B,MAAM,UAAU,MAAM;AAC3B,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,MAAM,KAAK,CAAC,GAAG;AAAA,MACb,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { useCompact } from './useCompact';
|
|
2
|
+
export { useCurrency } from './useCurrency';
|
|
3
|
+
export { useDate } from './useDate';
|
|
4
|
+
export { useList } from './useList';
|
|
5
|
+
export { useNumber } from './useNumber';
|
|
6
|
+
export { usePercentage } from './usePercentage';
|
|
7
|
+
export { useRelativeTime } from './useRelativeTime';
|
|
8
|
+
export { useUnit } from './useUnit';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/format/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React client hook that provides a compact number formatter
|
|
3
|
+
* bound to the current application locale.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const formatCompact = useCompact();
|
|
8
|
+
* formatCompact(1500); // "1.5K"
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare const useCompact: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
12
|
+
locale?: import("intlayer").LocalesValues;
|
|
13
|
+
}) => string;
|
|
14
|
+
//# sourceMappingURL=useCompact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCompact.d.ts","sourceRoot":"","sources":["../../../../src/client/format/useCompact.ts"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU;;YAWtB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React client hook that provides a currency formatter
|
|
3
|
+
* bound to the current application locale.
|
|
4
|
+
*
|
|
5
|
+
* @returns {(value: string | number, options?: CurrencyProps) => string}
|
|
6
|
+
* A function to format numbers into localized currency strings.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const formatCurrency = useCurrency();
|
|
11
|
+
*
|
|
12
|
+
* formatCurrency(1500, { currency: "USD" });
|
|
13
|
+
* // "$1,500.00"
|
|
14
|
+
*
|
|
15
|
+
* formatCurrency(1500, { currency: "EUR", locale: "de-DE" });
|
|
16
|
+
* // "1.500,00 €"
|
|
17
|
+
*
|
|
18
|
+
* formatCurrency(9876543.21, {
|
|
19
|
+
* currency: "JPY",
|
|
20
|
+
* fractionDigits: 0,
|
|
21
|
+
* });
|
|
22
|
+
* // "¥9,876,543"
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const useCurrency: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
26
|
+
locale?: import("intlayer").LocalesValues;
|
|
27
|
+
}) => string;
|
|
28
|
+
//# sourceMappingURL=useCurrency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCurrency.d.ts","sourceRoot":"","sources":["../../../../src/client/format/useCurrency.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,WAAW;;YAWvB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { date } from '@intlayer/core';
|
|
2
|
+
/**
|
|
3
|
+
* React client hook that provides a localized date/time formatter
|
|
4
|
+
* bound to the current application locale.
|
|
5
|
+
*
|
|
6
|
+
* @returns {(date: Date | string | number, options?: DateProps) => string}
|
|
7
|
+
* A function to format dates or timestamps into localized date/time strings.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const formatDate = useDate();
|
|
12
|
+
*
|
|
13
|
+
* formatDate(new Date("2025-01-01"));
|
|
14
|
+
* // "Jan 1, 2025"
|
|
15
|
+
*
|
|
16
|
+
* formatDate("2025-01-01T15:30:00Z", {
|
|
17
|
+
* dateStyle: "full",
|
|
18
|
+
* timeStyle: "short",
|
|
19
|
+
* });
|
|
20
|
+
* // "Wednesday, January 1, 2025 at 3:30 PM"
|
|
21
|
+
*
|
|
22
|
+
* formatDate(1735689600000, { locale: "fr-FR", dateStyle: "long" });
|
|
23
|
+
* // "1 janvier 2025"
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @see createDate
|
|
27
|
+
*/
|
|
28
|
+
export declare const useDate: () => (...args: Parameters<typeof date>) => string;
|
|
29
|
+
//# sourceMappingURL=useDate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDate.d.ts","sourceRoot":"","sources":["../../../../src/client/format/useDate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAItC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,OAAO,SAGV,GAAG,MAAM,UAAU,CAAC,OAAO,IAAI,CAAC,WAKzC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React client hook that provides a list formatter
|
|
3
|
+
* bound to the current application locale.
|
|
4
|
+
*
|
|
5
|
+
* @returns {(values: (string | number)[], options?: ListProps) => string}
|
|
6
|
+
* A function to format arrays into localized list strings.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const formatList = useList();
|
|
11
|
+
*
|
|
12
|
+
* formatList(['apple', 'banana', 'orange']);
|
|
13
|
+
* // "apple, banana, and orange"
|
|
14
|
+
*
|
|
15
|
+
* formatList(['red', 'green', 'blue'], { type: 'disjunction' });
|
|
16
|
+
* // "red, green, or blue"
|
|
17
|
+
*
|
|
18
|
+
* formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });
|
|
19
|
+
* // "1, 2 und 3"
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const useList: () => (values: (string | number)[], options?: Intl.ListFormatOptions & {
|
|
23
|
+
locale?: import("intlayer").LocalesValues;
|
|
24
|
+
}) => string;
|
|
25
|
+
//# sourceMappingURL=useList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useList.d.ts","sourceRoot":"","sources":["../../../../src/client/format/useList.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,OAAO;;YAWnB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React client hook that provides a localized number formatter.
|
|
3
|
+
*
|
|
4
|
+
* Uses the current locale from {@link useLocaleBase} and returns
|
|
5
|
+
* a function that can be used to format numbers consistently
|
|
6
|
+
* according to the user's locale.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const formatNumber = useNumber();
|
|
11
|
+
*
|
|
12
|
+
* formatNumber(12345);
|
|
13
|
+
* // e.g. "12,345" (en-US)
|
|
14
|
+
* // e.g. "12 345" (fr-FR)
|
|
15
|
+
*
|
|
16
|
+
* formatNumber(0.75, { style: "percent" });
|
|
17
|
+
* // e.g. "75%"
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @returns {(value: string | number, options?: import("../createNumber").NumberProps) => string}
|
|
21
|
+
* A number formatting function bound to the active locale.
|
|
22
|
+
*/
|
|
23
|
+
export declare const useNumber: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
24
|
+
locale?: import("intlayer").LocalesValues;
|
|
25
|
+
}) => string;
|
|
26
|
+
//# sourceMappingURL=useNumber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNumber.d.ts","sourceRoot":"","sources":["../../../../src/client/format/useNumber.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,SAAS;;YAWrB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React hook to provide a percentage formatter function
|
|
3
|
+
* based on the current application locale.
|
|
4
|
+
*
|
|
5
|
+
* This hook retrieves the active locale using {@link useLocaleBase}
|
|
6
|
+
* and memoizes a `createPercentage` instance for that locale.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const formatPercentage = usePercentage();
|
|
11
|
+
*
|
|
12
|
+
* const result = formatPercentage(0.875, { maximumFractionDigits: 1 });
|
|
13
|
+
* // "87.5%" (depending on locale)
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @returns {(value: string | number, options?: Omit<PercentageOptions, "value">) => string}
|
|
17
|
+
* A function that formats numbers or numeric strings into localized percentages.
|
|
18
|
+
*/
|
|
19
|
+
export declare const usePercentage: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
20
|
+
locale?: import("intlayer").LocalesValues;
|
|
21
|
+
}) => string;
|
|
22
|
+
//# sourceMappingURL=usePercentage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePercentage.d.ts","sourceRoot":"","sources":["../../../../src/client/format/usePercentage.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa;;YAWzB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side React hook for accessing a localized relative time formatter.
|
|
3
|
+
*
|
|
4
|
+
* This hook:
|
|
5
|
+
* - Reads the current locale from {@link useLocaleBase}.
|
|
6
|
+
* - Creates a new relative time formatter with {@link createRelativeTime}.
|
|
7
|
+
* - Returns a function that can format time differences into localized strings.
|
|
8
|
+
*
|
|
9
|
+
* Example:
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const relativeTime = useRelativeTime();
|
|
12
|
+
* const formatted = relativeTime(new Date("2024-08-01"), new Date());
|
|
13
|
+
* // e.g., "2 weeks ago"
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function
|
|
17
|
+
* bound to the current client locale.
|
|
18
|
+
*/
|
|
19
|
+
export declare const useRelativeTime: () => (from: string | number | Date, to?: string | number | Date, options?: Intl.RelativeTimeFormatOptions & {
|
|
20
|
+
locale?: import("intlayer").LocalesValues;
|
|
21
|
+
unit?: Intl.RelativeTimeFormatUnit;
|
|
22
|
+
}) => string;
|
|
23
|
+
//# sourceMappingURL=useRelativeTime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRelativeTime.d.ts","sourceRoot":"","sources":["../../../../src/client/format/useRelativeTime.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe;;;YAW3B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React hook that provides a unit formatting function
|
|
3
|
+
* based on the current locale from {@link useLocaleBase}.
|
|
4
|
+
*
|
|
5
|
+
* This hook wraps {@link createUnit} to return a formatter
|
|
6
|
+
* that can convert values into human-readable localized units
|
|
7
|
+
* (e.g., "10 km", "5 lbs").
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const formatUnit = useUnit();
|
|
12
|
+
* const distance = formatUnit(10, { unit: "kilometer" });
|
|
13
|
+
* // "10 km" (depending on locale)
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @returns {Function} A unit formatting function that accepts a value and optional formatting options.
|
|
17
|
+
*/
|
|
18
|
+
export declare const useUnit: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
19
|
+
locale?: import("intlayer").LocalesValues;
|
|
20
|
+
}) => string;
|
|
21
|
+
//# sourceMappingURL=useUnit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUnit.d.ts","sourceRoot":"","sources":["../../../../src/client/format/useUnit.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,OAAO;;YAWnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "preact-intlayer",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Preact applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
"require": "./dist/cjs/index.cjs",
|
|
40
40
|
"import": "./dist/esm/index.mjs"
|
|
41
41
|
},
|
|
42
|
+
"./format": {
|
|
43
|
+
"types": "./dist/types/client/format/index.d.ts",
|
|
44
|
+
"require": "./dist/cjs/client/format/index.cjs",
|
|
45
|
+
"import": "./dist/esm/client/format/index.mjs"
|
|
46
|
+
},
|
|
42
47
|
"./package.json": "./package.json"
|
|
43
48
|
},
|
|
44
49
|
"main": "dist/cjs/index.cjs",
|
|
@@ -58,11 +63,11 @@
|
|
|
58
63
|
"dependencies": {
|
|
59
64
|
"js-cookie": "^3.0.5",
|
|
60
65
|
"uuid": "^11.1.0",
|
|
61
|
-
"@intlayer/
|
|
62
|
-
"@intlayer/core": "5.8.
|
|
63
|
-
"@intlayer/
|
|
64
|
-
"@intlayer/
|
|
65
|
-
"@intlayer/editor": "5.8.
|
|
66
|
+
"@intlayer/api": "5.8.1",
|
|
67
|
+
"@intlayer/core": "5.8.1",
|
|
68
|
+
"@intlayer/config": "5.8.1",
|
|
69
|
+
"@intlayer/chokidar": "5.8.1",
|
|
70
|
+
"@intlayer/editor": "5.8.1"
|
|
66
71
|
},
|
|
67
72
|
"devDependencies": {
|
|
68
73
|
"@types/node": "^24.2.1",
|
|
@@ -76,18 +81,18 @@
|
|
|
76
81
|
"tsup": "^8.5.0",
|
|
77
82
|
"typescript": "^5.9.2",
|
|
78
83
|
"vitest": "^3.2.2",
|
|
79
|
-
"@utils/eslint-config": "1.0.4",
|
|
80
84
|
"@utils/ts-config": "1.0.4",
|
|
81
|
-
"@utils/
|
|
82
|
-
"@utils/ts-config-types": "1.0.4"
|
|
85
|
+
"@utils/eslint-config": "1.0.4",
|
|
86
|
+
"@utils/ts-config-types": "1.0.4",
|
|
87
|
+
"@utils/tsup-config": "1.0.4"
|
|
83
88
|
},
|
|
84
89
|
"peerDependencies": {
|
|
85
90
|
"preact": "^10.26.4",
|
|
86
|
-
"@intlayer/api": "5.8.
|
|
87
|
-
"@intlayer/chokidar": "5.8.
|
|
88
|
-
"@intlayer/
|
|
89
|
-
"@intlayer/core": "5.8.
|
|
90
|
-
"@intlayer/
|
|
91
|
+
"@intlayer/api": "5.8.1",
|
|
92
|
+
"@intlayer/chokidar": "5.8.1",
|
|
93
|
+
"@intlayer/config": "5.8.1",
|
|
94
|
+
"@intlayer/core": "5.8.1",
|
|
95
|
+
"@intlayer/editor": "5.8.1"
|
|
91
96
|
},
|
|
92
97
|
"engines": {
|
|
93
98
|
"node": ">=14.18"
|