@koine/next 2.0.0-beta.27 → 2.0.0-beta.29

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,6 +1,6 @@
1
1
  import type { DynamicNamespacesProps as BaseDynamicNamespacesProps } from "next-translate";
2
2
  import BaseDynamicNamespaces from "next-translate/DynamicNamespaces";
3
- import type { TranslateNamespace } from "./types-i18n.js";
3
+ import type { TranslateNamespace } from "@koine/i18n";
4
4
  export type DynamicNamespacesProps = Omit<BaseDynamicNamespacesProps, "namespaces"> & {
5
5
  namespaces: TranslateNamespace[];
6
6
  };
package/12/T.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ /// <reference types="react" />
1
2
  import type { TransProps } from "next-translate";
2
- import type { TranslateNamespace, TranslationsAllPaths, TranslationsPaths } from "./types-i18n.js";
3
+ import type { TranslateNamespace, TranslationsAllPaths, TranslationsPaths } from "@koine/i18n";
3
4
  export type TProps<TNamespace extends TranslateNamespace | undefined = undefined> = (Omit<TransProps, "i18nKey" | "ns"> & {
4
5
  i18nKey: TranslationsAllPaths;
5
6
  }) | (Omit<TransProps, "i18nKey" | "ns"> & {
@@ -0,0 +1,2 @@
1
+ export declare const createUseLocale: <TLocales extends string[] | readonly string[]>(_locales: TLocales, defaultLocale: TLocales[number]) => () => TLocales[number];
2
+ export default createUseLocale;
@@ -0,0 +1,7 @@
1
+ import { useRouter } from "next/router";
2
+ export var createUseLocale = function (_locales, defaultLocale) {
3
+ return function () {
4
+ return useRouter().locale || defaultLocale;
5
+ };
6
+ };
7
+ export default createUseLocale;
@@ -0,0 +1,3 @@
1
+ import { type ToRoute, type ToRouteDynamic, type ToRouteDynamicParams, type ToRouteStatic } from "@koine/i18n";
2
+ export declare const createUseTo: <TLocales extends string[] | readonly string[]>(useLocaleHook: () => TLocales[number], _locales: TLocales, defaultLocale: TLocales[number], hideDefaultLocaleInUrl?: boolean) => () => <TRoute extends ToRoute>(...args: TRoute extends ToRouteDynamic ? [routeId: TRoute, routeParams: ToRouteDynamicParams<TRoute>] : TRoute extends ToRouteStatic ? [routeId: ToRouteStatic] : never) => string;
3
+ export default createUseTo;
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { __read } from "tslib";
3
+ import { createTo, } from "@koine/i18n";
4
+ import { useT } from "./useT.js";
5
+ export var createUseTo = function (useLocaleHook, _locales, defaultLocale, hideDefaultLocaleInUrl) {
6
+ return function () {
7
+ var t = useT("~");
8
+ var locale = useLocaleHook();
9
+ var _to = createTo(_locales, defaultLocale, hideDefaultLocaleInUrl);
10
+ return function () {
11
+ var args = [];
12
+ for (var _i = 0; _i < arguments.length; _i++) {
13
+ args[_i] = arguments[_i];
14
+ }
15
+ var _a = __read(args, 2), routeId = _a[0], routeParams = _a[1];
16
+ return routeParams
17
+ ? _to(locale, t, routeId, routeParams)
18
+ : _to(locale, t, routeId);
19
+ };
20
+ };
21
+ };
22
+ export default createUseTo;
package/12/getT.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Translate, TranslateNamespace } from "./types-i18n.js";
1
+ import type { Translate, TranslateNamespace } from "@koine/i18n";
2
2
  export type GetT = <TNamespace extends TranslateNamespace | undefined = undefined>(locale?: string, namespace?: TNamespace) => Promise<Translate<TNamespace>>;
3
3
  export declare const getT: GetT;
4
4
  export default getT;
@@ -1,4 +1,4 @@
1
+ import type { TranslateLoose } from "@koine/i18n";
1
2
  import type { Option } from "@koine/react/types";
2
- import type { TranslateLoose } from "./types-i18n.js";
3
3
  export declare function translationAsOptions(t: TranslateLoose, i18nKey: string): Option[];
4
4
  export default translationAsOptions;
package/12/types.d.ts CHANGED
@@ -1,7 +1,4 @@
1
- export * from "./types-i18n.js";
2
- export * from "./types-seo.js";
3
1
  export type { TProps } from "./T.js";
4
2
  export type { GetT } from "./getT.js";
5
3
  export type { DynamicNamespacesProps } from "./DynamicNamespaces.js";
6
4
  export type { SeoDefaultsProps } from "./SeoDefaults.js";
7
- export type { ToTranslate, ToStaticRoute, ToDynamicRoute, ToArgs } from "./to.js";
package/12/types.js CHANGED
@@ -1,2 +1 @@
1
- export * from "./types-i18n.js";
2
- export * from "./types-seo.js";
1
+ export {};
package/12/useT.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { TranslateDefault, TranslateNamespace, TranslateNamespaced } from "./types-i18n.js";
1
+ import type { TranslateDefault, TranslateNamespace, TranslateNamespaced } from "@koine/i18n";
2
2
  export declare function useT(): TranslateDefault;
3
3
  export declare function useT<TNamespace extends TranslateNamespace>(namespace: TNamespace): TranslateNamespaced<TNamespace>;
4
4
  export default useT;
package/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { getSiteUrl } from "./getSiteUrl.js";
2
1
  export { load } from "./load.js";
3
2
  export { ThemeContext, type ThemeContextProps } from "./ThemeContext.js";
4
3
  export { ThemeProvider, type ThemeProviderProps } from "./ThemeProvider.js";
package/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export { getSiteUrl } from "./getSiteUrl.js";
2
1
  export { load } from "./load.js";
3
2
  export { ThemeContext } from "./ThemeContext.js";
4
3
  export { ThemeProvider } from "./ThemeProvider.js";
package/package.json CHANGED
@@ -2,9 +2,10 @@
2
2
  "name": "@koine/next",
3
3
  "sideEffects": false,
4
4
  "dependencies": {
5
- "@koine/browser": "2.0.0-beta.27",
6
- "@koine/react": "2.0.0-beta.27",
7
- "@koine/utils": "2.0.0-beta.27"
5
+ "@koine/browser": "2.0.0-beta.29",
6
+ "@koine/react": "2.0.0-beta.29",
7
+ "@koine/utils": "2.0.0-beta.29",
8
+ "@koine/i18n": "2.0.0-beta.29"
8
9
  },
9
10
  "peerDependenciesMeta": {
10
11
  "@kuus/yup": {
@@ -95,6 +96,12 @@
95
96
  "./12/app/sc": {
96
97
  "import": "./12/app/sc/index.js"
97
98
  },
99
+ "./12/createUseLocale": {
100
+ "import": "./12/createUseLocale.js"
101
+ },
102
+ "./12/createUseTo": {
103
+ "import": "./12/createUseTo.js"
104
+ },
98
105
  "./12/document/Document": {
99
106
  "import": "./12/document/Document.js"
100
107
  },
@@ -171,6 +178,12 @@
171
178
  "import": "./useTheme.js"
172
179
  }
173
180
  },
174
- "peerDependencies": {},
175
- "version": "2.0.0-beta.27"
181
+ "peerDependencies": {
182
+ "next": "^14.0.4",
183
+ "react": "^18.2.0",
184
+ "next-translate": "^2.6.2",
185
+ "next-seo": "^6.4.0",
186
+ "date-fns": "^3.2.0"
187
+ },
188
+ "version": "2.0.0-beta.29"
176
189
  }
package/typings.d.ts CHANGED
@@ -11,15 +11,6 @@ declare module "*.svg" {
11
11
  export default content;
12
12
  }
13
13
 
14
- /**
15
- * Extend NodeJS `process.env` with variables used by @koine
16
- */
17
- declare namespace NodeJS {
18
- interface ProcessEnv {
19
- NEXT_PUBLIC_APP_URL: string;
20
- }
21
- }
22
-
23
14
  /**
24
15
  * Types specifically related to `@koine/next` exposed on the global unique
25
16
  * namespace `Koine`. Most of the types here should be prefixed by `Next`, e.g.
@@ -30,36 +21,6 @@ declare namespace Koine {
30
21
  * Default SEO data structure expected by the `<Seo>` component's prop `seo`
31
22
  */
32
23
  type NextSeo = import("./12/types-seo").SeoData;
33
-
34
- /**
35
- * Translations dictionary extracted from JSON files.
36
- * You need to augment this type with something like:
37
- *
38
- * ```ts
39
- * declare namespace Koine {
40
- * interface Translations {
41
- * "~": typeof import("./locales/en/~.json");
42
- * "_": typeof import("./locales/en/_.json");
43
- * "$team": typeof import("./locales/en/$team.json");
44
- * "home": typeof import("./locales/en/home.json");
45
- * "Header": typeof import("./locales/en/Header.json");
46
- * }
47
- * }
48
- * ```
49
- *
50
- * Best to follow a convention to name the files which become the namespaces:
51
- *
52
- * - `~`: for app wide **urls** translated definitions
53
- * - `_`: for app wide **common** translations
54
- * - `${data}`: dollar prefix for static **data** like arrays, objects, .etc
55
- * - `{route-name}`: lower cased for **route** specific data
56
- * - `{ComponentName}`: pascal cased for **components** specific data
57
- *
58
- * This works through using [type augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation)
59
- * and [merging interfaces](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces).
60
- */
61
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
62
- interface Translations {}
63
24
  }
64
25
 
65
26
  /**