@koine/next 1.0.30 → 1.0.33

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/i18n/types.d.ts CHANGED
@@ -53,20 +53,30 @@ export declare type TranslationsAllPaths = {
53
53
  }[Extract<keyof TranslationsDictionary[N], string>];
54
54
  }[Extract<keyof TranslationsDictionary, string>];
55
55
  /**
56
- * Query object to populate the returned translated string interpolating data.
57
- * Unlike in `next-translate` we allow passing just `obj` as a shortcut for
58
- * `{ returnObjects: true }`. In such case the thrid argument will not exists.
56
+ * Unlike in `next-translate` we add passing some predefined arguments as
57
+ * shortcuts for common use cases:
58
+ * - `"obj"` as a shortcut for `{ returnObjects: true }`
59
+ * - `""` as a shortcut for `{ fallback: "" }`
59
60
  *
61
+ */
62
+ export declare type TranslationShortcut = "obj" | "";
63
+ /**
64
+ * Query object to populate the returned translated string interpolating data
65
+ * or a TranslationShortcut.
66
+ *
67
+ * NOTE: when using a shortcut passing TranslationOptions to `t()` is not supported
60
68
  * TODO: type safe this behaviour of the third argument (options).
61
69
  */
62
- export declare type TranslationQuery = undefined | null | "obj" | {
70
+ export declare type TranslationQuery = undefined | null | TranslationShortcut | {
63
71
  [key: string]: string | number | boolean;
64
72
  };
65
73
  /**
66
- * Opions of the translate function. Unlike in `next-translate` we allow passing
67
- * just `obj` as a shortcut for `{ returnObjects: true }`.
74
+ * Opions of the translate function or a TranslationShortcut.
75
+ *
76
+ * NOTE: when using a shortcut passing TranslationOptions to `t()` is not supported
77
+ * TODO: type safe this behaviour of the third argument (options).
68
78
  */
69
- export declare type TranslationOptions = undefined | "obj" | {
79
+ export declare type TranslationOptions = undefined | TranslationShortcut | {
70
80
  returnObjects?: boolean;
71
81
  fallback?: string | string[];
72
82
  default?: string;
@@ -1,7 +1,7 @@
1
1
  import type { TranslateNamespace, TranslateDefault, TranslateNamespaced } from "../types";
2
2
  /**
3
- * Wrap `next-translate` useTranslations for type safet and adding the `obj`
4
- * second argument shortcut for `{ returnObjects: true }`
3
+ * Wrap `next-translate` useTranslations for type safety and adds TranslationShortcut
4
+ * as second/thir argument.
5
5
  *
6
6
  * @see https://github.com/vinissimus/next-translate/issues/513#issuecomment-779826418
7
7
  *
@@ -4,7 +4,11 @@ export function useT(namespace) {
4
4
  var t = useTranslation().t;
5
5
  var tMemoized = useMemo(function () {
6
6
  return function (s, q, o) {
7
- return t(namespace ? "".concat(namespace, ":").concat(s) : s, q === "obj" ? null : q, q === "obj" || o === "obj" ? { returnObjects: true } : o
7
+ return t(namespace ? "".concat(namespace, ":").concat(s) : s, q === "obj" || q === "" ? null : q, q === "obj" || o === "obj"
8
+ ? { returnObjects: true }
9
+ : q === "" || o === ""
10
+ ? { fallback: "" }
11
+ : o
8
12
  // ) as TReturn extends (undefined | never | unknown) ? TranslateReturn<TranslationQuery, TranslationOptions> : TReturn;
9
13
  );
10
14
  };
@@ -8,7 +8,11 @@ function useT(namespace) {
8
8
  var t = (0, useTranslation_1.default)().t;
9
9
  var tMemoized = (0, react_1.useMemo)(function () {
10
10
  return function (s, q, o) {
11
- return t(namespace ? "".concat(namespace, ":").concat(s) : s, q === "obj" ? null : q, q === "obj" || o === "obj" ? { returnObjects: true } : o
11
+ return t(namespace ? "".concat(namespace, ":").concat(s) : s, q === "obj" || q === "" ? null : q, q === "obj" || o === "obj"
12
+ ? { returnObjects: true }
13
+ : q === "" || o === ""
14
+ ? { fallback: "" }
15
+ : o
12
16
  // ) as TReturn extends (undefined | never | unknown) ? TranslateReturn<TranslationQuery, TranslationOptions> : TReturn;
13
17
  );
14
18
  };
package/package.json CHANGED
@@ -7,14 +7,10 @@
7
7
  "peerDependencies": {
8
8
  "react": "^16.8 || ^17 || ^18",
9
9
  "next": "^12.1.6",
10
- "@koine/utils": "1.0.30",
10
+ "@koine/utils": "1.0.33",
11
11
  "framer-motion": "^6.3.10",
12
- "next-auth": "^4.3.4",
13
- "@mui/material": "^5.8.2",
14
- "@emotion/react": "^11.9.0",
12
+ "@koine/react": "1.0.33",
15
13
  "styled-components": "^5.3.5",
16
- "react-hook-form": "^7.31.3",
17
- "@koine/react": "1.0.30",
18
14
  "@mui/base": "^5.0.0-alpha.83",
19
15
  "react-icons": "^4.4.0",
20
16
  "date-fns": "^2.28.0",
@@ -22,15 +18,19 @@
22
18
  "@tiptap/react": "^2.0.0-beta.109",
23
19
  "@tiptap/starter-kit": "^2.0.0-beta.185",
24
20
  "yup": "^0.32.11",
21
+ "react-hook-form": "^7.31.3",
25
22
  "type-fest": "^2.13.0",
26
23
  "react-popper": "^2.3.0",
27
24
  "tslib": "^2.4.0",
25
+ "next-auth": "^4.3.4",
26
+ "@mui/material": "^5.8.2",
27
+ "@emotion/react": "^11.9.0",
28
28
  "@emotion/server": "^11.4.0",
29
29
  "@hookform/resolvers": "^2.9.0",
30
30
  "next-translate": "^1.4.0",
31
31
  "next-seo": "^5.4.0"
32
32
  },
33
- "version": "1.0.30",
33
+ "version": "1.0.33",
34
34
  "module": "./index.js",
35
35
  "types": "./index.d.ts"
36
36
  }