@koine/next 1.0.4 → 1.0.9

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.
Files changed (209) hide show
  1. package/Analytics/AnalyticsGoogle.d.ts +5 -6
  2. package/Analytics/AnalyticsGoogle.js +37 -0
  3. package/Analytics/index.d.ts +1 -1
  4. package/Analytics/index.js +1 -0
  5. package/Analytics/package.json +6 -0
  6. package/Auth/helpers.d.ts +17 -17
  7. package/Auth/helpers.js +21 -0
  8. package/Auth/index.d.ts +4 -4
  9. package/Auth/index.js +4 -0
  10. package/Auth/package.json +6 -0
  11. package/Auth/useLogin.d.ts +7 -7
  12. package/Auth/useLogin.js +50 -0
  13. package/Auth/useLoginUrl.d.ts +1 -1
  14. package/Auth/useLoginUrl.js +11 -0
  15. package/Auth/useLogout.d.ts +6 -6
  16. package/Auth/useLogout.js +52 -0
  17. package/Favicon/Favicon.d.ts +3 -4
  18. package/Favicon/Favicon.js +4 -0
  19. package/Favicon/index.d.ts +1 -1
  20. package/Favicon/index.js +1 -0
  21. package/Favicon/package.json +6 -0
  22. package/Forms/index.d.ts +2 -2
  23. package/Forms/index.js +2 -0
  24. package/Forms/package.json +6 -0
  25. package/Forms/useForm.d.ts +32 -32
  26. package/Forms/useForm.js +37 -0
  27. package/Forms/useSubmit.d.ts +24 -24
  28. package/Forms/useSubmit.js +23 -0
  29. package/Head/Head.d.ts +1 -1
  30. package/Head/Head.js +1 -0
  31. package/Head/index.d.ts +1 -1
  32. package/Head/index.js +1 -0
  33. package/Head/package.json +6 -0
  34. package/I18n/I18n.d.ts +44 -48
  35. package/I18n/I18n.js +74 -0
  36. package/I18n/index.d.ts +1 -1
  37. package/I18n/index.js +1 -0
  38. package/I18n/package.json +6 -0
  39. package/Img/Img.d.ts +21 -21
  40. package/Img/Img.js +28 -0
  41. package/Img/index.d.ts +1 -1
  42. package/Img/index.js +1 -0
  43. package/Img/package.json +6 -0
  44. package/Link/Link.d.ts +9 -8
  45. package/Link/Link.js +9 -0
  46. package/Link/index.d.ts +1 -1
  47. package/Link/index.js +1 -0
  48. package/Link/package.json +6 -0
  49. package/NextProgress/NextProgress.d.ts +24 -14
  50. package/NextProgress/NextProgress.js +37 -0
  51. package/NextProgress/index.d.ts +2 -1
  52. package/NextProgress/index.js +1 -0
  53. package/NextProgress/package.json +6 -0
  54. package/README.md +0 -0
  55. package/Seo/Seo.d.ts +3 -3
  56. package/Seo/Seo.js +8 -0
  57. package/Seo/SeoDefaults.d.ts +3 -3
  58. package/Seo/SeoDefaults.js +12 -0
  59. package/Seo/helpers.d.ts +48 -48
  60. package/Seo/helpers.js +111 -0
  61. package/Seo/index.d.ts +12 -12
  62. package/Seo/index.js +12 -0
  63. package/Seo/package.json +6 -0
  64. package/Theme/Theme.d.ts +46 -46
  65. package/Theme/Theme.js +235 -0
  66. package/Theme/index.d.ts +1 -1
  67. package/Theme/index.js +1 -0
  68. package/Theme/package.json +6 -0
  69. package/app/AppHead.d.ts +2 -3
  70. package/app/AppHead.js +5 -0
  71. package/app/AppMain.d.ts +35 -34
  72. package/app/AppMain.js +1 -0
  73. package/app/css/AppMain.d.ts +8 -0
  74. package/app/css/AppMain.js +11 -0
  75. package/app/css/AppTheme.d.ts +10 -0
  76. package/app/css/AppTheme.js +12 -0
  77. package/app/css/auth/index.d.ts +9 -0
  78. package/app/css/auth/index.js +13 -0
  79. package/app/css/auth/package.json +6 -0
  80. package/app/css/index.d.ts +54 -0
  81. package/app/css/index.js +57 -0
  82. package/app/css/package.json +6 -0
  83. package/app/em/AppMain.d.ts +10 -0
  84. package/app/em/AppMain.js +22 -0
  85. package/app/{AppTheme--emotion.d.ts → em/AppTheme.d.ts} +15 -15
  86. package/app/em/AppTheme.js +17 -0
  87. package/app/em/auth/index.d.ts +9 -0
  88. package/app/em/auth/index.js +13 -0
  89. package/app/em/auth/package.json +6 -0
  90. package/app/em/index.d.ts +9 -0
  91. package/app/em/index.js +12 -0
  92. package/app/em/package.json +6 -0
  93. package/app/index.d.ts +2 -11
  94. package/app/index.js +2 -0
  95. package/app/package.json +6 -0
  96. package/app/sc/AppMain.d.ts +10 -0
  97. package/app/sc/AppMain.js +22 -0
  98. package/app/sc/AppTheme.d.ts +13 -0
  99. package/app/sc/AppTheme.js +9 -0
  100. package/app/sc/auth/index.d.ts +9 -0
  101. package/app/sc/auth/index.js +13 -0
  102. package/app/sc/auth/package.json +6 -0
  103. package/app/sc/index.d.ts +56 -0
  104. package/app/sc/index.js +59 -0
  105. package/app/sc/package.json +6 -0
  106. package/config/index.d.ts +71 -58
  107. package/config/index.js +174 -0
  108. package/config/package.json +6 -0
  109. package/document/Document.d.ts +15 -10
  110. package/document/Document.js +19 -0
  111. package/document/css/index.d.ts +22 -0
  112. package/document/css/index.js +30 -0
  113. package/document/css/package.json +6 -0
  114. package/document/em/index.d.ts +16 -0
  115. package/document/em/index.js +68 -0
  116. package/document/em/package.json +6 -0
  117. package/document/index.d.ts +2 -4
  118. package/document/index.js +2 -0
  119. package/document/package.json +6 -0
  120. package/document/{Document--sc.d.ts → sc/index.d.ts} +20 -11
  121. package/document/sc/index.js +44 -0
  122. package/document/sc/package.json +6 -0
  123. package/index.d.ts +12 -12
  124. package/index.js +12 -743
  125. package/node/Analytics/AnalyticsGoogle.js +42 -0
  126. package/node/Analytics/index.js +4 -0
  127. package/node/Auth/helpers.js +26 -0
  128. package/node/Auth/index.js +7 -0
  129. package/node/Auth/useLogin.js +54 -0
  130. package/node/Auth/useLoginUrl.js +15 -0
  131. package/node/Auth/useLogout.js +56 -0
  132. package/node/Favicon/Favicon.js +9 -0
  133. package/node/Favicon/index.js +4 -0
  134. package/node/Forms/index.js +5 -0
  135. package/node/Forms/useForm.js +41 -0
  136. package/node/Forms/useSubmit.js +27 -0
  137. package/node/Head/Head.js +8 -0
  138. package/node/Head/index.js +4 -0
  139. package/node/I18n/I18n.js +82 -0
  140. package/node/I18n/index.js +4 -0
  141. package/node/Img/Img.js +34 -0
  142. package/node/Img/index.js +4 -0
  143. package/node/Link/Link.js +13 -0
  144. package/node/Link/index.js +4 -0
  145. package/node/NextProgress/NextProgress.js +41 -0
  146. package/node/NextProgress/index.js +5 -0
  147. package/node/Seo/Seo.js +12 -0
  148. package/node/Seo/SeoDefaults.js +16 -0
  149. package/node/Seo/helpers.js +115 -0
  150. package/node/Seo/index.js +15 -0
  151. package/node/Theme/Theme.js +241 -0
  152. package/node/Theme/index.js +4 -0
  153. package/node/app/AppHead.js +10 -0
  154. package/node/app/AppMain.js +2 -0
  155. package/node/app/css/AppMain.js +16 -0
  156. package/node/app/css/AppTheme.js +16 -0
  157. package/node/app/css/auth/index.js +18 -0
  158. package/node/app/css/index.js +62 -0
  159. package/node/app/em/AppMain.js +26 -0
  160. package/node/app/em/AppTheme.js +22 -0
  161. package/node/app/em/auth/index.js +18 -0
  162. package/node/app/em/index.js +17 -0
  163. package/node/app/index.js +5 -0
  164. package/node/app/sc/AppMain.js +26 -0
  165. package/node/app/sc/AppTheme.js +13 -0
  166. package/node/app/sc/auth/index.js +18 -0
  167. package/node/app/sc/index.js +64 -0
  168. package/node/config/index.js +184 -0
  169. package/node/document/Document.js +24 -0
  170. package/node/document/css/index.js +35 -0
  171. package/node/document/em/index.js +73 -0
  172. package/node/document/index.js +7 -0
  173. package/node/document/sc/index.js +49 -0
  174. package/node/index.js +15 -0
  175. package/node/utils/api.js +38 -0
  176. package/node/utils/emotion-cache.js +13 -0
  177. package/node/utils/index.js +32 -0
  178. package/package.json +3 -30
  179. package/{types.d.ts → typings.d.ts} +10 -7
  180. package/utils/api.d.ts +55 -55
  181. package/utils/api.js +35 -0
  182. package/{document/emotion.d.ts → utils/emotion-cache.d.ts} +5 -5
  183. package/utils/emotion-cache.js +8 -0
  184. package/utils/index.d.ts +19 -19
  185. package/utils/index.js +26 -0
  186. package/utils/package.json +6 -0
  187. package/Theme.js +0 -1905
  188. package/_tslib.js +0 -41
  189. package/app/App--emotion.d.ts +0 -10
  190. package/app/App--sc.d.ts +0 -10
  191. package/app/App--vanilla.d.ts +0 -10
  192. package/app/AppAuth--emotion.d.ts +0 -10
  193. package/app/AppAuth--sc.d.ts +0 -10
  194. package/app/AppMain--vanilla.d.ts +0 -27
  195. package/app/AppTheme--sc.d.ts +0 -13
  196. package/app/AppTheme--vanilla.d.ts +0 -10
  197. package/app/motion-features.d.ts +0 -2
  198. package/app.js +0 -250
  199. package/config.js +0 -183
  200. package/document/Document--emotion.d.ts +0 -5
  201. package/document/Document--vanilla.d.ts +0 -11
  202. package/document.js +0 -207
  203. package/emotion.js +0 -1329
  204. package/es.object.assign.js +0 -1074
  205. package/es.string.replace.js +0 -785
  206. package/es.string.split.js +0 -201
  207. package/index.esm.js +0 -4600
  208. package/index.umd.js +0 -4638
  209. package/motion-features.js +0 -10
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnalyticsGoogle = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const router_1 = require("next/router");
8
+ const script_1 = tslib_1.__importDefault(require("next/script"));
9
+ const utils_1 = require("@koine/utils");
10
+ const AnalyticsGoogle = ({ id }) => {
11
+ const uid = id || process.env["NEXT_PUBLIC_GTM_ID"];
12
+ const { events, asPath, query } = (0, router_1.useRouter)();
13
+ const [ready, setReady] = (0, react_1.useState)(false);
14
+ const [routed, setRouted] = (0, react_1.useState)(false);
15
+ // const [url, setUrl] = useState("");
16
+ (0, react_1.useEffect)(() => {
17
+ const handleRouteChange = () => {
18
+ setRouted(true);
19
+ };
20
+ events.on("routeChangeComplete", handleRouteChange);
21
+ return () => {
22
+ events.off("routeChangeComplete", handleRouteChange);
23
+ };
24
+ }, [events]);
25
+ (0, react_1.useEffect)(() => {
26
+ if (routed && ready && asPath) {
27
+ // const search = query;
28
+ (0, utils_1.pageview)(asPath);
29
+ }
30
+ }, [asPath, query, routed, ready]);
31
+ if (!uid) {
32
+ return null;
33
+ }
34
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(script_1.default, { id: "google-tagmanager", src: `https://www.googletagmanager.com/gtag/js?id=${id}`, strategy: "afterInteractive", onLoad: () => setReady(true) }), (0, jsx_runtime_1.jsx)(script_1.default, { id: "google-analytics", strategy: "afterInteractive", children: `
35
+ window.dataLayer = window.dataLayer || [];
36
+ function gtag(){window.dataLayer.push(arguments);}
37
+ gtag('js', new Date());
38
+
39
+ gtag('config', '${id}', { 'send_page_view': false });
40
+ ` })] }));
41
+ };
42
+ exports.AnalyticsGoogle = AnalyticsGoogle;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./AnalyticsGoogle"), exports);
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCallbackUrl = exports.getAuthRoutes = exports.AUTH_ROUTES = void 0;
4
+ const utils_1 = require("@koine/utils");
5
+ exports.AUTH_ROUTES = {
6
+ login: process.env["AUTH_ROUTE_LOGIN"],
7
+ profile: process.env["AUTH_ROUTE_PROFILE"],
8
+ register: process.env["AUTH_ROUTE_REGISTER"],
9
+ secured: JSON.parse(process.env["AUTH_ROUTES_SECURED"] || "[]"),
10
+ };
11
+ function getAuthRoutes(t) {
12
+ return Object.keys(exports.AUTH_ROUTES).reduce((map, name) => {
13
+ const routePage = exports.AUTH_ROUTES[name];
14
+ // @ts-expect-error cannot remember
15
+ map[name] = (0, utils_1.isString)(routePage) ? t(`~:${exports.AUTH_ROUTES[name]}`) : routePage;
16
+ return map;
17
+ }, {});
18
+ }
19
+ exports.getAuthRoutes = getAuthRoutes;
20
+ /**
21
+ * @param url e.g. "http://localhost:3000/signin?callbackUrl=http://localhost:3000/profile"
22
+ */
23
+ function getCallbackUrl(url = window.location.href) {
24
+ return url.split("callbackUrl=")[1] || "";
25
+ }
26
+ exports.getCallbackUrl = getCallbackUrl;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./helpers"), exports);
5
+ tslib_1.__exportStar(require("./useLogin"), exports);
6
+ tslib_1.__exportStar(require("./useLoginUrl"), exports);
7
+ tslib_1.__exportStar(require("./useLogout"), exports);
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLogin = void 0;
4
+ const react_1 = require("react");
5
+ const router_1 = require("next/router");
6
+ const react_2 = require("next-auth/react");
7
+ const utils_1 = require("@koine/utils");
8
+ const I18n_1 = require("../I18n");
9
+ const helpers_1 = require("./helpers");
10
+ function useLogin() {
11
+ const t = (0, I18n_1.useT)();
12
+ const { push } = (0, router_1.useRouter)();
13
+ const [loading, setLoading] = (0, react_1.useState)(false);
14
+ const [ok, setOk] = (0, react_1.useState)(false);
15
+ const [fail, setFail] = (0, react_1.useState)(false);
16
+ const submit = (0, react_1.useCallback)((data) => {
17
+ setLoading(true);
18
+ (0, react_2.signIn)("credentials", {
19
+ ...data,
20
+ redirect: false,
21
+ })
22
+ // @ts-expect-error FIXME: at some point...
23
+ .then(({ ok }) => {
24
+ setLoading(false);
25
+ setOk(ok);
26
+ setFail(!ok);
27
+ if (ok) {
28
+ const redirectUrl = (0, utils_1.parseURL)((0, helpers_1.getCallbackUrl)());
29
+ const { login, register, profile } = (0, helpers_1.getAuthRoutes)(t);
30
+ if (redirectUrl) {
31
+ const redirectPath = redirectUrl.pathname;
32
+ if (profile &&
33
+ (redirectPath === login || redirectPath === register)) {
34
+ push(profile);
35
+ }
36
+ else {
37
+ push(redirectPath + redirectUrl.search);
38
+ }
39
+ }
40
+ else if (profile) {
41
+ push(profile);
42
+ }
43
+ }
44
+ });
45
+ }, [t, push]);
46
+ // TODO: useMemo ?
47
+ return {
48
+ submit,
49
+ loading,
50
+ ok,
51
+ fail,
52
+ };
53
+ }
54
+ exports.useLogin = useLogin;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLoginUrl = void 0;
4
+ const react_1 = require("react");
5
+ const I18n_1 = require("../I18n");
6
+ const helpers_1 = require("./helpers");
7
+ function useLoginUrl() {
8
+ const [currentUrl, setCurrentUrl] = (0, react_1.useState)("");
9
+ const t = (0, I18n_1.useT)();
10
+ (0, react_1.useEffect)(() => {
11
+ setCurrentUrl(`?callbackUrl=${window.location.href}`);
12
+ }, []);
13
+ return `${(0, helpers_1.getAuthRoutes)(t).login}${currentUrl}`;
14
+ }
15
+ exports.useLoginUrl = useLoginUrl;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLogout = void 0;
4
+ const react_1 = require("react");
5
+ const router_1 = require("next/router");
6
+ const react_2 = require("next-auth/react");
7
+ const utils_1 = require("@koine/utils");
8
+ const I18n_1 = require("../I18n");
9
+ const helpers_1 = require("./helpers");
10
+ function useLogout() {
11
+ const t = (0, I18n_1.useT)();
12
+ const { push } = (0, router_1.useRouter)();
13
+ const [loading, setLoading] = (0, react_1.useState)(false);
14
+ const [ok, setOk] = (0, react_1.useState)(false);
15
+ const [fail] = (0, react_1.useState)(false);
16
+ const submit = (0, react_1.useCallback)((event) => {
17
+ event.preventDefault();
18
+ event.stopPropagation();
19
+ setLoading(true);
20
+ (0, react_2.signOut)({ redirect: false }).then(() => {
21
+ setLoading(false);
22
+ setOk(true);
23
+ const redirectUrl = (0, utils_1.parseURL)((0, helpers_1.getCallbackUrl)());
24
+ const currentUrl = (0, utils_1.parseURL)(window.location.href);
25
+ const { secured } = (0, helpers_1.getAuthRoutes)(t);
26
+ const signin = t("~:/signin");
27
+ const profile = t("~:/profile");
28
+ const targetUrl = redirectUrl || currentUrl;
29
+ let redirect = "";
30
+ if (targetUrl) {
31
+ if (targetUrl.pathname === profile) {
32
+ redirect = signin;
33
+ }
34
+ else if (secured) {
35
+ for (let i = 0; i < secured.length; i++) {
36
+ if (targetUrl.pathname.match(secured[i])) {
37
+ redirect = signin;
38
+ break;
39
+ }
40
+ }
41
+ }
42
+ }
43
+ if (redirect) {
44
+ push(redirect);
45
+ }
46
+ });
47
+ }, [t, push]);
48
+ // TODO: useMemo ?
49
+ return {
50
+ submit,
51
+ loading,
52
+ ok,
53
+ fail,
54
+ };
55
+ }
56
+ exports.useLogout = useLogout;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Favicon = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const head_1 = tslib_1.__importDefault(require("next/head"));
7
+ const react_1 = require("@koine/react");
8
+ const Favicon = (props) => ((0, jsx_runtime_1.jsx)(head_1.default, { children: (0, jsx_runtime_1.jsx)(react_1.FaviconTags, { ...props }) }));
9
+ exports.Favicon = Favicon;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./Favicon"), exports);
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./useForm"), exports);
5
+ tslib_1.__exportStar(require("./useSubmit"), exports);
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useForm = void 0;
4
+ const react_1 = require("react");
5
+ const react_hook_form_1 = require("react-hook-form");
6
+ const yup_1 = require("@hookform/resolvers/yup");
7
+ const I18n_1 = require("../I18n");
8
+ function useForm(
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ schema, i18nNamespace, formProps = {}, debug) {
11
+ const t = (0, I18n_1.useT)(i18nNamespace);
12
+ // const form = _useForm<InferType<ObjectSchema<T, object>>>({
13
+ const form = (0, react_hook_form_1.useForm)({
14
+ // @ts-expect-error FIXME:
15
+ resolver: (0, yup_1.yupResolver)(schema),
16
+ // make the form behave more closer as native:
17
+ // shouldUnregister: true,
18
+ ...formProps,
19
+ });
20
+ // const { control, register, setValue } = form;
21
+ // const field = { control, register, setValue, t };
22
+ // if ("production" !== process.env["NODE_ENV"]) {
23
+ // if (debug) {
24
+ // console.log(
25
+ // `Form ${i18nNamespace} data`,
26
+ // form.watch(),
27
+ // `errors: `,
28
+ // form.formState.errors
29
+ // );
30
+ // }
31
+ // }
32
+ // if (formProps.mode === "onChange") {
33
+ // return { field, ...form };
34
+ // }
35
+ return (0, react_1.useMemo)(() => {
36
+ const { control, register, setValue } = form;
37
+ const field = { control, register, setValue, t };
38
+ return { field, ...form };
39
+ }, [t, form]);
40
+ }
41
+ exports.useForm = useForm;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSubmit = void 0;
4
+ const react_use_1 = require("react-use");
5
+ const api_1 = require("../utils/api");
6
+ function useSubmit(url, transformData) {
7
+ const [state, submit] = (0, react_use_1.useAsyncFn)(async (json) => {
8
+ if (transformData)
9
+ json = transformData(json);
10
+ const response = await api_1.api.post(url, {
11
+ json,
12
+ });
13
+ if ("production" !== process.env["NODE_ENV"]) {
14
+ console.log("[@koine/next] useSubmit response", response);
15
+ }
16
+ return response;
17
+ }, [url, transformData]);
18
+ const { loading, error, value } = state;
19
+ const fail = !loading && (!!error || value?.fail);
20
+ return {
21
+ submit,
22
+ loading,
23
+ ...(value || {}),
24
+ fail,
25
+ };
26
+ }
27
+ exports.useSubmit = useSubmit;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Head = void 0;
7
+ var head_1 = require("next/head");
8
+ Object.defineProperty(exports, "Head", { enumerable: true, get: function () { return __importDefault(head_1).default; } });
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./Head"), exports);
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ /// <reference types="@koine/next/typings" />
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useDateFormat = exports.translationAsOptions = exports.useT = exports.T = void 0;
5
+ const tslib_1 = require("tslib");
6
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
7
+ /**
8
+ * @file
9
+ *
10
+ * About the typescript support for translation strings @see:
11
+ * - https://github.com/vinissimus/next-translate/issues/721
12
+ */
13
+ const react_1 = require("react");
14
+ const router_1 = require("next/router");
15
+ const format_1 = tslib_1.__importDefault(require("date-fns/format"));
16
+ const useTranslation_1 = tslib_1.__importDefault(require("next-translate/useTranslation"));
17
+ const react_2 = require("@koine/react");
18
+ var Trans_1 = require("next-translate/Trans");
19
+ Object.defineProperty(exports, "T", { enumerable: true, get: function () { return tslib_1.__importDefault(Trans_1).default; } });
20
+ /**
21
+ * FIXME: the use of `useMemo` is a hopefully-temporary solution to fix the FOUC
22
+ * problem of untranslated text during page transitions
23
+ *
24
+ * @see https://github.com/vinissimus/next-translate/issues/513#issuecomment-779826418
25
+ */
26
+ function useT(namespace) {
27
+ const t = (0, useTranslation_1.default)().t;
28
+ // const typedT = <
29
+ // // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
30
+ // R extends unknown = string,
31
+ // // Q extends TranslationQuery = TranslationQuery
32
+ // // O extends TranslationOptions = TranslationOptions
33
+ // >(
34
+ // s: N extends TranslateNamespace
35
+ // ? Paths<Koine.NextTranslations[N]> | AllPaths
36
+ // : AllPaths,
37
+ // q?: TranslationQuery,
38
+ // o?: TranslationOptions
39
+ // ) =>
40
+ // // eslint-disable-next-line
41
+ // t.call(
42
+ // null,
43
+ // namespace ? `${namespace}:${s}` : s,
44
+ // q === "obj" ? null : q,
45
+ // q === "obj" || o === "obj" ? { returnObjects: true } : o
46
+ // // ) as R extends (undefined | never | unknown) ? TranslateReturn<TranslationQuery, TranslationOptions> : R;
47
+ // ) as R;
48
+ // return typedT;
49
+ const tMemoized = (0, react_1.useMemo)(() => (s, q, o) => t(namespace ? `${namespace}:${s}` : s, q === "obj" ? null : q, q === "obj" || o === "obj" ? { returnObjects: true } : o
50
+ // ) as R extends (undefined | never | unknown) ? TranslateReturn<TranslationQuery, TranslationOptions> : R;
51
+ ), [t, namespace]);
52
+ // return tMemoized as Translate<N>;
53
+ return tMemoized;
54
+ }
55
+ exports.useT = useT;
56
+ function translationAsOptions(t, i18nKey) {
57
+ const dictionary = t(i18nKey, undefined, {
58
+ returnObjects: true,
59
+ });
60
+ return Object.keys(dictionary).map((key) => ({
61
+ value: key,
62
+ label: dictionary[key],
63
+ }));
64
+ }
65
+ exports.translationAsOptions = translationAsOptions;
66
+ /**
67
+ * Automatically returns the `date-fns/format` function with the right locale
68
+ * passed as option (grabbed from next router value).
69
+ */
70
+ const useDateFormat = () => {
71
+ const [formatter, setFormatter] = (0, react_1.useState)(() => (...args) => (0, format_1.default)(...args));
72
+ const router = (0, router_1.useRouter)();
73
+ const locale = (0, react_2.useDateLocale)(router.locale);
74
+ (0, react_1.useEffect)(() => {
75
+ if (locale) {
76
+ const newFormatter = (date, _format, options) => (0, format_1.default)(date, _format, { ...(options || {}), locale });
77
+ setFormatter(() => (...args) => newFormatter(...args));
78
+ }
79
+ }, [locale]);
80
+ return formatter;
81
+ };
82
+ exports.useDateFormat = useDateFormat;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./I18n"), exports);
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNextImgProps = exports.NextImgSmart = exports.NextImg = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const image_1 = tslib_1.__importDefault(require("next/image"));
8
+ exports.NextImg = image_1.default;
9
+ const NextImgSmart = (props) => {
10
+ const [$loaded, setLoaded] = (0, react_1.useState)(false);
11
+ const [$error, setError] = (0, react_1.useState)(false);
12
+ const { nextImgProps, restProps } = getNextImgProps(props);
13
+ const { Wrap } = restProps;
14
+ return nextImgProps.priority ? ((0, jsx_runtime_1.jsx)(image_1.default, { ...nextImgProps })) : ((0, jsx_runtime_1.jsx)(Wrap, { ...restProps, "$loaded": $loaded, "$error": $error, children: (0, jsx_runtime_1.jsx)(image_1.default, { ...nextImgProps, onLoadingComplete: () => setLoaded(true), onError: () => setError(true) }) }));
15
+ };
16
+ exports.NextImgSmart = NextImgSmart;
17
+ function getNextImgProps({ src, alt, layout, blurDataURL, width, height, priority, objectFit, objectPosition, ...restProps }) {
18
+ const nextImgProps = {
19
+ src,
20
+ alt,
21
+ layout,
22
+ blurDataURL,
23
+ width,
24
+ height,
25
+ priority,
26
+ objectFit,
27
+ objectPosition,
28
+ };
29
+ return {
30
+ nextImgProps,
31
+ restProps,
32
+ };
33
+ }
34
+ exports.getNextImgProps = getNextImgProps;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./Img"), exports);
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Link = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const link_1 = tslib_1.__importDefault(require("next/link"));
8
+ /**
9
+ * @see https://next.js.org/docs/api-reference/next/link
10
+ */
11
+ exports.Link = (0, react_1.forwardRef)(function Link({ href, prefetch, replace, scroll, shallow, locale, Link = "span", ...props }, ref) {
12
+ return ((0, jsx_runtime_1.jsx)(link_1.default, { href: href, replace: replace, scroll: scroll, shallow: shallow, locale: locale, passHref: true, children: (0, jsx_runtime_1.jsx)(Link, { ref: ref, ...props }) }));
13
+ });
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./Link"), exports);
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NextProgress = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const router_1 = require("next/router");
7
+ const NextProgress = ({ startAt = 0.3, showOnShallow = true, stopDelayMs = 200, Overlay = "div", }) => {
8
+ const { events } = (0, router_1.useRouter)();
9
+ // const [progress, setProgress] = useState(0);
10
+ const [running, setRunning] = (0, react_1.useState)(false);
11
+ const timer = (0, react_1.useRef)(null);
12
+ const routeChangeStart = (0, react_1.useCallback)((_, { shallow }) => {
13
+ if (!shallow || showOnShallow) {
14
+ // setProgress(startAt);
15
+ setRunning(true);
16
+ }
17
+ }, [showOnShallow]);
18
+ const routeChangeEnd = (0, react_1.useCallback)((_, { shallow }) => {
19
+ if (!shallow || showOnShallow) {
20
+ if (timer.current) {
21
+ clearTimeout(timer.current);
22
+ }
23
+ timer.current = setTimeout(() => {
24
+ // setProgress(100);
25
+ setRunning(false);
26
+ }, stopDelayMs);
27
+ }
28
+ }, [showOnShallow, stopDelayMs, timer]);
29
+ (0, react_1.useEffect)(() => {
30
+ events.on("routeChangeStart", routeChangeStart);
31
+ events.on("routeChangeComplete", routeChangeEnd);
32
+ events.on("routeChangeError", routeChangeEnd);
33
+ return () => {
34
+ events.off("routeChangeStart", routeChangeStart);
35
+ events.off("routeChangeComplete", routeChangeEnd);
36
+ events.off("routeChangeError", routeChangeEnd);
37
+ };
38
+ }, [events, routeChangeStart, routeChangeEnd]);
39
+ return (0, jsx_runtime_1.jsx)(Overlay, { running: running });
40
+ };
41
+ exports.NextProgress = NextProgress;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NextProgress = void 0;
4
+ var NextProgress_1 = require("./NextProgress");
5
+ Object.defineProperty(exports, "NextProgress", { enumerable: true, get: function () { return NextProgress_1.NextProgress; } });
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Seo = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const head_1 = tslib_1.__importDefault(require("next/head"));
8
+ const helpers_1 = require("./helpers");
9
+ const _Seo = (props) => {
10
+ return (0, jsx_runtime_1.jsx)(head_1.default, { children: (0, helpers_1.buildTags)(props) });
11
+ };
12
+ exports.Seo = (0, react_1.memo)(_Seo);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SeoDefaults = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const head_1 = tslib_1.__importDefault(require("next/head"));
8
+ // import { useRouter } from "next/router";
9
+ // import { getSiteUrl } from "../utils";
10
+ const helpers_1 = require("./helpers");
11
+ const _SeoDefaults = (props) => {
12
+ // const router = useRouter();
13
+ // props.openGraph.url = getSiteUrl(router.asPath);
14
+ return (0, jsx_runtime_1.jsx)(head_1.default, { children: (0, helpers_1.buildTags)(props) });
15
+ };
16
+ exports.SeoDefaults = (0, react_1.memo)(_SeoDefaults);