@koine/next 1.0.11 → 1.0.14
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/Analytics/AnalyticsGoogle.js +12 -16
- package/Auth/helpers.js +6 -5
- package/Auth/useLogin.js +17 -18
- package/Auth/useLoginUrl.js +5 -5
- package/Auth/useLogout.js +19 -19
- package/Favicon/Favicon.js +2 -1
- package/Forms/useForm.js +10 -12
- package/Forms/useSubmit.js +23 -18
- package/I18n/I18n.js +35 -14
- package/Img/Img.js +22 -20
- package/Link/Link.js +4 -2
- package/NextProgress/NextProgress.js +12 -9
- package/Seo/Seo.js +2 -2
- package/Seo/SeoDefaults.js +2 -2
- package/Seo/helpers.js +34 -30
- package/Theme/Theme.js +98 -88
- package/app/AppHead.js +1 -1
- package/app/css/AppMain.js +4 -2
- package/app/css/AppTheme.js +4 -2
- package/app/css/auth/index.js +3 -2
- package/app/css/index.js +3 -2
- package/app/em/AppMain.js +9 -7
- package/app/em/AppTheme.js +6 -5
- package/app/em/auth/index.js +3 -2
- package/app/em/index.js +3 -2
- package/app/sc/AppMain.js +9 -7
- package/app/sc/AppTheme.js +4 -2
- package/app/sc/auth/index.js +3 -2
- package/app/sc/index.js +3 -2
- package/config/index.d.ts +13 -0
- package/config/index.js +87 -71
- package/document/Document.js +12 -5
- package/document/css/index.js +26 -12
- package/document/em/index.js +39 -48
- package/document/sc/index.js +44 -23
- package/package.json +13 -11
- package/utils/api.js +40 -31
- package/utils/index.js +7 -6
- package/node/Analytics/AnalyticsGoogle.js +0 -42
- package/node/Analytics/index.js +0 -4
- package/node/Auth/helpers.js +0 -26
- package/node/Auth/index.js +0 -7
- package/node/Auth/useLogin.js +0 -54
- package/node/Auth/useLoginUrl.js +0 -15
- package/node/Auth/useLogout.js +0 -56
- package/node/Favicon/Favicon.js +0 -9
- package/node/Favicon/index.js +0 -4
- package/node/Forms/index.js +0 -5
- package/node/Forms/useForm.js +0 -41
- package/node/Forms/useSubmit.js +0 -27
- package/node/Head/Head.js +0 -8
- package/node/Head/index.js +0 -4
- package/node/I18n/I18n.js +0 -82
- package/node/I18n/index.js +0 -4
- package/node/Img/Img.js +0 -34
- package/node/Img/index.js +0 -4
- package/node/Link/Link.js +0 -13
- package/node/Link/index.js +0 -4
- package/node/NextProgress/NextProgress.js +0 -41
- package/node/NextProgress/index.js +0 -5
- package/node/Seo/Seo.js +0 -12
- package/node/Seo/SeoDefaults.js +0 -16
- package/node/Seo/helpers.js +0 -115
- package/node/Seo/index.js +0 -15
- package/node/Theme/Theme.js +0 -241
- package/node/Theme/index.js +0 -4
- package/node/app/AppHead.js +0 -10
- package/node/app/AppMain.js +0 -2
- package/node/app/css/AppMain.js +0 -16
- package/node/app/css/AppTheme.js +0 -16
- package/node/app/css/auth/index.js +0 -18
- package/node/app/css/index.js +0 -62
- package/node/app/em/AppMain.js +0 -26
- package/node/app/em/AppTheme.js +0 -22
- package/node/app/em/auth/index.js +0 -18
- package/node/app/em/index.js +0 -17
- package/node/app/index.js +0 -5
- package/node/app/sc/AppMain.js +0 -26
- package/node/app/sc/AppTheme.js +0 -13
- package/node/app/sc/auth/index.js +0 -18
- package/node/app/sc/index.js +0 -64
- package/node/config/index.js +0 -184
- package/node/document/Document.js +0 -24
- package/node/document/css/index.js +0 -35
- package/node/document/em/index.js +0 -73
- package/node/document/index.js +0 -7
- package/node/document/sc/index.js +0 -49
- package/node/index.js +0 -15
- package/node/utils/api.js +0 -38
- package/node/utils/emotion-cache.js +0 -13
- package/node/utils/index.js +0 -32
|
@@ -1,24 +1,26 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { useState, useEffect } from "react";
|
|
3
4
|
import { useRouter } from "next/router";
|
|
4
5
|
import Script from "next/script";
|
|
5
6
|
import { pageview } from "@koine/utils";
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export var AnalyticsGoogle = function (_a) {
|
|
8
|
+
var id = _a.id;
|
|
9
|
+
var uid = id || process.env["NEXT_PUBLIC_GTM_ID"];
|
|
10
|
+
var _b = useRouter(), events = _b.events, asPath = _b.asPath, query = _b.query;
|
|
11
|
+
var _c = useState(false), ready = _c[0], setReady = _c[1];
|
|
12
|
+
var _d = useState(false), routed = _d[0], setRouted = _d[1];
|
|
11
13
|
// const [url, setUrl] = useState("");
|
|
12
|
-
useEffect(()
|
|
13
|
-
|
|
14
|
+
useEffect(function () {
|
|
15
|
+
var handleRouteChange = function () {
|
|
14
16
|
setRouted(true);
|
|
15
17
|
};
|
|
16
18
|
events.on("routeChangeComplete", handleRouteChange);
|
|
17
|
-
return ()
|
|
19
|
+
return function () {
|
|
18
20
|
events.off("routeChangeComplete", handleRouteChange);
|
|
19
21
|
};
|
|
20
22
|
}, [events]);
|
|
21
|
-
useEffect(()
|
|
23
|
+
useEffect(function () {
|
|
22
24
|
if (routed && ready && asPath) {
|
|
23
25
|
// const search = query;
|
|
24
26
|
pageview(asPath);
|
|
@@ -27,11 +29,5 @@ export const AnalyticsGoogle = ({ id }) => {
|
|
|
27
29
|
if (!uid) {
|
|
28
30
|
return null;
|
|
29
31
|
}
|
|
30
|
-
return (_jsxs(_Fragment, { children: [_jsx(Script, { id: "google-tagmanager", src:
|
|
31
|
-
window.dataLayer = window.dataLayer || [];
|
|
32
|
-
function gtag(){window.dataLayer.push(arguments);}
|
|
33
|
-
gtag('js', new Date());
|
|
34
|
-
|
|
35
|
-
gtag('config', '${id}', { 'send_page_view': false });
|
|
36
|
-
` })] }));
|
|
32
|
+
return (_jsxs(_Fragment, { children: [_jsx(Script, { id: "google-tagmanager", src: "https://www.googletagmanager.com/gtag/js?id=".concat(id), strategy: "afterInteractive", onLoad: function () { return setReady(true); } }), _jsx(Script, __assign({ id: "google-analytics", strategy: "afterInteractive" }, { children: "\n window.dataLayer = window.dataLayer || [];\n function gtag(){window.dataLayer.push(arguments);}\n gtag('js', new Date());\n\n gtag('config', '".concat(id, "', { 'send_page_view': false });\n ") }))] }));
|
|
37
33
|
};
|
package/Auth/helpers.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { isString } from "@koine/utils";
|
|
2
|
-
export
|
|
2
|
+
export var AUTH_ROUTES = {
|
|
3
3
|
login: process.env["AUTH_ROUTE_LOGIN"],
|
|
4
4
|
profile: process.env["AUTH_ROUTE_PROFILE"],
|
|
5
5
|
register: process.env["AUTH_ROUTE_REGISTER"],
|
|
6
6
|
secured: JSON.parse(process.env["AUTH_ROUTES_SECURED"] || "[]"),
|
|
7
7
|
};
|
|
8
8
|
export function getAuthRoutes(t) {
|
|
9
|
-
return Object.keys(AUTH_ROUTES).reduce((map, name)
|
|
10
|
-
|
|
9
|
+
return Object.keys(AUTH_ROUTES).reduce(function (map, name) {
|
|
10
|
+
var routePage = AUTH_ROUTES[name];
|
|
11
11
|
// @ts-expect-error cannot remember
|
|
12
|
-
map[name] = isString(routePage) ? t(
|
|
12
|
+
map[name] = isString(routePage) ? t("~:".concat(AUTH_ROUTES[name])) : routePage;
|
|
13
13
|
return map;
|
|
14
14
|
}, {});
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* @param url e.g. "http://localhost:3000/signin?callbackUrl=http://localhost:3000/profile"
|
|
18
18
|
*/
|
|
19
|
-
export function getCallbackUrl(url
|
|
19
|
+
export function getCallbackUrl(url) {
|
|
20
|
+
if (url === void 0) { url = window.location.href; }
|
|
20
21
|
return url.split("callbackUrl=")[1] || "";
|
|
21
22
|
}
|
package/Auth/useLogin.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { useState, useCallback } from "react";
|
|
2
3
|
import { useRouter } from "next/router";
|
|
3
4
|
import { signIn } from "next-auth/react";
|
|
@@ -5,27 +6,25 @@ import { parseURL } from "@koine/utils";
|
|
|
5
6
|
import { useT } from "../I18n";
|
|
6
7
|
import { getAuthRoutes, getCallbackUrl } from "./helpers";
|
|
7
8
|
export function useLogin() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
var t = useT();
|
|
10
|
+
var push = useRouter().push;
|
|
11
|
+
var _a = useState(false), loading = _a[0], setLoading = _a[1];
|
|
12
|
+
var _b = useState(false), ok = _b[0], setOk = _b[1];
|
|
13
|
+
var _c = useState(false), fail = _c[0], setFail = _c[1];
|
|
14
|
+
var submit = useCallback(function (data) {
|
|
14
15
|
setLoading(true);
|
|
15
|
-
signIn("credentials", {
|
|
16
|
-
...data,
|
|
17
|
-
redirect: false,
|
|
18
|
-
})
|
|
16
|
+
signIn("credentials", __assign(__assign({}, data), { redirect: false }))
|
|
19
17
|
// @ts-expect-error FIXME: at some point...
|
|
20
|
-
.then((
|
|
18
|
+
.then(function (_a) {
|
|
19
|
+
var ok = _a.ok;
|
|
21
20
|
setLoading(false);
|
|
22
21
|
setOk(ok);
|
|
23
22
|
setFail(!ok);
|
|
24
23
|
if (ok) {
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
var redirectUrl = parseURL(getCallbackUrl());
|
|
25
|
+
var _b = getAuthRoutes(t), login = _b.login, register = _b.register, profile = _b.profile;
|
|
27
26
|
if (redirectUrl) {
|
|
28
|
-
|
|
27
|
+
var redirectPath = redirectUrl.pathname;
|
|
29
28
|
if (profile &&
|
|
30
29
|
(redirectPath === login || redirectPath === register)) {
|
|
31
30
|
push(profile);
|
|
@@ -42,9 +41,9 @@ export function useLogin() {
|
|
|
42
41
|
}, [t, push]);
|
|
43
42
|
// TODO: useMemo ?
|
|
44
43
|
return {
|
|
45
|
-
submit,
|
|
46
|
-
loading,
|
|
47
|
-
ok,
|
|
48
|
-
fail,
|
|
44
|
+
submit: submit,
|
|
45
|
+
loading: loading,
|
|
46
|
+
ok: ok,
|
|
47
|
+
fail: fail,
|
|
49
48
|
};
|
|
50
49
|
}
|
package/Auth/useLoginUrl.js
CHANGED
|
@@ -2,10 +2,10 @@ import { useEffect, useState } from "react";
|
|
|
2
2
|
import { useT } from "../I18n";
|
|
3
3
|
import { getAuthRoutes } from "./helpers";
|
|
4
4
|
export function useLoginUrl() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
useEffect(()
|
|
8
|
-
setCurrentUrl(
|
|
5
|
+
var _a = useState(""), currentUrl = _a[0], setCurrentUrl = _a[1];
|
|
6
|
+
var t = useT();
|
|
7
|
+
useEffect(function () {
|
|
8
|
+
setCurrentUrl("?callbackUrl=".concat(window.location.href));
|
|
9
9
|
}, []);
|
|
10
|
-
return
|
|
10
|
+
return "".concat(getAuthRoutes(t).login).concat(currentUrl);
|
|
11
11
|
}
|
package/Auth/useLogout.js
CHANGED
|
@@ -5,31 +5,31 @@ import { parseURL } from "@koine/utils";
|
|
|
5
5
|
import { useT } from "../I18n";
|
|
6
6
|
import { getAuthRoutes, getCallbackUrl } from "./helpers";
|
|
7
7
|
export function useLogout() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
var t = useT();
|
|
9
|
+
var push = useRouter().push;
|
|
10
|
+
var _a = useState(false), loading = _a[0], setLoading = _a[1];
|
|
11
|
+
var _b = useState(false), ok = _b[0], setOk = _b[1];
|
|
12
|
+
var fail = useState(false)[0];
|
|
13
|
+
var submit = useCallback(function (event) {
|
|
14
14
|
event.preventDefault();
|
|
15
15
|
event.stopPropagation();
|
|
16
16
|
setLoading(true);
|
|
17
|
-
signOut({ redirect: false }).then(()
|
|
17
|
+
signOut({ redirect: false }).then(function () {
|
|
18
18
|
setLoading(false);
|
|
19
19
|
setOk(true);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
var redirectUrl = parseURL(getCallbackUrl());
|
|
21
|
+
var currentUrl = parseURL(window.location.href);
|
|
22
|
+
var secured = getAuthRoutes(t).secured;
|
|
23
|
+
var signin = t("~:/signin");
|
|
24
|
+
var profile = t("~:/profile");
|
|
25
|
+
var targetUrl = redirectUrl || currentUrl;
|
|
26
|
+
var redirect = "";
|
|
27
27
|
if (targetUrl) {
|
|
28
28
|
if (targetUrl.pathname === profile) {
|
|
29
29
|
redirect = signin;
|
|
30
30
|
}
|
|
31
31
|
else if (secured) {
|
|
32
|
-
for (
|
|
32
|
+
for (var i = 0; i < secured.length; i++) {
|
|
33
33
|
if (targetUrl.pathname.match(secured[i])) {
|
|
34
34
|
redirect = signin;
|
|
35
35
|
break;
|
|
@@ -44,9 +44,9 @@ export function useLogout() {
|
|
|
44
44
|
}, [t, push]);
|
|
45
45
|
// TODO: useMemo ?
|
|
46
46
|
return {
|
|
47
|
-
submit,
|
|
48
|
-
loading,
|
|
49
|
-
ok,
|
|
50
|
-
fail,
|
|
47
|
+
submit: submit,
|
|
48
|
+
loading: loading,
|
|
49
|
+
ok: ok,
|
|
50
|
+
fail: fail,
|
|
51
51
|
};
|
|
52
52
|
}
|
package/Favicon/Favicon.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import Head from "next/head";
|
|
3
4
|
import { FaviconTags } from "@koine/react";
|
|
4
|
-
export
|
|
5
|
+
export var Favicon = function (props) { return (_jsx(Head, { children: _jsx(FaviconTags, __assign({}, props)) })); };
|
package/Forms/useForm.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { useMemo } from "react";
|
|
2
3
|
import { useForm as _useForm } from "react-hook-form";
|
|
3
4
|
import { yupResolver as resolver } from "@hookform/resolvers/yup";
|
|
4
5
|
import { useT } from "../I18n";
|
|
5
6
|
export function useForm(
|
|
6
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
-
schema, i18nNamespace, formProps
|
|
8
|
-
|
|
8
|
+
schema, i18nNamespace, formProps, debug) {
|
|
9
|
+
if (formProps === void 0) { formProps = {}; }
|
|
10
|
+
var t = useT(i18nNamespace);
|
|
9
11
|
// const form = _useForm<InferType<ObjectSchema<T, object>>>({
|
|
10
|
-
|
|
12
|
+
var form = _useForm(__assign({
|
|
11
13
|
// @ts-expect-error FIXME:
|
|
12
|
-
resolver: resolver(schema),
|
|
13
|
-
// make the form behave more closer as native:
|
|
14
|
-
// shouldUnregister: true,
|
|
15
|
-
...formProps,
|
|
16
|
-
});
|
|
14
|
+
resolver: resolver(schema) }, formProps));
|
|
17
15
|
// const { control, register, setValue } = form;
|
|
18
16
|
// const field = { control, register, setValue, t };
|
|
19
17
|
// if (process.env["NODE_ENV"] !== "production") {
|
|
@@ -29,9 +27,9 @@ schema, i18nNamespace, formProps = {}, debug) {
|
|
|
29
27
|
// if (formProps.mode === "onChange") {
|
|
30
28
|
// return { field, ...form };
|
|
31
29
|
// }
|
|
32
|
-
return useMemo(()
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return { field,
|
|
30
|
+
return useMemo(function () {
|
|
31
|
+
var control = form.control, register = form.register, setValue = form.setValue;
|
|
32
|
+
var field = { control: control, register: register, setValue: setValue, t: t };
|
|
33
|
+
return __assign({ field: field }, form);
|
|
36
34
|
}, [t, form]);
|
|
37
35
|
}
|
package/Forms/useSubmit.js
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
|
+
import { __assign, __awaiter, __generator } from "tslib";
|
|
1
2
|
import { useAsyncFn } from "@koine/react";
|
|
2
3
|
import { api } from "../utils/api";
|
|
3
4
|
export function useSubmit(url, transformData) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
var _this = this;
|
|
6
|
+
var _a = useAsyncFn(function (json) { return __awaiter(_this, void 0, void 0, function () {
|
|
7
|
+
var response;
|
|
8
|
+
return __generator(this, function (_a) {
|
|
9
|
+
switch (_a.label) {
|
|
10
|
+
case 0:
|
|
11
|
+
if (transformData)
|
|
12
|
+
json = transformData(json);
|
|
13
|
+
return [4 /*yield*/, api.post(url, {
|
|
14
|
+
json: json,
|
|
15
|
+
})];
|
|
16
|
+
case 1:
|
|
17
|
+
response = _a.sent();
|
|
18
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
19
|
+
console.log("[@koine/next] useSubmit response", response);
|
|
20
|
+
}
|
|
21
|
+
return [2 /*return*/, response];
|
|
22
|
+
}
|
|
9
23
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}, [url, transformData]);
|
|
15
|
-
const { loading, error, value } = state;
|
|
16
|
-
const fail = !loading && (!!error || value?.fail);
|
|
17
|
-
return {
|
|
18
|
-
submit,
|
|
19
|
-
loading,
|
|
20
|
-
...(value || {}),
|
|
21
|
-
fail,
|
|
22
|
-
};
|
|
24
|
+
}); }, [url, transformData]), state = _a[0], submit = _a[1];
|
|
25
|
+
var loading = state.loading, error = state.error, value = state.value;
|
|
26
|
+
var fail = !loading && (!!error || (value === null || value === void 0 ? void 0 : value.fail));
|
|
27
|
+
return __assign(__assign({ submit: submit, loading: loading }, (value || {})), { fail: fail });
|
|
23
28
|
}
|
package/I18n/I18n.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="@koine/next/typings" />
|
|
2
|
+
import { __assign } from "tslib";
|
|
2
3
|
/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
|
|
3
4
|
/**
|
|
4
5
|
* @file
|
|
@@ -19,7 +20,7 @@ export { default as T } from "next-translate/Trans";
|
|
|
19
20
|
* @see https://github.com/vinissimus/next-translate/issues/513#issuecomment-779826418
|
|
20
21
|
*/
|
|
21
22
|
export function useT(namespace) {
|
|
22
|
-
|
|
23
|
+
var t = useTranslation().t;
|
|
23
24
|
// const typedT = <
|
|
24
25
|
// // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
25
26
|
// R extends unknown = string,
|
|
@@ -41,33 +42,53 @@ export function useT(namespace) {
|
|
|
41
42
|
// // ) as R extends (undefined | never | unknown) ? TranslateReturn<TranslationQuery, TranslationOptions> : R;
|
|
42
43
|
// ) as R;
|
|
43
44
|
// return typedT;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
var tMemoized = useMemo(function () {
|
|
46
|
+
return function (s, q, o) {
|
|
47
|
+
return t(namespace ? "".concat(namespace, ":").concat(s) : s, q === "obj" ? null : q, q === "obj" || o === "obj" ? { returnObjects: true } : o
|
|
48
|
+
// ) as R extends (undefined | never | unknown) ? TranslateReturn<TranslationQuery, TranslationOptions> : R;
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
}, [t, namespace]);
|
|
47
52
|
// return tMemoized as Translate<N>;
|
|
48
53
|
return tMemoized;
|
|
49
54
|
}
|
|
50
55
|
export function translationAsOptions(t, i18nKey) {
|
|
51
|
-
|
|
56
|
+
var dictionary = t(i18nKey, undefined, {
|
|
52
57
|
returnObjects: true,
|
|
53
58
|
});
|
|
54
|
-
return Object.keys(dictionary).map((key)
|
|
59
|
+
return Object.keys(dictionary).map(function (key) { return ({
|
|
55
60
|
value: key,
|
|
56
61
|
label: dictionary[key],
|
|
57
|
-
}));
|
|
62
|
+
}); });
|
|
58
63
|
}
|
|
59
64
|
/**
|
|
60
65
|
* Automatically returns the `date-fns/format` function with the right locale
|
|
61
66
|
* passed as option (grabbed from next router value).
|
|
62
67
|
*/
|
|
63
|
-
export
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
export var useDateFormat = function () {
|
|
69
|
+
var _a = useState(function () {
|
|
70
|
+
return function () {
|
|
71
|
+
var args = [];
|
|
72
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
73
|
+
args[_i] = arguments[_i];
|
|
74
|
+
}
|
|
75
|
+
return format.apply(void 0, args);
|
|
76
|
+
};
|
|
77
|
+
}), formatter = _a[0], setFormatter = _a[1];
|
|
78
|
+
var router = useRouter();
|
|
79
|
+
var locale = useDateLocale(router.locale);
|
|
80
|
+
useEffect(function () {
|
|
68
81
|
if (locale) {
|
|
69
|
-
|
|
70
|
-
setFormatter(
|
|
82
|
+
var newFormatter_1 = function (date, _format, options) { return format(date, _format, __assign(__assign({}, (options || {})), { locale: locale })); };
|
|
83
|
+
setFormatter(function () {
|
|
84
|
+
return function () {
|
|
85
|
+
var args = [];
|
|
86
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
87
|
+
args[_i] = arguments[_i];
|
|
88
|
+
}
|
|
89
|
+
return newFormatter_1.apply(void 0, args);
|
|
90
|
+
};
|
|
91
|
+
});
|
|
71
92
|
}
|
|
72
93
|
}, [locale]);
|
|
73
94
|
return formatter;
|
package/Img/Img.js
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
1
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import { useState } from "react";
|
|
3
4
|
import NextImage from "next/image";
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return nextImgProps.priority ? (_jsx(NextImage, {
|
|
5
|
+
export var NextImg = NextImage;
|
|
6
|
+
export var NextImgSmart = function (props) {
|
|
7
|
+
var _a = useState(false), $loaded = _a[0], setLoaded = _a[1];
|
|
8
|
+
var _b = useState(false), $error = _b[0], setError = _b[1];
|
|
9
|
+
var _c = getNextImgProps(props), nextImgProps = _c.nextImgProps, restProps = _c.restProps;
|
|
10
|
+
var Wrap = restProps.Wrap;
|
|
11
|
+
return nextImgProps.priority ? (_jsx(NextImage, __assign({}, nextImgProps))) : (_jsx(Wrap, __assign({}, restProps, { "$loaded": $loaded, "$error": $error }, { children: _jsx(NextImage, __assign({}, nextImgProps, { onLoadingComplete: function () { return setLoaded(true); }, onError: function () { return setError(true); } })) })));
|
|
11
12
|
};
|
|
12
|
-
export function getNextImgProps(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
export function getNextImgProps(_a) {
|
|
14
|
+
var src = _a.src, alt = _a.alt, layout = _a.layout, blurDataURL = _a.blurDataURL, width = _a.width, height = _a.height, priority = _a.priority, objectFit = _a.objectFit, objectPosition = _a.objectPosition, restProps = __rest(_a, ["src", "alt", "layout", "blurDataURL", "width", "height", "priority", "objectFit", "objectPosition"]);
|
|
15
|
+
var nextImgProps = {
|
|
16
|
+
src: src,
|
|
17
|
+
alt: alt,
|
|
18
|
+
layout: layout,
|
|
19
|
+
blurDataURL: blurDataURL,
|
|
20
|
+
width: width,
|
|
21
|
+
height: height,
|
|
22
|
+
priority: priority,
|
|
23
|
+
objectFit: objectFit,
|
|
24
|
+
objectPosition: objectPosition,
|
|
23
25
|
};
|
|
24
26
|
return {
|
|
25
|
-
nextImgProps,
|
|
26
|
-
restProps,
|
|
27
|
+
nextImgProps: nextImgProps,
|
|
28
|
+
restProps: restProps,
|
|
27
29
|
};
|
|
28
30
|
}
|
package/Link/Link.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
1
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import { forwardRef } from "react";
|
|
3
4
|
import NextLink from "next/link";
|
|
4
5
|
/**
|
|
5
6
|
* @see https://next.js.org/docs/api-reference/next/link
|
|
6
7
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
8
|
+
export var Link = forwardRef(function Link(_a, ref) {
|
|
9
|
+
var href = _a.href, prefetch = _a.prefetch, replace = _a.replace, scroll = _a.scroll, shallow = _a.shallow, locale = _a.locale, _b = _a.Link, Link = _b === void 0 ? "span" : _b, props = __rest(_a, ["href", "prefetch", "replace", "scroll", "shallow", "locale", "Link"]);
|
|
10
|
+
return (_jsx(NextLink, __assign({ href: href, replace: replace, scroll: scroll, shallow: shallow, locale: locale, passHref: true }, { children: _jsx(Link, __assign({ ref: ref }, props)) })));
|
|
9
11
|
});
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { useRouter } from "next/router";
|
|
4
|
-
export
|
|
5
|
-
|
|
4
|
+
export var NextProgress = function (_a) {
|
|
5
|
+
var _b = _a.startAt, startAt = _b === void 0 ? 0.3 : _b, _c = _a.showOnShallow, showOnShallow = _c === void 0 ? true : _c, _d = _a.stopDelayMs, stopDelayMs = _d === void 0 ? 200 : _d, _e = _a.Overlay, Overlay = _e === void 0 ? "div" : _e;
|
|
6
|
+
var events = useRouter().events;
|
|
6
7
|
// const [progress, setProgress] = useState(0);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
var _f = useState(false), running = _f[0], setRunning = _f[1];
|
|
9
|
+
var timer = useRef(null);
|
|
10
|
+
var routeChangeStart = useCallback(function (_, _a) {
|
|
11
|
+
var shallow = _a.shallow;
|
|
10
12
|
if (!shallow || showOnShallow) {
|
|
11
13
|
// setProgress(startAt);
|
|
12
14
|
setRunning(true);
|
|
13
15
|
}
|
|
14
16
|
}, [showOnShallow]);
|
|
15
|
-
|
|
17
|
+
var routeChangeEnd = useCallback(function (_, _a) {
|
|
18
|
+
var shallow = _a.shallow;
|
|
16
19
|
if (!shallow || showOnShallow) {
|
|
17
20
|
if (timer.current) {
|
|
18
21
|
clearTimeout(timer.current);
|
|
19
22
|
}
|
|
20
|
-
timer.current = setTimeout(()
|
|
23
|
+
timer.current = setTimeout(function () {
|
|
21
24
|
// setProgress(100);
|
|
22
25
|
setRunning(false);
|
|
23
26
|
}, stopDelayMs);
|
|
24
27
|
}
|
|
25
28
|
}, [showOnShallow, stopDelayMs, timer]);
|
|
26
|
-
useEffect(()
|
|
29
|
+
useEffect(function () {
|
|
27
30
|
events.on("routeChangeStart", routeChangeStart);
|
|
28
31
|
events.on("routeChangeComplete", routeChangeEnd);
|
|
29
32
|
events.on("routeChangeError", routeChangeEnd);
|
|
30
|
-
return ()
|
|
33
|
+
return function () {
|
|
31
34
|
events.off("routeChangeStart", routeChangeStart);
|
|
32
35
|
events.off("routeChangeComplete", routeChangeEnd);
|
|
33
36
|
events.off("routeChangeError", routeChangeEnd);
|
package/Seo/Seo.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { memo } from "react";
|
|
3
3
|
import Head from "next/head";
|
|
4
4
|
import { buildTags } from "./helpers";
|
|
5
|
-
|
|
5
|
+
var _Seo = function (props) {
|
|
6
6
|
return _jsx(Head, { children: buildTags(props) });
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export var Seo = memo(_Seo);
|
package/Seo/SeoDefaults.js
CHANGED
|
@@ -4,9 +4,9 @@ import Head from "next/head";
|
|
|
4
4
|
// import { useRouter } from "next/router";
|
|
5
5
|
// import { getSiteUrl } from "../utils";
|
|
6
6
|
import { buildTags } from "./helpers";
|
|
7
|
-
|
|
7
|
+
var _SeoDefaults = function (props) {
|
|
8
8
|
// const router = useRouter();
|
|
9
9
|
// props.openGraph.url = getSiteUrl(router.asPath);
|
|
10
10
|
return _jsx(Head, { children: buildTags(props) });
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export var SeoDefaults = memo(_SeoDefaults);
|