preact-intlayer 8.9.3 → 8.9.4-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.
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.cjs","names":["internationalization","IntlayerClientContext"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * Preact hook to get the current locale and related locale management functions.\n *\n * @param props - Optional properties for the hook.\n * @returns An object containing the current locale, default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocale } from 'preact-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { locale, setLocale, availableLocales } = useLocale();\n *\n * return (\n * <select value={locale} onChange={(e) => setLocale(e.target.value)}>\n * {availableLocales.map((loc) => (\n * <option key={loc} value={loc}>{loc}</option>\n * ))}\n * </select>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext) ?? {};\n\n const setLocale = (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n\n onLocaleChange?.(locale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAK;CACzB,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+CAAwB,EAAE;CAE5B,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,wDACJC,sDAAsB,IAAI,EAAE;CAE3C,MAAM,aAAa,WAA0B;EAC3C,IAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,OAAO,EAAE;GACnD,QAAQ,MAAM,UAAU,OAAO,mBAAmB;GAClD;;EAGF,eAAe,OAAO;EAEtB,mDACE,QACA,mBAAmB,0BAA0B,KAC9C;EAED,iBAAiB,OAAO;;CAG1B,OAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"useLocale.cjs","names":["internationalization","IntlayerClientContext"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\ntype UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * Preact hook to get the current locale and related locale management functions.\n *\n * @param props - Optional properties for the hook.\n * @returns An object containing the current locale, default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocale } from 'preact-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { locale, setLocale, availableLocales } = useLocale();\n *\n * return (\n * <select value={locale} onChange={(e) => setLocale(e.target.value)}>\n * {availableLocales.map((loc) => (\n * <option key={loc} value={loc}>{loc}</option>\n * ))}\n * </select>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext) ?? {};\n\n const setLocale = (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n\n onLocaleChange?.(locale as DeclaredLocales);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAsB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+CAAwB,EAAE;CAE5B,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,wDACJC,sDAAsB,IAAI,EAAE;CAE3C,MAAM,aAAa,WAA0B;EAC3C,IAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,OAAO,EAAE;GACnD,QAAQ,MAAM,UAAU,OAAO,mBAAmB;GAClD;;EAGF,eAAe,OAAO;EAEtB,mDACE,QACA,mBAAmB,0BAA0B,KAC9C;EAED,iBAAiB,OAA0B;;CAG7C,OAAO;EACL;EACA;EACA;EACA;EACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * Preact hook to get the current locale and related locale management functions.\n *\n * @param props - Optional properties for the hook.\n * @returns An object containing the current locale, default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocale } from 'preact-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { locale, setLocale, availableLocales } = useLocale();\n *\n * return (\n * <select value={locale} onChange={(e) => setLocale(e.target.value)}>\n * {availableLocales.map((loc) => (\n * <option key={loc} value={loc}>{loc}</option>\n * ))}\n * </select>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext) ?? {};\n\n const setLocale = (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n\n onLocaleChange?.(locale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAK;CACzB,MAAM,EAAE,eAAe,SAAS,qBAC9B,wBAAwB,EAAE;CAE5B,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,2BACf,WAAW,sBAAsB,IAAI,EAAE;CAE3C,MAAM,aAAa,WAA0B;EAC3C,IAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,OAAO,EAAE;GACnD,QAAQ,MAAM,UAAU,OAAO,mBAAmB;GAClD;;EAGF,eAAe,OAAO;EAEtB,mBACE,QACA,mBAAmB,0BAA0B,KAC9C;EAED,iBAAiB,OAAO;;CAG1B,OAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\ntype UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * Preact hook to get the current locale and related locale management functions.\n *\n * @param props - Optional properties for the hook.\n * @returns An object containing the current locale, default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocale } from 'preact-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { locale, setLocale, availableLocales } = useLocale();\n *\n * return (\n * <select value={locale} onChange={(e) => setLocale(e.target.value)}>\n * {availableLocales.map((loc) => (\n * <option key={loc} value={loc}>{loc}</option>\n * ))}\n * </select>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext) ?? {};\n\n const setLocale = (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n\n onLocaleChange?.(locale as DeclaredLocales);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAsB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9B,wBAAwB,EAAE;CAE5B,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,2BACf,WAAW,sBAAsB,IAAI,EAAE;CAE3C,MAAM,aAAa,WAA0B;EAC3C,IAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,OAAO,EAAE;GACnD,QAAQ,MAAM,UAAU,OAAO,mBAAmB;GAClD;;EAGF,eAAe,OAAO;EAEtB,mBACE,QACA,mBAAmB,0BAA0B,KAC9C;EAED,iBAAiB,OAA0B;;CAG7C,OAAO;EACL;EACA;EACA;EACA;EACD"}
@@ -1,10 +1,15 @@
1
- import { LocalesValues } from "@intlayer/types/module_augmentation";
2
- import * as _$_intlayer_types0 from "@intlayer/types";
1
+ import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
3
2
 
4
3
  //#region src/client/useLocale.d.ts
5
- type useLocaleProps = {
4
+ type UseLocaleProps = {
6
5
  isCookieEnabled?: boolean;
7
- onLocaleChange?: (locale: LocalesValues) => void;
6
+ onLocaleChange?: (locale: DeclaredLocales) => void;
7
+ };
8
+ type UseLocaleResult = {
9
+ locale: DeclaredLocales;
10
+ defaultLocale: DeclaredLocales;
11
+ availableLocales: DeclaredLocales[];
12
+ setLocale: (locale: LocalesValues) => void;
8
13
  };
9
14
  /**
10
15
  * Preact hook to get the current locale and related locale management functions.
@@ -32,12 +37,7 @@ type useLocaleProps = {
32
37
  declare const useLocale: ({
33
38
  isCookieEnabled,
34
39
  onLocaleChange
35
- }?: useLocaleProps) => {
36
- locale: LocalesValues;
37
- defaultLocale: _$_intlayer_types0.Locale;
38
- availableLocales: _$_intlayer_types0.Locale[];
39
- setLocale: (locale: LocalesValues) => void;
40
- };
40
+ }?: UseLocaleProps) => UseLocaleResult;
41
41
  //#endregion
42
42
  export { useLocale };
43
43
  //# sourceMappingURL=useLocale.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/client/useLocale.ts"],"mappings":";;;;KAMK,cAAA;EACH,eAAA;EACA,cAAA,IAAkB,MAAA,EAAQ,aAAA;AAAA;;;;;;;;;;AA0B5B;;;;;;;;;;;;;;cAAa,SAAA;EAAa,eAAA;EAAA;AAAA,IAGvB,cAAA;;;;sBAU0B,aAAA;AAAA"}
1
+ {"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/client/useLocale.ts"],"mappings":";;;KASK,cAAA;EACH,eAAA;EACA,cAAA,IAAkB,MAAA,EAAQ,eAAA;AAAA;AAAA,KAGvB,eAAA;EACH,MAAA,EAAQ,eAAA;EACR,aAAA,EAAe,eAAA;EACf,gBAAA,EAAkB,eAAA;EAClB,SAAA,GAAY,MAAA,EAAQ,aAAA;AAAA;;;AAPqB;;;;;;;;;;;;;;;;;;;;AAiC3C;cAAa,SAAA;EAAa,eAAA;EAAA;AAAA,IAGvB,cAAA,KAAsB,eAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "preact-intlayer",
3
- "version": "8.9.3",
3
+ "version": "8.9.4-canary.0",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Preact applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -100,15 +100,15 @@
100
100
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
101
101
  },
102
102
  "dependencies": {
103
- "@intlayer/api": "8.9.3",
104
- "@intlayer/chokidar": "8.9.3",
105
- "@intlayer/config": "8.9.3",
106
- "@intlayer/core": "8.9.3",
107
- "@intlayer/editor": "8.9.3",
108
- "@intlayer/types": "8.9.3"
103
+ "@intlayer/api": "8.9.4-canary.0",
104
+ "@intlayer/chokidar": "8.9.4-canary.0",
105
+ "@intlayer/config": "8.9.4-canary.0",
106
+ "@intlayer/core": "8.9.4-canary.0",
107
+ "@intlayer/editor": "8.9.4-canary.0",
108
+ "@intlayer/types": "8.9.4-canary.0"
109
109
  },
110
110
  "devDependencies": {
111
- "@types/node": "25.6.1",
111
+ "@types/node": "25.6.2",
112
112
  "@utils/ts-config": "1.0.4",
113
113
  "@utils/ts-config-types": "1.0.4",
114
114
  "@utils/tsdown-config": "1.0.4",