react-intlayer 9.7.3 → 9.8.0-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,7 +34,7 @@ let _intlayer_core_formatters = require("@intlayer/core/formatters");
34
34
  */
35
35
  const useDate = () => {
36
36
  const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
37
- return (...args) => {
37
+ return (0, react.useCallback)((...args) => {
38
38
  const options = typeof args[1] === "string" ? {
39
39
  ..._intlayer_core_formatters.presets[args[1]],
40
40
  locale
@@ -43,7 +43,7 @@ const useDate = () => {
43
43
  locale: args[1]?.locale ?? locale
44
44
  };
45
45
  return (0, _intlayer_core_formatters.date)(args[0], options);
46
- };
46
+ }, [locale]);
47
47
  };
48
48
 
49
49
  exports.useDate = useDate;
@@ -1 +1 @@
1
- {"version":3,"file":"useDate.cjs","names":["useContext","IntlayerClientContext","presets","date"],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date, presets } from '@intlayer/core/formatters';\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 const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale: locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,eAAWA,kBAAWC,qDAAqB,KAAK,CAAC;CAEzD,QAAQ,GAAG,SAAkC;EAC3C,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAGC,kCAAQ,KAAK;GAAa;EAAO,IACtC;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,EAAE,EAAE,UAAU;EAAO;EAEtD,WAAOC,gCAAK,KAAK,IAAI,OAAqC;CAC5D;AACF"}
1
+ {"version":3,"file":"useDate.cjs","names":["useContext","IntlayerClientContext","useCallback","presets","date"],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date, presets } from '@intlayer/core/formatters';\nimport { useCallback, 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 useCallback(\n (...args: Parameters<typeof date>) => {\n const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n },\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,eAAWA,kBAAWC,qDAAqB,KAAK,CAAC;CAEzD,WAAOC,oBACJ,GAAG,SAAkC;EACpC,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAGC,kCAAQ,KAAK;GAAK;EAAO,IAC9B;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,EAAE,EAAE,UAAU;EAAO;EAEtD,WAAOC,gCAAK,KAAK,IAAI,OAAqC;CAC5D,GACA,CAAC,MAAM,CACT;AACF"}
@@ -32,10 +32,16 @@ let _intlayer_core_formatters = require("@intlayer/core/formatters");
32
32
  */
33
33
  const useDate = () => {
34
34
  const locale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext);
35
- return (...args) => (0, _intlayer_core_formatters.date)(args[0], {
36
- ...args[1],
37
- locale: args[1]?.locale ?? locale
38
- });
35
+ return (...args) => {
36
+ const options = typeof args[1] === "string" ? {
37
+ ..._intlayer_core_formatters.presets[args[1]],
38
+ locale
39
+ } : {
40
+ ...args[1],
41
+ locale: args[1]?.locale ?? locale
42
+ };
43
+ return (0, _intlayer_core_formatters.date)(args[0], options);
44
+ };
39
45
  };
40
46
 
41
47
  exports.useDate = useDate;
@@ -1 +1 @@
1
- {"version":3,"file":"useDate.cjs","names":["getServerContext","IntlayerServerContext","date"],"sources":["../../../../src/server/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,gBAAgB;CAC3B,MAAM,SAASA,8CAAgCC,2DAAqB;CAEpE,QAAQ,GAAG,aACTC,gCAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
1
+ {"version":3,"file":"useDate.cjs","names":["getServerContext","IntlayerServerContext","presets","date"],"sources":["../../../../src/server/format/useDate.ts"],"sourcesContent":["import { date, presets } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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 const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,gBAAgB;CAC3B,MAAM,SAASA,8CAAgCC,2DAAqB;CAEpE,QAAQ,GAAG,SAAkC;EAC3C,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAGC,kCAAQ,KAAK;GAAK;EAAO,IAC9B;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,EAAE,EAAE,UAAU;EAAO;EAEtD,WAAOC,gCAAK,KAAK,IAAI,OAAqC;CAC5D;AACF"}
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { IntlayerClientContext } from "../IntlayerProvider.mjs";
4
- import { useContext } from "react";
4
+ import { useCallback, useContext } from "react";
5
5
  import { date, presets } from "@intlayer/core/formatters";
6
6
 
7
7
  // src/client/format/useDate.ts
@@ -33,7 +33,7 @@ import { date, presets } from "@intlayer/core/formatters";
33
33
  */
34
34
  const useDate = () => {
35
35
  const { locale } = useContext(IntlayerClientContext) ?? {};
36
- return (...args) => {
36
+ return useCallback((...args) => {
37
37
  const options = typeof args[1] === "string" ? {
38
38
  ...presets[args[1]],
39
39
  locale
@@ -42,7 +42,7 @@ const useDate = () => {
42
42
  locale: args[1]?.locale ?? locale
43
43
  };
44
44
  return date(args[0], options);
45
- };
45
+ }, [locale]);
46
46
  };
47
47
 
48
48
  export { useDate };
@@ -1 +1 @@
1
- {"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date, presets } from '@intlayer/core/formatters';\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 const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale: locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,QAAQ,GAAG,SAAkC;EAC3C,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAG,QAAQ,KAAK;GAAa;EAAO,IACtC;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,EAAE,EAAE,UAAU;EAAO;EAEtD,OAAO,KAAK,KAAK,IAAI,OAAqC;CAC5D;AACF"}
1
+ {"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date, presets } from '@intlayer/core/formatters';\nimport { useCallback, 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 useCallback(\n (...args: Parameters<typeof date>) => {\n const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n },\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,aACJ,GAAG,SAAkC;EACpC,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAG,QAAQ,KAAK;GAAK;EAAO,IAC9B;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,EAAE,EAAE,UAAU;EAAO;EAEtD,OAAO,KAAK,KAAK,IAAI,OAAqC;CAC5D,GACA,CAAC,MAAM,CACT;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
2
2
  import { getServerContext } from "../serverContext.mjs";
3
- import { date } from "@intlayer/core/formatters";
3
+ import { date, presets } from "@intlayer/core/formatters";
4
4
 
5
5
  // src/server/format/useDate.ts
6
6
  /**
@@ -31,10 +31,16 @@ import { date } from "@intlayer/core/formatters";
31
31
  */
32
32
  const useDate = () => {
33
33
  const locale = getServerContext(IntlayerServerContext);
34
- return (...args) => date(args[0], {
35
- ...args[1],
36
- locale: args[1]?.locale ?? locale
37
- });
34
+ return (...args) => {
35
+ const options = typeof args[1] === "string" ? {
36
+ ...presets[args[1]],
37
+ locale
38
+ } : {
39
+ ...args[1],
40
+ locale: args[1]?.locale ?? locale
41
+ };
42
+ return date(args[0], options);
43
+ };
38
44
  };
39
45
 
40
46
  export { useDate };
@@ -1 +1 @@
1
- {"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/server/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,gBAAgB;CAC3B,MAAM,SAAS,iBAAgC,qBAAqB;CAEpE,QAAQ,GAAG,SACT,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
1
+ {"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/server/format/useDate.ts"],"sourcesContent":["import { date, presets } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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 const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,gBAAgB;CAC3B,MAAM,SAAS,iBAAgC,qBAAqB;CAEpE,QAAQ,GAAG,SAAkC;EAC3C,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAG,QAAQ,KAAK;GAAK;EAAO,IAC9B;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,EAAE,EAAE,UAAU;EAAO;EAEtD,OAAO,KAAK,KAAK,IAAI,OAAqC;CAC5D;AACF"}
@@ -1,4 +1,3 @@
1
- import { date } from "@intlayer/core/formatters";
2
1
  /**
3
2
  * React client hook that provides a localized date/time formatter
4
3
  * bound to the current application locale.
@@ -25,5 +24,7 @@ import { date } from "@intlayer/core/formatters";
25
24
  *
26
25
  * @see createDate
27
26
  */
28
- export declare const useDate: () => (...args: Parameters<typeof date>) => string;
27
+ export declare const useDate: () => (date: string | number | Date, options?: import("@intlayer/core/formatters").DateTimePreset | (Intl.DateTimeFormatOptions & {
28
+ locale?: import("@intlayer/types").LocalesValues;
29
+ })) => string;
29
30
  //# sourceMappingURL=useDate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../../src/client/format/useDate.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgCa,mBAAO,MAGD,kBAAkB"}
1
+ {"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../../src/client/format/useDate.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;qBAgCa,gBAAO,wBAAA,MAAA,8CAAA,kBAAA,KAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "9.7.3",
3
+ "version": "9.8.0-canary.1",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -133,12 +133,12 @@
133
133
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
134
134
  },
135
135
  "dependencies": {
136
- "@intlayer/api": "9.7.3",
137
- "@intlayer/config": "9.7.3",
138
- "@intlayer/core": "9.7.3",
139
- "@intlayer/dictionaries-entry": "9.7.3",
140
- "@intlayer/editor": "9.7.3",
141
- "@intlayer/types": "9.7.3"
136
+ "@intlayer/api": "9.8.0-canary.1",
137
+ "@intlayer/config": "9.8.0-canary.1",
138
+ "@intlayer/core": "9.8.0-canary.1",
139
+ "@intlayer/dictionaries-entry": "9.8.0-canary.1",
140
+ "@intlayer/editor": "9.8.0-canary.1",
141
+ "@intlayer/types": "9.8.0-canary.1"
142
142
  },
143
143
  "devDependencies": {
144
144
  "@craco/types": "7.1.0",
@@ -159,7 +159,7 @@
159
159
  "react-dom": ">=16.0.0"
160
160
  },
161
161
  "optionalDependencies": {
162
- "@intlayer/analytics": "9.7.3"
162
+ "@intlayer/analytics": "9.8.0-canary.1"
163
163
  },
164
164
  "engines": {
165
165
  "node": ">=14.18"