@koine/next 1.0.9 → 1.0.10
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/package.json +30 -2
- package/Analytics/AnalyticsGoogle.d.ts +0 -5
- package/Analytics/AnalyticsGoogle.js +0 -37
- package/Analytics/index.d.ts +0 -1
- package/Analytics/index.js +0 -1
- package/Analytics/package.json +0 -6
- package/Auth/helpers.d.ts +0 -17
- package/Auth/helpers.js +0 -21
- package/Auth/index.d.ts +0 -4
- package/Auth/index.js +0 -4
- package/Auth/package.json +0 -6
- package/Auth/useLogin.d.ts +0 -7
- package/Auth/useLogin.js +0 -50
- package/Auth/useLoginUrl.d.ts +0 -1
- package/Auth/useLoginUrl.js +0 -11
- package/Auth/useLogout.d.ts +0 -6
- package/Auth/useLogout.js +0 -52
- package/Favicon/Favicon.d.ts +0 -3
- package/Favicon/Favicon.js +0 -4
- package/Favicon/index.d.ts +0 -1
- package/Favicon/index.js +0 -1
- package/Favicon/package.json +0 -6
- package/Forms/index.d.ts +0 -2
- package/Forms/index.js +0 -2
- package/Forms/package.json +0 -6
- package/Forms/useForm.d.ts +0 -32
- package/Forms/useForm.js +0 -37
- package/Forms/useSubmit.d.ts +0 -24
- package/Forms/useSubmit.js +0 -23
- package/Head/Head.d.ts +0 -1
- package/Head/Head.js +0 -1
- package/Head/index.d.ts +0 -1
- package/Head/index.js +0 -1
- package/Head/package.json +0 -6
- package/I18n/I18n.d.ts +0 -44
- package/I18n/I18n.js +0 -74
- package/I18n/index.d.ts +0 -1
- package/I18n/index.js +0 -1
- package/I18n/package.json +0 -6
- package/Img/Img.d.ts +0 -21
- package/Img/Img.js +0 -28
- package/Img/index.d.ts +0 -1
- package/Img/index.js +0 -1
- package/Img/package.json +0 -6
- package/Link/Link.d.ts +0 -9
- package/Link/Link.js +0 -9
- package/Link/index.d.ts +0 -1
- package/Link/index.js +0 -1
- package/Link/package.json +0 -6
- package/NextProgress/NextProgress.d.ts +0 -24
- package/NextProgress/NextProgress.js +0 -37
- package/NextProgress/index.d.ts +0 -2
- package/NextProgress/index.js +0 -1
- package/NextProgress/package.json +0 -6
- package/Seo/Seo.d.ts +0 -3
- package/Seo/Seo.js +0 -8
- package/Seo/SeoDefaults.d.ts +0 -3
- package/Seo/SeoDefaults.js +0 -12
- package/Seo/helpers.d.ts +0 -48
- package/Seo/helpers.js +0 -111
- package/Seo/index.d.ts +0 -12
- package/Seo/index.js +0 -12
- package/Seo/package.json +0 -6
- package/Theme/Theme.d.ts +0 -46
- package/Theme/Theme.js +0 -235
- package/Theme/index.d.ts +0 -1
- package/Theme/index.js +0 -1
- package/Theme/package.json +0 -6
- package/app/AppHead.d.ts +0 -2
- package/app/AppHead.js +0 -5
- package/app/AppMain.d.ts +0 -35
- package/app/AppMain.js +0 -1
- package/app/css/AppMain.d.ts +0 -8
- package/app/css/AppMain.js +0 -11
- package/app/css/AppTheme.d.ts +0 -10
- package/app/css/AppTheme.js +0 -12
- package/app/css/auth/index.d.ts +0 -9
- package/app/css/auth/index.js +0 -13
- package/app/css/auth/package.json +0 -6
- package/app/css/index.d.ts +0 -54
- package/app/css/index.js +0 -57
- package/app/css/package.json +0 -6
- package/app/em/AppMain.d.ts +0 -10
- package/app/em/AppMain.js +0 -22
- package/app/em/AppTheme.d.ts +0 -15
- package/app/em/AppTheme.js +0 -17
- package/app/em/auth/index.d.ts +0 -9
- package/app/em/auth/index.js +0 -13
- package/app/em/auth/package.json +0 -6
- package/app/em/index.d.ts +0 -9
- package/app/em/index.js +0 -12
- package/app/em/package.json +0 -6
- package/app/index.d.ts +0 -2
- package/app/index.js +0 -2
- package/app/package.json +0 -6
- package/app/sc/AppMain.d.ts +0 -10
- package/app/sc/AppMain.js +0 -22
- package/app/sc/AppTheme.d.ts +0 -13
- package/app/sc/AppTheme.js +0 -9
- package/app/sc/auth/index.d.ts +0 -9
- package/app/sc/auth/index.js +0 -13
- package/app/sc/auth/package.json +0 -6
- package/app/sc/index.d.ts +0 -56
- package/app/sc/index.js +0 -59
- package/app/sc/package.json +0 -6
- package/config/index.d.ts +0 -71
- package/config/index.js +0 -174
- package/config/package.json +0 -6
- package/document/Document.d.ts +0 -15
- package/document/Document.js +0 -19
- package/document/css/index.d.ts +0 -22
- package/document/css/index.js +0 -30
- package/document/css/package.json +0 -6
- package/document/em/index.d.ts +0 -16
- package/document/em/index.js +0 -68
- package/document/em/package.json +0 -6
- package/document/index.d.ts +0 -2
- package/document/index.js +0 -2
- package/document/package.json +0 -6
- package/document/sc/index.d.ts +0 -20
- package/document/sc/index.js +0 -44
- package/document/sc/package.json +0 -6
- package/index.d.ts +0 -12
- package/index.js +0 -12
- 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
- package/utils/api.d.ts +0 -55
- package/utils/api.js +0 -35
- package/utils/emotion-cache.d.ts +0 -5
- package/utils/emotion-cache.js +0 -8
- package/utils/index.d.ts +0 -19
- package/utils/index.js +0 -26
- package/utils/package.json +0 -6
package/document/index.js
DELETED
package/document/package.json
DELETED
package/document/sc/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import NextDocument, { DocumentContext, DocumentInitialProps } from "next/document";
|
|
3
|
-
/**
|
|
4
|
-
* Next Document wrapper for `styled-components` based projects
|
|
5
|
-
*
|
|
6
|
-
* For typescript safety of this component
|
|
7
|
-
* @see https://bit.ly/3ceuF8m
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
*
|
|
11
|
-
* in your `myapp/pages/_document.tsx`:
|
|
12
|
-
* ```tsx
|
|
13
|
-
* export { Document as default } from "@koine/next/document/sc";
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare class Document extends NextDocument {
|
|
17
|
-
static getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps>;
|
|
18
|
-
render(): JSX.Element;
|
|
19
|
-
}
|
|
20
|
-
export default Document;
|
package/document/sc/index.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React from "react";
|
|
3
|
-
/* ? eslint-disable @next/next/no-document-import-in-page */
|
|
4
|
-
import NextDocument, { Html, Head, Main, NextScript, } from "next/document";
|
|
5
|
-
import { Meta, NoJs } from "@koine/react";
|
|
6
|
-
import { ServerStyleSheet } from "styled-components";
|
|
7
|
-
/**
|
|
8
|
-
* Next Document wrapper for `styled-components` based projects
|
|
9
|
-
*
|
|
10
|
-
* For typescript safety of this component
|
|
11
|
-
* @see https://bit.ly/3ceuF8m
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
*
|
|
15
|
-
* in your `myapp/pages/_document.tsx`:
|
|
16
|
-
* ```tsx
|
|
17
|
-
* export { Document as default } from "@koine/next/document/sc";
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export class Document extends NextDocument {
|
|
21
|
-
static async getInitialProps(ctx) {
|
|
22
|
-
const sheet = new ServerStyleSheet();
|
|
23
|
-
const originalRenderPage = ctx.renderPage;
|
|
24
|
-
try {
|
|
25
|
-
ctx.renderPage = () => originalRenderPage({
|
|
26
|
-
enhanceApp: (App) => (props) => sheet.collectStyles(_jsx(App, { ...props })),
|
|
27
|
-
});
|
|
28
|
-
const initialProps = await NextDocument.getInitialProps(ctx);
|
|
29
|
-
return {
|
|
30
|
-
...initialProps,
|
|
31
|
-
// @ts-expect-error FIXME: have they changed type?
|
|
32
|
-
styles: (_jsxs(React.Fragment, { children: [initialProps.styles, sheet.getStyleElement()] })),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
finally {
|
|
36
|
-
sheet.seal();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
render() {
|
|
40
|
-
const { locale, defaultLocale } = this.props.__NEXT_DATA__;
|
|
41
|
-
return (_jsxs(Html, { lang: locale || defaultLocale, className: "no-js", children: [_jsxs(Head, { children: [_jsx(Meta, {}), _jsx(NoJs, {})] }), _jsxs("body", { children: [_jsx(Main, {}), _jsx(NextScript, {})] })] }));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
export default Document;
|
package/document/sc/package.json
DELETED
package/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from "./Analytics";
|
|
2
|
-
export * from "./Auth";
|
|
3
|
-
export * from "./Favicon";
|
|
4
|
-
export * from "./Forms";
|
|
5
|
-
export * from "./Head";
|
|
6
|
-
export * from "./I18n";
|
|
7
|
-
export * from "./Img";
|
|
8
|
-
export * from "./Link";
|
|
9
|
-
export * from "./NextProgress";
|
|
10
|
-
export * from "./Seo";
|
|
11
|
-
export * from "./Theme";
|
|
12
|
-
export * from "./utils";
|
package/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from "./Analytics";
|
|
2
|
-
export * from "./Auth";
|
|
3
|
-
export * from "./Favicon";
|
|
4
|
-
export * from "./Forms";
|
|
5
|
-
export * from "./Head";
|
|
6
|
-
export * from "./I18n";
|
|
7
|
-
export * from "./Img";
|
|
8
|
-
export * from "./Link";
|
|
9
|
-
export * from "./NextProgress";
|
|
10
|
-
export * from "./Seo";
|
|
11
|
-
export * from "./Theme";
|
|
12
|
-
export * from "./utils";
|
|
@@ -1,42 +0,0 @@
|
|
|
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;
|
package/node/Analytics/index.js
DELETED
package/node/Auth/helpers.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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;
|
package/node/Auth/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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);
|
package/node/Auth/useLogin.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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;
|
package/node/Auth/useLoginUrl.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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;
|
package/node/Auth/useLogout.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
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;
|
package/node/Favicon/Favicon.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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;
|
package/node/Favicon/index.js
DELETED
package/node/Forms/index.js
DELETED
package/node/Forms/useForm.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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;
|
package/node/Forms/useSubmit.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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;
|
package/node/Head/Head.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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; } });
|
package/node/Head/index.js
DELETED
package/node/I18n/I18n.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
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;
|
package/node/I18n/index.js
DELETED
package/node/Img/Img.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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;
|
package/node/Img/index.js
DELETED
package/node/Link/Link.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
});
|
package/node/Link/index.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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;
|
|
@@ -1,5 +0,0 @@
|
|
|
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; } });
|
package/node/Seo/Seo.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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);
|