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,14 @@
|
|
|
1
|
+
import { compact } from "@intlayer/core";
|
|
2
|
+
import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
|
|
3
|
+
import { getServerContext } from "../serverContext.mjs";
|
|
4
|
+
const useCompact = () => {
|
|
5
|
+
const locale = getServerContext(IntlayerServerContext);
|
|
6
|
+
return (...args) => compact(args[0], {
|
|
7
|
+
...args[1],
|
|
8
|
+
locale: args[1]?.locale ?? locale
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
useCompact
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useCompact.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/server/format/useCompact.ts"],"sourcesContent":["import { type LocalesValues } from '@intlayer/config/client';\nimport { compact } from '@intlayer/core';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"AACA,SAAS,eAAe;AACxB,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAY1B,MAAM,aAAa,MAAM;AAC9B,QAAM,SAAS,iBAAgC,qBAAqB;AAEpE,SAAO,IAAI,SACT,QAAQ,KAAK,CAAC,GAAG;AAAA,IACf,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { currency } from "@intlayer/core";
|
|
2
|
+
import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
|
|
3
|
+
import { getServerContext } from "../serverContext.mjs";
|
|
4
|
+
const useCurrency = () => {
|
|
5
|
+
const locale = getServerContext(IntlayerServerContext);
|
|
6
|
+
return (...args) => currency(args[0], {
|
|
7
|
+
...args[1],
|
|
8
|
+
locale: args[1]?.locale ?? locale
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
useCurrency
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useCurrency.mjs.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":"AACA,SAAS,gBAAgB;AACzB,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAuB1B,MAAM,cAAc,MAAM;AAC/B,QAAM,SAAS,iBAAgC,qBAAqB;AAEpE,SAAO,IAAI,SACT,SAAS,KAAK,CAAC,GAAG;AAAA,IAChB,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { date } from "@intlayer/core";
|
|
2
|
+
import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
|
|
3
|
+
import { getServerContext } from "../serverContext.mjs";
|
|
4
|
+
const useDate = () => {
|
|
5
|
+
const locale = getServerContext(IntlayerServerContext);
|
|
6
|
+
return (...args) => date(args[0], {
|
|
7
|
+
...args[1],
|
|
8
|
+
locale: args[1]?.locale ?? locale
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
useDate
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useDate.mjs.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":"AACA,SAAS,YAAY;AACrB,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AA4B1B,MAAM,UAAU,MAAM;AAC3B,QAAM,SAAS,iBAAgC,qBAAqB;AAEpE,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,14 @@
|
|
|
1
|
+
import { list } from "@intlayer/core";
|
|
2
|
+
import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
|
|
3
|
+
import { getServerContext } from "../serverContext.mjs";
|
|
4
|
+
const useList = () => {
|
|
5
|
+
const locale = getServerContext(IntlayerServerContext);
|
|
6
|
+
return (...args) => list(args[0], {
|
|
7
|
+
...args[1],
|
|
8
|
+
locale: args[1]?.locale ?? locale
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
useList
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useList.mjs.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":"AACA,SAAS,YAAY;AACrB,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAoB1B,MAAM,UAAU,MAAM;AAC3B,QAAM,SAAS,iBAAgC,qBAAqB;AAEpE,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,14 @@
|
|
|
1
|
+
import { number } from "@intlayer/core";
|
|
2
|
+
import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
|
|
3
|
+
import { getServerContext } from "../serverContext.mjs";
|
|
4
|
+
const useNumber = () => {
|
|
5
|
+
const locale = getServerContext(IntlayerServerContext);
|
|
6
|
+
return (...args) => number(args[0], {
|
|
7
|
+
...args[1],
|
|
8
|
+
locale: args[1]?.locale ?? locale
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
useNumber
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useNumber.mjs.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":"AACA,SAAS,cAAc;AACvB,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAwB1B,MAAM,YAAY,MAAM;AAC7B,QAAM,SAAS,iBAAgC,qBAAqB;AAEpE,SAAO,IAAI,SACT,OAAO,KAAK,CAAC,GAAG;AAAA,IACd,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { percentage } from "@intlayer/core";
|
|
2
|
+
import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
|
|
3
|
+
import { getServerContext } from "../serverContext.mjs";
|
|
4
|
+
const usePercentage = () => {
|
|
5
|
+
const locale = getServerContext(IntlayerServerContext);
|
|
6
|
+
return (...args) => percentage(args[0], {
|
|
7
|
+
...args[1],
|
|
8
|
+
locale: args[1]?.locale ?? locale
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
usePercentage
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=usePercentage.mjs.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":"AACA,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAoB1B,MAAM,gBAAgB,MAAM;AACjC,QAAM,SAAS,iBAAgC,qBAAqB;AAEpE,SAAO,IAAI,SACT,WAAW,KAAK,CAAC,GAAG;AAAA,IAClB,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { relativeTime } from "@intlayer/core";
|
|
2
|
+
import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
|
|
3
|
+
import { getServerContext } from "../serverContext.mjs";
|
|
4
|
+
const useRelativeTime = () => {
|
|
5
|
+
const locale = getServerContext(IntlayerServerContext);
|
|
6
|
+
return (...args) => relativeTime(args[0], args[1] ?? /* @__PURE__ */ new Date(), {
|
|
7
|
+
...args[2],
|
|
8
|
+
locale: args[2]?.locale ?? locale
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
useRelativeTime
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useRelativeTime.mjs.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":"AACA,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAoB1B,MAAM,kBAAkB,MAAM;AACnC,QAAM,SAAS,iBAAgC,qBAAqB;AAEpE,SAAO,IAAI,SACT,aAAa,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,14 @@
|
|
|
1
|
+
import { units } from "@intlayer/core";
|
|
2
|
+
import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
|
|
3
|
+
import { getServerContext } from "../serverContext.mjs";
|
|
4
|
+
const useUnit = () => {
|
|
5
|
+
const locale = getServerContext(IntlayerServerContext);
|
|
6
|
+
return (...args) => units(args[0], {
|
|
7
|
+
...args[1],
|
|
8
|
+
locale: args[1]?.locale ?? locale
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
useUnit
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useUnit.mjs.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":"AACA,SAAS,aAAa;AACtB,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAmB1B,MAAM,UAAU,MAAM;AAC3B,QAAM,SAAS,iBAAgC,qBAAqB;AAEpE,SAAO,IAAI,SACT,MAAM,KAAK,CAAC,GAAG;AAAA,IACb,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","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"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side exports for internal package use.
|
|
3
|
+
*
|
|
4
|
+
* Note: This file is used by other packages that import from 'react-intlayer/client'.
|
|
5
|
+
* The main package index.ts imports directly from individual files to avoid circular dependencies.
|
|
6
|
+
*/
|
|
1
7
|
export { getBrowserLocale } from './getBrowserLocale';
|
|
2
8
|
export { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, useIntlayerContext, type IntlayerProviderProps, } from './IntlayerProvider';
|
|
3
9
|
export { t } from './t';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,qBAAqB,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,qBAAqB,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,7 +3,18 @@ declare module '@intlayer/core' {
|
|
|
3
3
|
interface IInterpreterPlugin<T, S> extends IInterpreterPluginReact<T> {
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
export { getBrowserLocale
|
|
6
|
+
export { getBrowserLocale } from './client/getBrowserLocale';
|
|
7
|
+
export { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, useIntlayerContext, type IntlayerProviderProps, } from './client/IntlayerProvider';
|
|
8
|
+
export { t } from './client/t';
|
|
9
|
+
export { useDictionary } from './client/useDictionary';
|
|
10
|
+
export { useDictionaryAsync } from './client/useDictionaryAsync';
|
|
11
|
+
export { useDictionaryDynamic } from './client/useDictionaryDynamic';
|
|
12
|
+
export { useI18n } from './client/useI18n';
|
|
13
|
+
export { useIntlayer } from './client/useIntlayer';
|
|
14
|
+
export { useLoadDynamic } from './client/useLoadDynamic';
|
|
15
|
+
export { useLocale } from './client/useLocale';
|
|
16
|
+
export { useLocaleBase } from './client/useLocaleBase';
|
|
17
|
+
export { localeCookie, setLocaleCookie, useLocaleCookie, } from './client/useLocaleCookie';
|
|
7
18
|
export { type IntlayerNode } from './IntlayerNode';
|
|
8
19
|
export { MarkdownProvider } from './markdown/index';
|
|
9
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,uBAAuB,CAAC,CAAC,CAAC;KAAG;CACzE;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,uBAAuB,CAAC,CAAC,CAAC;KAAG;CACzE;AAGD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,qBAAqB,GAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -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/server/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,13 @@
|
|
|
1
|
+
import { compact } from '@intlayer/core';
|
|
2
|
+
/**
|
|
3
|
+
* React client hook that provides a compact number formatter
|
|
4
|
+
* bound to the current application locale.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* const formatCompact = useCompact();
|
|
9
|
+
* formatCompact(1500); // "1.5K"
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare const useCompact: () => (...args: Parameters<typeof compact>) => string;
|
|
13
|
+
//# sourceMappingURL=useCompact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCompact.d.ts","sourceRoot":"","sources":["../../../../src/server/format/useCompact.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAIzC;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,SAGb,GAAG,MAAM,UAAU,CAAC,OAAO,OAAO,CAAC,WAK5C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { currency } from '@intlayer/core';
|
|
2
|
+
/**
|
|
3
|
+
* React client hook that provides a currency formatter
|
|
4
|
+
* bound to the current application locale.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* const formatCurrency = useCurrency();
|
|
9
|
+
*
|
|
10
|
+
* formatCurrency(1500, { currency: "USD" });
|
|
11
|
+
* // "$1,500.00"
|
|
12
|
+
*
|
|
13
|
+
* formatCurrency(1500, { currency: "EUR", locale: "de-DE" });
|
|
14
|
+
* // "1.500,00 €"
|
|
15
|
+
*
|
|
16
|
+
* formatCurrency(9876543.21, {
|
|
17
|
+
* currency: "JPY",
|
|
18
|
+
* fractionDigits: 0,
|
|
19
|
+
* });
|
|
20
|
+
* // "¥9,876,543"
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const useCurrency: () => (...args: Parameters<typeof currency>) => string;
|
|
24
|
+
//# sourceMappingURL=useCurrency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCurrency.d.ts","sourceRoot":"","sources":["../../../../src/server/format/useCurrency.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,WAAW,SAGd,GAAG,MAAM,UAAU,CAAC,OAAO,QAAQ,CAAC,WAK7C,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/server/format/useDate.ts"],"names":[],"mappings":"AACA,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,21 @@
|
|
|
1
|
+
import { list } from '@intlayer/core';
|
|
2
|
+
/**
|
|
3
|
+
* React server hook that provides a list formatter
|
|
4
|
+
* bound to the current application locale.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* const formatList = useList();
|
|
9
|
+
*
|
|
10
|
+
* formatList(['apple', 'banana', 'orange']);
|
|
11
|
+
* // "apple, banana, and orange"
|
|
12
|
+
*
|
|
13
|
+
* formatList(['red', 'green', 'blue'], { type: 'disjunction' });
|
|
14
|
+
* // "red, green, or blue"
|
|
15
|
+
*
|
|
16
|
+
* formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });
|
|
17
|
+
* // "1, 2 und 3"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const useList: () => (...args: Parameters<typeof list>) => string;
|
|
21
|
+
//# sourceMappingURL=useList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useList.d.ts","sourceRoot":"","sources":["../../../../src/server/format/useList.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAItC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,OAAO,SAGV,GAAG,MAAM,UAAU,CAAC,OAAO,IAAI,CAAC,WAKzC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { number } from '@intlayer/core';
|
|
2
|
+
/**
|
|
3
|
+
* React client hook that provides a localized number formatter.
|
|
4
|
+
*
|
|
5
|
+
* Uses the current locale from {@link useLocaleBase} and returns
|
|
6
|
+
* a function that can be used to format numbers consistently
|
|
7
|
+
* according to the user's locale.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const formatNumber = useNumber();
|
|
12
|
+
*
|
|
13
|
+
* formatNumber(12345);
|
|
14
|
+
* // e.g. "12,345" (en-US)
|
|
15
|
+
* // e.g. "12 345" (fr-FR)
|
|
16
|
+
*
|
|
17
|
+
* formatNumber(0.75, { style: "percent" });
|
|
18
|
+
* // e.g. "75%"
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @returns {(value: string | number, options?: import("../createNumber").NumberProps) => string}
|
|
22
|
+
* A number formatting function bound to the active locale.
|
|
23
|
+
*/
|
|
24
|
+
export declare const useNumber: () => (...args: Parameters<typeof number>) => string;
|
|
25
|
+
//# sourceMappingURL=useNumber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNumber.d.ts","sourceRoot":"","sources":["../../../../src/server/format/useNumber.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIxC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,SAAS,SAGZ,GAAG,MAAM,UAAU,CAAC,OAAO,MAAM,CAAC,WAK3C,CAAC"}
|