react-intlayer 5.7.8 → 5.8.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- 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/cjs/client/index.cjs.map +1 -1
- package/dist/cjs/index.cjs +29 -18
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/server/format/index.cjs +50 -0
- package/dist/cjs/server/format/index.cjs.map +1 -0
- package/dist/cjs/server/format/useCompact.cjs +38 -0
- package/dist/cjs/server/format/useCompact.cjs.map +1 -0
- package/dist/cjs/server/format/useCurrency.cjs +38 -0
- package/dist/cjs/server/format/useCurrency.cjs.map +1 -0
- package/dist/cjs/server/format/useDate.cjs +38 -0
- package/dist/cjs/server/format/useDate.cjs.map +1 -0
- package/dist/cjs/server/format/useList.cjs +38 -0
- package/dist/cjs/server/format/useList.cjs.map +1 -0
- package/dist/cjs/server/format/useNumber.cjs +38 -0
- package/dist/cjs/server/format/useNumber.cjs.map +1 -0
- package/dist/cjs/server/format/usePercentage.cjs +38 -0
- package/dist/cjs/server/format/usePercentage.cjs.map +1 -0
- package/dist/cjs/server/format/useRelativeTime.cjs +38 -0
- package/dist/cjs/server/format/useRelativeTime.cjs.map +1 -0
- package/dist/cjs/server/format/useUnit.cjs +38 -0
- package/dist/cjs/server/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/esm/client/index.mjs.map +1 -1
- package/dist/esm/index.mjs +14 -12
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/server/format/index.mjs +19 -0
- package/dist/esm/server/format/index.mjs.map +1 -0
- package/dist/esm/server/format/useCompact.mjs +14 -0
- package/dist/esm/server/format/useCompact.mjs.map +1 -0
- package/dist/esm/server/format/useCurrency.mjs +14 -0
- package/dist/esm/server/format/useCurrency.mjs.map +1 -0
- package/dist/esm/server/format/useDate.mjs +14 -0
- package/dist/esm/server/format/useDate.mjs.map +1 -0
- package/dist/esm/server/format/useList.mjs +14 -0
- package/dist/esm/server/format/useList.mjs.map +1 -0
- package/dist/esm/server/format/useNumber.mjs +14 -0
- package/dist/esm/server/format/useNumber.mjs.map +1 -0
- package/dist/esm/server/format/usePercentage.mjs +14 -0
- package/dist/esm/server/format/usePercentage.mjs.map +1 -0
- package/dist/esm/server/format/useRelativeTime.mjs +14 -0
- package/dist/esm/server/format/useRelativeTime.mjs.map +1 -0
- package/dist/esm/server/format/useUnit.mjs +14 -0
- package/dist/esm/server/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/dist/types/client/index.d.ts +6 -0
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +12 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/server/format/index.d.ts +9 -0
- package/dist/types/server/format/index.d.ts.map +1 -0
- package/dist/types/server/format/useCompact.d.ts +13 -0
- package/dist/types/server/format/useCompact.d.ts.map +1 -0
- package/dist/types/server/format/useCurrency.d.ts +24 -0
- package/dist/types/server/format/useCurrency.d.ts.map +1 -0
- package/dist/types/server/format/useDate.d.ts +29 -0
- package/dist/types/server/format/useDate.d.ts.map +1 -0
- package/dist/types/server/format/useList.d.ts +21 -0
- package/dist/types/server/format/useList.d.ts.map +1 -0
- package/dist/types/server/format/useNumber.d.ts +25 -0
- package/dist/types/server/format/useNumber.d.ts.map +1 -0
- package/dist/types/server/format/usePercentage.d.ts +21 -0
- package/dist/types/server/format/usePercentage.d.ts.map +1 -0
- package/dist/types/server/format/useRelativeTime.d.ts +21 -0
- package/dist/types/server/format/useRelativeTime.d.ts.map +1 -0
- package/dist/types/server/format/useUnit.d.ts +20 -0
- package/dist/types/server/format/useUnit.d.ts.map +1 -0
- package/package.json +27 -17
|
@@ -0,0 +1,38 @@
|
|
|
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 useCurrency_exports = {};
|
|
20
|
+
__export(useCurrency_exports, {
|
|
21
|
+
useCurrency: () => useCurrency
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useCurrency_exports);
|
|
24
|
+
var import_core = require("@intlayer/core");
|
|
25
|
+
var import_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
26
|
+
var import_serverContext = require('../serverContext.cjs');
|
|
27
|
+
const useCurrency = () => {
|
|
28
|
+
const locale = (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
29
|
+
return (...args) => (0, import_core.currency)(args[0], {
|
|
30
|
+
...args[1],
|
|
31
|
+
locale: args[1]?.locale ?? locale
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
useCurrency
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=useCurrency.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/server/format/useCurrency.ts"],"sourcesContent":["import { type LocalesValues } from '@intlayer/config/client';\nimport { currency } from '@intlayer/core';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAyB;AACzB,oCAAsC;AACtC,2BAAiC;AAuB1B,MAAM,cAAc,MAAM;AAC/B,QAAM,aAAS,uCAAgC,mDAAqB;AAEpE,SAAO,IAAI,aACT,sBAAS,KAAK,CAAC,GAAG;AAAA,IAChB,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 useDate_exports = {};
|
|
20
|
+
__export(useDate_exports, {
|
|
21
|
+
useDate: () => useDate
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useDate_exports);
|
|
24
|
+
var import_core = require("@intlayer/core");
|
|
25
|
+
var import_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
26
|
+
var import_serverContext = require('../serverContext.cjs');
|
|
27
|
+
const useDate = () => {
|
|
28
|
+
const locale = (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
29
|
+
return (...args) => (0, import_core.date)(args[0], {
|
|
30
|
+
...args[1],
|
|
31
|
+
locale: args[1]?.locale ?? locale
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
useDate
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=useDate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/server/format/useDate.ts"],"sourcesContent":["import { type LocalesValues } from '@intlayer/config/client';\nimport { date } from '@intlayer/core';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\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;AACA,kBAAqB;AACrB,oCAAsC;AACtC,2BAAiC;AA4B1B,MAAM,UAAU,MAAM;AAC3B,QAAM,aAAS,uCAAgC,mDAAqB;AAEpE,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,38 @@
|
|
|
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 useList_exports = {};
|
|
20
|
+
__export(useList_exports, {
|
|
21
|
+
useList: () => useList
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useList_exports);
|
|
24
|
+
var import_core = require("@intlayer/core");
|
|
25
|
+
var import_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
26
|
+
var import_serverContext = require('../serverContext.cjs');
|
|
27
|
+
const useList = () => {
|
|
28
|
+
const locale = (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
29
|
+
return (...args) => (0, import_core.list)(args[0], {
|
|
30
|
+
...args[1],
|
|
31
|
+
locale: args[1]?.locale ?? locale
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
useList
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=useList.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/server/format/useList.ts"],"sourcesContent":["import { type LocalesValues } from '@intlayer/config/client';\nimport { list } from '@intlayer/core';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React server hook that provides a list formatter\n * bound to the current application locale.\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAqB;AACrB,oCAAsC;AACtC,2BAAiC;AAoB1B,MAAM,UAAU,MAAM;AAC3B,QAAM,aAAS,uCAAgC,mDAAqB;AAEpE,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,38 @@
|
|
|
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 useNumber_exports = {};
|
|
20
|
+
__export(useNumber_exports, {
|
|
21
|
+
useNumber: () => useNumber
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useNumber_exports);
|
|
24
|
+
var import_core = require("@intlayer/core");
|
|
25
|
+
var import_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
26
|
+
var import_serverContext = require('../serverContext.cjs');
|
|
27
|
+
const useNumber = () => {
|
|
28
|
+
const locale = (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
29
|
+
return (...args) => (0, import_core.number)(args[0], {
|
|
30
|
+
...args[1],
|
|
31
|
+
locale: args[1]?.locale ?? locale
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
useNumber
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=useNumber.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/server/format/useNumber.ts"],"sourcesContent":["import { type LocalesValues } from '@intlayer/config/client';\nimport { number } from '@intlayer/core';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAuB;AACvB,oCAAsC;AACtC,2BAAiC;AAwB1B,MAAM,YAAY,MAAM;AAC7B,QAAM,aAAS,uCAAgC,mDAAqB;AAEpE,SAAO,IAAI,aACT,oBAAO,KAAK,CAAC,GAAG;AAAA,IACd,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 usePercentage_exports = {};
|
|
20
|
+
__export(usePercentage_exports, {
|
|
21
|
+
usePercentage: () => usePercentage
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(usePercentage_exports);
|
|
24
|
+
var import_core = require("@intlayer/core");
|
|
25
|
+
var import_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
26
|
+
var import_serverContext = require('../serverContext.cjs');
|
|
27
|
+
const usePercentage = () => {
|
|
28
|
+
const locale = (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
29
|
+
return (...args) => (0, import_core.percentage)(args[0], {
|
|
30
|
+
...args[1],
|
|
31
|
+
locale: args[1]?.locale ?? locale
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
usePercentage
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=usePercentage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/server/format/usePercentage.ts"],"sourcesContent":["import { type LocalesValues } from '@intlayer/config/client';\nimport { percentage } from '@intlayer/core';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAA2B;AAC3B,oCAAsC;AACtC,2BAAiC;AAoB1B,MAAM,gBAAgB,MAAM;AACjC,QAAM,aAAS,uCAAgC,mDAAqB;AAEpE,SAAO,IAAI,aACT,wBAAW,KAAK,CAAC,GAAG;AAAA,IAClB,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 useRelativeTime_exports = {};
|
|
20
|
+
__export(useRelativeTime_exports, {
|
|
21
|
+
useRelativeTime: () => useRelativeTime
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useRelativeTime_exports);
|
|
24
|
+
var import_core = require("@intlayer/core");
|
|
25
|
+
var import_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
26
|
+
var import_serverContext = require('../serverContext.cjs');
|
|
27
|
+
const useRelativeTime = () => {
|
|
28
|
+
const locale = (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
29
|
+
return (...args) => (0, import_core.relativeTime)(args[0], args[1] ?? /* @__PURE__ */ new Date(), {
|
|
30
|
+
...args[2],
|
|
31
|
+
locale: args[2]?.locale ?? locale
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
useRelativeTime
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=useRelativeTime.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/server/format/useRelativeTime.ts"],"sourcesContent":["import { type LocalesValues } from '@intlayer/config/client';\nimport { relativeTime } from '@intlayer/core';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1] ?? new Date(), {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAA6B;AAC7B,oCAAsC;AACtC,2BAAiC;AAoB1B,MAAM,kBAAkB,MAAM;AACnC,QAAM,aAAS,uCAAgC,mDAAqB;AAEpE,SAAO,IAAI,aACT,0BAAa,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,oBAAI,KAAK,GAAG;AAAA,IAC3C,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 useUnit_exports = {};
|
|
20
|
+
__export(useUnit_exports, {
|
|
21
|
+
useUnit: () => useUnit
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useUnit_exports);
|
|
24
|
+
var import_core = require("@intlayer/core");
|
|
25
|
+
var import_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
26
|
+
var import_serverContext = require('../serverContext.cjs');
|
|
27
|
+
const useUnit = () => {
|
|
28
|
+
const locale = (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
29
|
+
return (...args) => (0, import_core.units)(args[0], {
|
|
30
|
+
...args[1],
|
|
31
|
+
locale: args[1]?.locale ?? locale
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
useUnit
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=useUnit.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/server/format/useUnit.ts"],"sourcesContent":["import { type LocalesValues } from '@intlayer/config/client';\nimport { units } from '@intlayer/core';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAsB;AACtB,oCAAsC;AACtC,2BAAiC;AAmB1B,MAAM,UAAU,MAAM;AAC3B,QAAM,aAAS,uCAAgC,mDAAqB;AAEpE,SAAO,IAAI,aACT,mBAAM,KAAK,CAAC,GAAG;AAAA,IACb,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","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 "react";
|
|
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 'react';\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 "react";
|
|
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 'react';\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 "react";
|
|
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 'react';\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 "react";
|
|
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 'react';\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 "react";
|
|
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 'react';\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 "react";
|
|
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 'react';\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 "react";
|
|
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 'react';\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 "react";
|
|
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 'react';\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":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["/**\n * Client-side exports for internal package use.\n *\n * Note: This file is used by other packages that import from 'react-intlayer/client'.\n * The main package index.ts imports directly from individual files to avoid circular dependencies.\n */\n\nexport { getBrowserLocale } from './getBrowserLocale';\nexport {\n IntlayerClientContext,\n IntlayerProvider,\n IntlayerProviderContent,\n useIntlayerContext,\n type IntlayerProviderProps,\n} from './IntlayerProvider';\nexport { t } from './t';\nexport { useDictionary } from './useDictionary';\nexport { useDictionaryAsync } from './useDictionaryAsync';\nexport { useDictionaryDynamic } from './useDictionaryDynamic';\nexport { useI18n } from './useI18n';\nexport { useIntlayer } from './useIntlayer';\nexport { useLoadDynamic } from './useLoadDynamic';\nexport { useLocale } from './useLocale';\nexport { useLocaleBase } from './useLocaleBase';\nexport {\n localeCookie,\n setLocaleCookie,\n useLocaleCookie,\n} from './useLocaleCookie';\n"],"mappings":"AAOA,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,SAAS;AAClB,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
+
import { getBrowserLocale } from "./client/getBrowserLocale.mjs";
|
|
1
2
|
import {
|
|
2
|
-
getBrowserLocale,
|
|
3
3
|
IntlayerClientContext,
|
|
4
4
|
IntlayerProvider,
|
|
5
5
|
IntlayerProviderContent,
|
|
6
|
+
useIntlayerContext
|
|
7
|
+
} from "./client/IntlayerProvider.mjs";
|
|
8
|
+
import { t } from "./client/t.mjs";
|
|
9
|
+
import { useDictionary } from "./client/useDictionary.mjs";
|
|
10
|
+
import { useDictionaryAsync } from "./client/useDictionaryAsync.mjs";
|
|
11
|
+
import { useDictionaryDynamic } from "./client/useDictionaryDynamic.mjs";
|
|
12
|
+
import { useI18n } from "./client/useI18n.mjs";
|
|
13
|
+
import { useIntlayer } from "./client/useIntlayer.mjs";
|
|
14
|
+
import { useLoadDynamic } from "./client/useLoadDynamic.mjs";
|
|
15
|
+
import { useLocale } from "./client/useLocale.mjs";
|
|
16
|
+
import { useLocaleBase } from "./client/useLocaleBase.mjs";
|
|
17
|
+
import {
|
|
6
18
|
localeCookie,
|
|
7
19
|
setLocaleCookie,
|
|
8
|
-
t,
|
|
9
|
-
useDictionary,
|
|
10
|
-
useDictionaryAsync,
|
|
11
|
-
useDictionaryDynamic,
|
|
12
|
-
useI18n,
|
|
13
|
-
useIntlayer,
|
|
14
|
-
useIntlayerContext,
|
|
15
|
-
useLoadDynamic,
|
|
16
|
-
useLocale,
|
|
17
|
-
useLocaleBase,
|
|
18
20
|
useLocaleCookie
|
|
19
|
-
} from "./client/
|
|
21
|
+
} from "./client/useLocaleCookie.mjs";
|
|
20
22
|
import { MarkdownProvider } from "./markdown/index.mjs";
|
|
21
23
|
export {
|
|
22
24
|
IntlayerClientContext,
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import type { IInterpreterPluginReact } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginReact<T> {}\n}\n\nexport {\n
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import type { IInterpreterPluginReact } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginReact<T> {}\n}\n\n// Import directly from individual files to avoid circular dependency issues\nexport { getBrowserLocale } from './client/getBrowserLocale';\nexport {\n IntlayerClientContext,\n IntlayerProvider,\n IntlayerProviderContent,\n useIntlayerContext,\n type IntlayerProviderProps,\n} from './client/IntlayerProvider';\nexport { t } from './client/t';\nexport { useDictionary } from './client/useDictionary';\nexport { useDictionaryAsync } from './client/useDictionaryAsync';\nexport { useDictionaryDynamic } from './client/useDictionaryDynamic';\nexport { useI18n } from './client/useI18n';\nexport { useIntlayer } from './client/useIntlayer';\nexport { useLoadDynamic } from './client/useLoadDynamic';\nexport { useLocale } from './client/useLocale';\nexport { useLocaleBase } from './client/useLocaleBase';\nexport {\n localeCookie,\n setLocaleCookie,\n useLocaleCookie,\n} from './client/useLocaleCookie';\n\nexport { type IntlayerNode } from './IntlayerNode';\nexport { MarkdownProvider } from './markdown/index';\n"],"mappings":"AAOA,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,SAAS;AAClB,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,wBAAwB;","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/server/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":[]}
|