@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.
- package/Analytics/AnalyticsGoogle.d.ts +5 -6
- package/Analytics/AnalyticsGoogle.js +37 -0
- package/Analytics/index.d.ts +1 -1
- package/Analytics/index.js +1 -0
- package/Analytics/package.json +6 -0
- package/Auth/helpers.d.ts +17 -17
- package/Auth/helpers.js +21 -0
- package/Auth/index.d.ts +4 -4
- package/Auth/index.js +4 -0
- package/Auth/package.json +6 -0
- package/Auth/useLogin.d.ts +7 -7
- package/Auth/useLogin.js +50 -0
- package/Auth/useLoginUrl.d.ts +1 -1
- package/Auth/useLoginUrl.js +11 -0
- package/Auth/useLogout.d.ts +6 -6
- package/Auth/useLogout.js +52 -0
- package/Favicon/Favicon.d.ts +3 -4
- package/Favicon/Favicon.js +4 -0
- package/Favicon/index.d.ts +1 -1
- package/Favicon/index.js +1 -0
- package/Favicon/package.json +6 -0
- package/Forms/index.d.ts +2 -2
- package/Forms/index.js +2 -0
- package/Forms/package.json +6 -0
- package/Forms/useForm.d.ts +32 -32
- package/Forms/useForm.js +37 -0
- package/Forms/useSubmit.d.ts +24 -24
- package/Forms/useSubmit.js +23 -0
- package/Head/Head.d.ts +1 -1
- package/Head/Head.js +1 -0
- package/Head/index.d.ts +1 -1
- package/Head/index.js +1 -0
- package/Head/package.json +6 -0
- package/I18n/I18n.d.ts +44 -48
- package/I18n/I18n.js +74 -0
- package/I18n/index.d.ts +1 -1
- package/I18n/index.js +1 -0
- package/I18n/package.json +6 -0
- package/Img/Img.d.ts +21 -21
- package/Img/Img.js +28 -0
- package/Img/index.d.ts +1 -1
- package/Img/index.js +1 -0
- package/Img/package.json +6 -0
- package/Link/Link.d.ts +9 -8
- package/Link/Link.js +9 -0
- package/Link/index.d.ts +1 -1
- package/Link/index.js +1 -0
- package/Link/package.json +6 -0
- package/NextProgress/NextProgress.d.ts +24 -14
- package/NextProgress/NextProgress.js +37 -0
- package/NextProgress/index.d.ts +2 -1
- package/NextProgress/index.js +1 -0
- package/NextProgress/package.json +6 -0
- package/README.md +0 -0
- package/Seo/Seo.d.ts +3 -3
- package/Seo/Seo.js +8 -0
- package/Seo/SeoDefaults.d.ts +3 -3
- package/Seo/SeoDefaults.js +12 -0
- package/Seo/helpers.d.ts +48 -48
- package/Seo/helpers.js +111 -0
- package/Seo/index.d.ts +12 -12
- package/Seo/index.js +12 -0
- package/Seo/package.json +6 -0
- package/Theme/Theme.d.ts +46 -46
- package/Theme/Theme.js +235 -0
- package/Theme/index.d.ts +1 -1
- package/Theme/index.js +1 -0
- package/Theme/package.json +6 -0
- package/app/AppHead.d.ts +2 -3
- package/app/AppHead.js +5 -0
- package/app/AppMain.d.ts +35 -34
- package/app/AppMain.js +1 -0
- package/app/css/AppMain.d.ts +8 -0
- package/app/css/AppMain.js +11 -0
- package/app/css/AppTheme.d.ts +10 -0
- package/app/css/AppTheme.js +12 -0
- package/app/css/auth/index.d.ts +9 -0
- package/app/css/auth/index.js +13 -0
- package/app/css/auth/package.json +6 -0
- package/app/css/index.d.ts +54 -0
- package/app/css/index.js +57 -0
- package/app/css/package.json +6 -0
- package/app/em/AppMain.d.ts +10 -0
- package/app/em/AppMain.js +22 -0
- package/app/{AppTheme--emotion.d.ts → em/AppTheme.d.ts} +15 -15
- package/app/em/AppTheme.js +17 -0
- package/app/em/auth/index.d.ts +9 -0
- package/app/em/auth/index.js +13 -0
- package/app/em/auth/package.json +6 -0
- package/app/em/index.d.ts +9 -0
- package/app/em/index.js +12 -0
- package/app/em/package.json +6 -0
- package/app/index.d.ts +2 -11
- package/app/index.js +2 -0
- package/app/package.json +6 -0
- package/app/sc/AppMain.d.ts +10 -0
- package/app/sc/AppMain.js +22 -0
- package/app/sc/AppTheme.d.ts +13 -0
- package/app/sc/AppTheme.js +9 -0
- package/app/sc/auth/index.d.ts +9 -0
- package/app/sc/auth/index.js +13 -0
- package/app/sc/auth/package.json +6 -0
- package/app/sc/index.d.ts +56 -0
- package/app/sc/index.js +59 -0
- package/app/sc/package.json +6 -0
- package/config/index.d.ts +71 -58
- package/config/index.js +174 -0
- package/config/package.json +6 -0
- package/document/Document.d.ts +15 -10
- package/document/Document.js +19 -0
- package/document/css/index.d.ts +22 -0
- package/document/css/index.js +30 -0
- package/document/css/package.json +6 -0
- package/document/em/index.d.ts +16 -0
- package/document/em/index.js +68 -0
- package/document/em/package.json +6 -0
- package/document/index.d.ts +2 -4
- package/document/index.js +2 -0
- package/document/package.json +6 -0
- package/document/{Document--sc.d.ts → sc/index.d.ts} +20 -11
- package/document/sc/index.js +44 -0
- package/document/sc/package.json +6 -0
- package/index.d.ts +12 -12
- package/index.js +12 -743
- package/node/Analytics/AnalyticsGoogle.js +42 -0
- package/node/Analytics/index.js +4 -0
- package/node/Auth/helpers.js +26 -0
- package/node/Auth/index.js +7 -0
- package/node/Auth/useLogin.js +54 -0
- package/node/Auth/useLoginUrl.js +15 -0
- package/node/Auth/useLogout.js +56 -0
- package/node/Favicon/Favicon.js +9 -0
- package/node/Favicon/index.js +4 -0
- package/node/Forms/index.js +5 -0
- package/node/Forms/useForm.js +41 -0
- package/node/Forms/useSubmit.js +27 -0
- package/node/Head/Head.js +8 -0
- package/node/Head/index.js +4 -0
- package/node/I18n/I18n.js +82 -0
- package/node/I18n/index.js +4 -0
- package/node/Img/Img.js +34 -0
- package/node/Img/index.js +4 -0
- package/node/Link/Link.js +13 -0
- package/node/Link/index.js +4 -0
- package/node/NextProgress/NextProgress.js +41 -0
- package/node/NextProgress/index.js +5 -0
- package/node/Seo/Seo.js +12 -0
- package/node/Seo/SeoDefaults.js +16 -0
- package/node/Seo/helpers.js +115 -0
- package/node/Seo/index.js +15 -0
- package/node/Theme/Theme.js +241 -0
- package/node/Theme/index.js +4 -0
- package/node/app/AppHead.js +10 -0
- package/node/app/AppMain.js +2 -0
- package/node/app/css/AppMain.js +16 -0
- package/node/app/css/AppTheme.js +16 -0
- package/node/app/css/auth/index.js +18 -0
- package/node/app/css/index.js +62 -0
- package/node/app/em/AppMain.js +26 -0
- package/node/app/em/AppTheme.js +22 -0
- package/node/app/em/auth/index.js +18 -0
- package/node/app/em/index.js +17 -0
- package/node/app/index.js +5 -0
- package/node/app/sc/AppMain.js +26 -0
- package/node/app/sc/AppTheme.js +13 -0
- package/node/app/sc/auth/index.js +18 -0
- package/node/app/sc/index.js +64 -0
- package/node/config/index.js +184 -0
- package/node/document/Document.js +24 -0
- package/node/document/css/index.js +35 -0
- package/node/document/em/index.js +73 -0
- package/node/document/index.js +7 -0
- package/node/document/sc/index.js +49 -0
- package/node/index.js +15 -0
- package/node/utils/api.js +38 -0
- package/node/utils/emotion-cache.js +13 -0
- package/node/utils/index.js +32 -0
- package/package.json +3 -30
- package/{types.d.ts → typings.d.ts} +10 -7
- package/utils/api.d.ts +55 -55
- package/utils/api.js +35 -0
- package/{document/emotion.d.ts → utils/emotion-cache.d.ts} +5 -5
- package/utils/emotion-cache.js +8 -0
- package/utils/index.d.ts +19 -19
- package/utils/index.js +26 -0
- package/utils/package.json +6 -0
- package/Theme.js +0 -1905
- package/_tslib.js +0 -41
- package/app/App--emotion.d.ts +0 -10
- package/app/App--sc.d.ts +0 -10
- package/app/App--vanilla.d.ts +0 -10
- package/app/AppAuth--emotion.d.ts +0 -10
- package/app/AppAuth--sc.d.ts +0 -10
- package/app/AppMain--vanilla.d.ts +0 -27
- package/app/AppTheme--sc.d.ts +0 -13
- package/app/AppTheme--vanilla.d.ts +0 -10
- package/app/motion-features.d.ts +0 -2
- package/app.js +0 -250
- package/config.js +0 -183
- package/document/Document--emotion.d.ts +0 -5
- package/document/Document--vanilla.d.ts +0 -11
- package/document.js +0 -207
- package/emotion.js +0 -1329
- package/es.object.assign.js +0 -1074
- package/es.string.replace.js +0 -785
- package/es.string.split.js +0 -201
- package/index.esm.js +0 -4600
- package/index.umd.js +0 -4638
- package/motion-features.js +0 -10
package/I18n/I18n.d.ts
CHANGED
|
@@ -1,48 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}[keyof Koine.NextTranslations];
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Passing just `obj` is a shortcut for `{ returnObjects: true }`
|
|
16
|
-
*/
|
|
17
|
-
declare type TranslationQuery = undefined | null | "obj" | {
|
|
18
|
-
[key: string]: string | number | boolean;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Passing just `obj` is a shortcut for `{ returnObjects: true }`
|
|
22
|
-
*/
|
|
23
|
-
declare type TranslationOptions = undefined | "obj" | {
|
|
24
|
-
returnObjects?: boolean;
|
|
25
|
-
fallback?: string | string[];
|
|
26
|
-
default?: string;
|
|
27
|
-
};
|
|
28
|
-
export declare type TranslateNamespace = keyof Koine.NextTranslations;
|
|
29
|
-
export declare type TranslateKey = AllPaths;
|
|
30
|
-
export declare type Translate<
|
|
31
|
-
export declare type TranslateLoose = (s: any, q?: any, o?: any) => string;
|
|
32
|
-
/**
|
|
33
|
-
* FIXME: the use of `useMemo` is a hopefully-temporary solution to fix the FOUC
|
|
34
|
-
* problem of untranslated text during page transitions
|
|
35
|
-
*
|
|
36
|
-
* @see https://github.com/vinissimus/next-translate/issues/513#issuecomment-779826418
|
|
37
|
-
*/
|
|
38
|
-
export declare function useT<N extends TranslateNamespace | undefined>(namespace?: N): <R extends unknown = string>(s: N extends TranslateNamespace ? Paths<Koine.NextTranslations[N]> | AllPaths : AllPaths, q?: TranslationQuery, o?: TranslationOptions) => R;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* Automatically returns the `date-fns/format` function with the right locale
|
|
46
|
-
* passed as option (grabbed from next router value).
|
|
47
|
-
*/
|
|
48
|
-
export declare const useDateFormat: () => typeof format;
|
|
1
|
+
/// <reference types="@koine/next/typings" />
|
|
2
|
+
import format from "date-fns/format";
|
|
3
|
+
import type { Option } from "@koine/react";
|
|
4
|
+
export { default as T } from "next-translate/Trans";
|
|
5
|
+
declare type Join<S1, S2> = S1 extends string ? S2 extends string ? `${S1}.${S2}` : never : never;
|
|
6
|
+
declare type Paths<T> = {
|
|
7
|
+
[K in keyof T]: T[K] extends Record<string, unknown> ? Join<K, Paths<T[K]>> : K;
|
|
8
|
+
}[keyof T];
|
|
9
|
+
export declare type AllPaths = {
|
|
10
|
+
[N in keyof Koine.NextTranslations]: {
|
|
11
|
+
[K in keyof Koine.NextTranslations[N]]: Koine.NextTranslations[N][K] extends Array<Record<string, unknown>> ? Join<K extends string ? `${N}:${K}` : `${N}:`, Paths<Koine.NextTranslations[N][K]>> : Koine.NextTranslations[N][K] extends Record<string, unknown> ? Join<K extends string ? `${N}:${K}` : `${N}:`, Paths<Koine.NextTranslations[N][K]>> & Record<Koine.NextTranslations[N][K], object> : Koine.NextTranslations[N][K] extends Array<string | number | boolean> ? Join<K extends string ? `${N}:${K}` : `${N}`, Paths<Koine.NextTranslations[N][K]>> : Koine.NextTranslations[N][K] extends string | number | boolean ? K extends string ? `${N}:${K}` : `${N}:` : ``;
|
|
12
|
+
}[keyof Koine.NextTranslations[N]];
|
|
13
|
+
}[keyof Koine.NextTranslations];
|
|
14
|
+
/**
|
|
15
|
+
* Passing just `obj` is a shortcut for `{ returnObjects: true }`
|
|
16
|
+
*/
|
|
17
|
+
declare type TranslationQuery = undefined | null | "obj" | {
|
|
18
|
+
[key: string]: string | number | boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Passing just `obj` is a shortcut for `{ returnObjects: true }`
|
|
22
|
+
*/
|
|
23
|
+
declare type TranslationOptions = undefined | "obj" | {
|
|
24
|
+
returnObjects?: boolean;
|
|
25
|
+
fallback?: string | string[];
|
|
26
|
+
default?: string;
|
|
27
|
+
};
|
|
28
|
+
export declare type TranslateNamespace = keyof Koine.NextTranslations;
|
|
29
|
+
export declare type TranslateKey = AllPaths;
|
|
30
|
+
export declare type Translate<N extends undefined | keyof Koine.NextTranslations = undefined> = <R extends unknown = string>(s: N extends TranslateNamespace ? Paths<Koine.NextTranslations[N]> | AllPaths : AllPaths, q?: TranslationQuery, o?: TranslationOptions) => R;
|
|
31
|
+
export declare type TranslateLoose = (s: any, q?: any, o?: any) => string;
|
|
32
|
+
/**
|
|
33
|
+
* FIXME: the use of `useMemo` is a hopefully-temporary solution to fix the FOUC
|
|
34
|
+
* problem of untranslated text during page transitions
|
|
35
|
+
*
|
|
36
|
+
* @see https://github.com/vinissimus/next-translate/issues/513#issuecomment-779826418
|
|
37
|
+
*/
|
|
38
|
+
export declare function useT<N extends TranslateNamespace | undefined>(namespace?: N): <R extends unknown = string>(s: N extends TranslateNamespace ? Paths<Koine.NextTranslations[N]> | AllPaths : AllPaths, q?: TranslationQuery, o?: TranslationOptions) => R;
|
|
39
|
+
export declare function translationAsOptions(t: TranslateLoose, i18nKey: string): Option[];
|
|
40
|
+
/**
|
|
41
|
+
* Automatically returns the `date-fns/format` function with the right locale
|
|
42
|
+
* passed as option (grabbed from next router value).
|
|
43
|
+
*/
|
|
44
|
+
export declare const useDateFormat: () => typeof format;
|
package/I18n/I18n.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/// <reference types="@koine/next/typings" />
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
|
|
3
|
+
/**
|
|
4
|
+
* @file
|
|
5
|
+
*
|
|
6
|
+
* About the typescript support for translation strings @see:
|
|
7
|
+
* - https://github.com/vinissimus/next-translate/issues/721
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect, useState, useMemo } from "react";
|
|
10
|
+
import { useRouter } from "next/router";
|
|
11
|
+
import format from "date-fns/format";
|
|
12
|
+
import useTranslation from "next-translate/useTranslation";
|
|
13
|
+
import { useDateLocale } from "@koine/react";
|
|
14
|
+
export { default as T } from "next-translate/Trans";
|
|
15
|
+
/**
|
|
16
|
+
* FIXME: the use of `useMemo` is a hopefully-temporary solution to fix the FOUC
|
|
17
|
+
* problem of untranslated text during page transitions
|
|
18
|
+
*
|
|
19
|
+
* @see https://github.com/vinissimus/next-translate/issues/513#issuecomment-779826418
|
|
20
|
+
*/
|
|
21
|
+
export function useT(namespace) {
|
|
22
|
+
const t = useTranslation().t;
|
|
23
|
+
// const typedT = <
|
|
24
|
+
// // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
25
|
+
// R extends unknown = string,
|
|
26
|
+
// // Q extends TranslationQuery = TranslationQuery
|
|
27
|
+
// // O extends TranslationOptions = TranslationOptions
|
|
28
|
+
// >(
|
|
29
|
+
// s: N extends TranslateNamespace
|
|
30
|
+
// ? Paths<Koine.NextTranslations[N]> | AllPaths
|
|
31
|
+
// : AllPaths,
|
|
32
|
+
// q?: TranslationQuery,
|
|
33
|
+
// o?: TranslationOptions
|
|
34
|
+
// ) =>
|
|
35
|
+
// // eslint-disable-next-line
|
|
36
|
+
// t.call(
|
|
37
|
+
// null,
|
|
38
|
+
// namespace ? `${namespace}:${s}` : s,
|
|
39
|
+
// q === "obj" ? null : q,
|
|
40
|
+
// q === "obj" || o === "obj" ? { returnObjects: true } : o
|
|
41
|
+
// // ) as R extends (undefined | never | unknown) ? TranslateReturn<TranslationQuery, TranslationOptions> : R;
|
|
42
|
+
// ) as R;
|
|
43
|
+
// return typedT;
|
|
44
|
+
const tMemoized = useMemo(() => (s, q, o) => t(namespace ? `${namespace}:${s}` : s, q === "obj" ? null : q, q === "obj" || o === "obj" ? { returnObjects: true } : o
|
|
45
|
+
// ) as R extends (undefined | never | unknown) ? TranslateReturn<TranslationQuery, TranslationOptions> : R;
|
|
46
|
+
), [t, namespace]);
|
|
47
|
+
// return tMemoized as Translate<N>;
|
|
48
|
+
return tMemoized;
|
|
49
|
+
}
|
|
50
|
+
export function translationAsOptions(t, i18nKey) {
|
|
51
|
+
const dictionary = t(i18nKey, undefined, {
|
|
52
|
+
returnObjects: true,
|
|
53
|
+
});
|
|
54
|
+
return Object.keys(dictionary).map((key) => ({
|
|
55
|
+
value: key,
|
|
56
|
+
label: dictionary[key],
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Automatically returns the `date-fns/format` function with the right locale
|
|
61
|
+
* passed as option (grabbed from next router value).
|
|
62
|
+
*/
|
|
63
|
+
export const useDateFormat = () => {
|
|
64
|
+
const [formatter, setFormatter] = useState(() => (...args) => format(...args));
|
|
65
|
+
const router = useRouter();
|
|
66
|
+
const locale = useDateLocale(router.locale);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (locale) {
|
|
69
|
+
const newFormatter = (date, _format, options) => format(date, _format, { ...(options || {}), locale });
|
|
70
|
+
setFormatter(() => (...args) => newFormatter(...args));
|
|
71
|
+
}
|
|
72
|
+
}, [locale]);
|
|
73
|
+
return formatter;
|
|
74
|
+
};
|
package/I18n/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./I18n";
|
|
1
|
+
export * from "./I18n";
|
package/I18n/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./I18n";
|
package/Img/Img.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import NextImage, { ImageProps
|
|
3
|
-
import { KoineImgSmartProps, KoineImgSmartWrapProps } from "@koine/react";
|
|
4
|
-
interface StaticRequire {
|
|
5
|
-
default: StaticImageData;
|
|
6
|
-
}
|
|
7
|
-
declare type StaticImport = StaticRequire | StaticImageData;
|
|
8
|
-
export declare type NextImgProps = Omit<React.ComponentPropsWithoutRef<"img">, "src"> & Omit<
|
|
9
|
-
src: string | StaticImport;
|
|
10
|
-
};
|
|
11
|
-
export declare const NextImg: typeof NextImage;
|
|
12
|
-
export declare type NextImgSmartWrapProps = KoineImgSmartWrapProps;
|
|
13
|
-
export declare type NextImgSmartProps = KoineImgSmartProps & NextImgProps;
|
|
14
|
-
export declare const NextImgSmart: (props: NextImgSmartProps) => JSX.Element;
|
|
15
|
-
export declare function getNextImgProps<T>({ src, alt, layout, blurDataURL, width, height, priority, objectFit, objectPosition, ...restProps }: T & NextImgProps): {
|
|
16
|
-
nextImgProps: NextImgProps;
|
|
17
|
-
restProps: Omit<T & Omit<Pick<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "key" | keyof React.ImgHTMLAttributes<HTMLImageElement>>, "src"> & Omit<
|
|
18
|
-
src: string | StaticImport;
|
|
19
|
-
}, "
|
|
20
|
-
};
|
|
21
|
-
export {};
|
|
1
|
+
import React from "react";
|
|
2
|
+
import NextImage, { ImageProps, StaticImageData } from "next/image";
|
|
3
|
+
import type { KoineImgSmartProps, KoineImgSmartWrapProps } from "@koine/react";
|
|
4
|
+
interface StaticRequire {
|
|
5
|
+
default: StaticImageData;
|
|
6
|
+
}
|
|
7
|
+
declare type StaticImport = StaticRequire | StaticImageData;
|
|
8
|
+
export declare type NextImgProps = Omit<React.ComponentPropsWithoutRef<"img">, "src"> & Omit<ImageProps, "src"> & {
|
|
9
|
+
src: string | StaticImport;
|
|
10
|
+
};
|
|
11
|
+
export declare const NextImg: typeof NextImage;
|
|
12
|
+
export declare type NextImgSmartWrapProps = KoineImgSmartWrapProps;
|
|
13
|
+
export declare type NextImgSmartProps = KoineImgSmartProps & NextImgProps;
|
|
14
|
+
export declare const NextImgSmart: (props: NextImgSmartProps) => JSX.Element;
|
|
15
|
+
export declare function getNextImgProps<T>({ src, alt, layout, blurDataURL, width, height, priority, objectFit, objectPosition, ...restProps }: T & NextImgProps): {
|
|
16
|
+
nextImgProps: NextImgProps;
|
|
17
|
+
restProps: Omit<T & Omit<Pick<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "key" | keyof React.ImgHTMLAttributes<HTMLImageElement>>, "src"> & Omit<ImageProps, "src"> & {
|
|
18
|
+
src: string | StaticImport;
|
|
19
|
+
}, "src" | "alt" | "height" | "width" | "layout" | "priority" | "blurDataURL" | "objectFit" | "objectPosition">;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
package/Img/Img.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import NextImage from "next/image";
|
|
4
|
+
export const NextImg = NextImage;
|
|
5
|
+
export const NextImgSmart = (props) => {
|
|
6
|
+
const [$loaded, setLoaded] = useState(false);
|
|
7
|
+
const [$error, setError] = useState(false);
|
|
8
|
+
const { nextImgProps, restProps } = getNextImgProps(props);
|
|
9
|
+
const { Wrap } = restProps;
|
|
10
|
+
return nextImgProps.priority ? (_jsx(NextImage, { ...nextImgProps })) : (_jsx(Wrap, { ...restProps, "$loaded": $loaded, "$error": $error, children: _jsx(NextImage, { ...nextImgProps, onLoadingComplete: () => setLoaded(true), onError: () => setError(true) }) }));
|
|
11
|
+
};
|
|
12
|
+
export function getNextImgProps({ src, alt, layout, blurDataURL, width, height, priority, objectFit, objectPosition, ...restProps }) {
|
|
13
|
+
const nextImgProps = {
|
|
14
|
+
src,
|
|
15
|
+
alt,
|
|
16
|
+
layout,
|
|
17
|
+
blurDataURL,
|
|
18
|
+
width,
|
|
19
|
+
height,
|
|
20
|
+
priority,
|
|
21
|
+
objectFit,
|
|
22
|
+
objectPosition,
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
nextImgProps,
|
|
26
|
+
restProps,
|
|
27
|
+
};
|
|
28
|
+
}
|
package/Img/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./Img";
|
|
1
|
+
export * from "./Img";
|
package/Img/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Img";
|
package/Img/package.json
ADDED
package/Link/Link.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { LinkProps as NextLinkProps } from "next/link";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { LinkProps as NextLinkProps } from "next/link";
|
|
3
|
+
export declare type LinkProps = Omit<React.ComponentPropsWithRef<"a">, "href"> & Omit<NextLinkProps, "as" | "passHref" | "children"> & {
|
|
4
|
+
Link?: React.ComponentType<any>;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* @see https://next.js.org/docs/api-reference/next/link
|
|
8
|
+
*/
|
|
9
|
+
export declare const Link: React.ForwardRefExoticComponent<Pick<LinkProps, "key" | "title" | "hidden" | "type" | "locale" | "replace" | "slot" | "style" | "children" | "rel" | "href" | "hrefLang" | "property" | "id" | "prefetch" | "onLoad" | "color" | "onBlur" | "onChange" | "onSubmit" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "download" | "media" | "ping" | "target" | "scroll" | "shallow" | "legacyBehavior" | "Link"> & React.RefAttributes<HTMLAnchorElement>>;
|
package/Link/Link.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import NextLink from "next/link";
|
|
4
|
+
/**
|
|
5
|
+
* @see https://next.js.org/docs/api-reference/next/link
|
|
6
|
+
*/
|
|
7
|
+
export const Link = forwardRef(function Link({ href, prefetch, replace, scroll, shallow, locale, Link = "span", ...props }, ref) {
|
|
8
|
+
return (_jsx(NextLink, { href: href, replace: replace, scroll: scroll, shallow: shallow, locale: locale, passHref: true, children: _jsx(Link, { ref: ref, ...props }) }));
|
|
9
|
+
});
|
package/Link/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./Link";
|
|
1
|
+
export * from "./Link";
|
package/Link/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Link";
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/** @default 0.3 */
|
|
4
|
-
startAt
|
|
5
|
-
/** @default true */
|
|
6
|
-
showOnShallow
|
|
7
|
-
/** @default 200 */
|
|
8
|
-
stopDelayMs
|
|
9
|
-
};
|
|
10
|
-
export declare
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { WithComponents, Simplify } from "@koine/react";
|
|
2
|
+
declare type OwnProps = {
|
|
3
|
+
/** @default 0.3 */
|
|
4
|
+
startAt?: number;
|
|
5
|
+
/** @default true */
|
|
6
|
+
showOnShallow?: boolean;
|
|
7
|
+
/** @default 200 */
|
|
8
|
+
stopDelayMs?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare type Components = {
|
|
11
|
+
Overlay: {
|
|
12
|
+
type: "div";
|
|
13
|
+
props: {
|
|
14
|
+
running?: boolean;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare type ComponentsProps = {
|
|
19
|
+
[Name in keyof Components]: Components[Name]["props"];
|
|
20
|
+
};
|
|
21
|
+
declare type Props = Simplify<WithComponents<OwnProps, Components>>;
|
|
22
|
+
export declare type NextProgressProps = Props;
|
|
23
|
+
export declare const NextProgress: ({ startAt, showOnShallow, stopDelayMs, Overlay, }: NextProgressProps) => JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useRouter } from "next/router";
|
|
4
|
+
export const NextProgress = ({ startAt = 0.3, showOnShallow = true, stopDelayMs = 200, Overlay = "div", }) => {
|
|
5
|
+
const { events } = useRouter();
|
|
6
|
+
// const [progress, setProgress] = useState(0);
|
|
7
|
+
const [running, setRunning] = useState(false);
|
|
8
|
+
const timer = useRef(null);
|
|
9
|
+
const routeChangeStart = useCallback((_, { shallow }) => {
|
|
10
|
+
if (!shallow || showOnShallow) {
|
|
11
|
+
// setProgress(startAt);
|
|
12
|
+
setRunning(true);
|
|
13
|
+
}
|
|
14
|
+
}, [showOnShallow]);
|
|
15
|
+
const routeChangeEnd = useCallback((_, { shallow }) => {
|
|
16
|
+
if (!shallow || showOnShallow) {
|
|
17
|
+
if (timer.current) {
|
|
18
|
+
clearTimeout(timer.current);
|
|
19
|
+
}
|
|
20
|
+
timer.current = setTimeout(() => {
|
|
21
|
+
// setProgress(100);
|
|
22
|
+
setRunning(false);
|
|
23
|
+
}, stopDelayMs);
|
|
24
|
+
}
|
|
25
|
+
}, [showOnShallow, stopDelayMs, timer]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
events.on("routeChangeStart", routeChangeStart);
|
|
28
|
+
events.on("routeChangeComplete", routeChangeEnd);
|
|
29
|
+
events.on("routeChangeError", routeChangeEnd);
|
|
30
|
+
return () => {
|
|
31
|
+
events.off("routeChangeStart", routeChangeStart);
|
|
32
|
+
events.off("routeChangeComplete", routeChangeEnd);
|
|
33
|
+
events.off("routeChangeError", routeChangeEnd);
|
|
34
|
+
};
|
|
35
|
+
}, [events, routeChangeStart, routeChangeEnd]);
|
|
36
|
+
return _jsx(Overlay, { running: running });
|
|
37
|
+
};
|
package/NextProgress/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { NextProgress } from "./NextProgress";
|
|
2
|
+
export type { NextProgressProps } from "./NextProgress";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NextProgress } from "./NextProgress";
|
package/README.md
CHANGED
|
File without changes
|
package/Seo/Seo.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { SeoProps } from "./helpers";
|
|
3
|
-
export declare const Seo: React.MemoExoticComponent<(props: SeoProps) => JSX.Element>;
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SeoProps } from "./helpers";
|
|
3
|
+
export declare const Seo: React.MemoExoticComponent<(props: SeoProps) => JSX.Element>;
|
package/Seo/Seo.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import Head from "next/head";
|
|
4
|
+
import { buildTags } from "./helpers";
|
|
5
|
+
const _Seo = (props) => {
|
|
6
|
+
return _jsx(Head, { children: buildTags(props) });
|
|
7
|
+
};
|
|
8
|
+
export const Seo = memo(_Seo);
|
package/Seo/SeoDefaults.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { SeoDefaultsProps } from "./helpers";
|
|
3
|
-
export declare const SeoDefaults: React.MemoExoticComponent<(props: SeoDefaultsProps) => JSX.Element>;
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SeoDefaultsProps } from "./helpers";
|
|
3
|
+
export declare const SeoDefaults: React.MemoExoticComponent<(props: SeoDefaultsProps) => JSX.Element>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import Head from "next/head";
|
|
4
|
+
// import { useRouter } from "next/router";
|
|
5
|
+
// import { getSiteUrl } from "../utils";
|
|
6
|
+
import { buildTags } from "./helpers";
|
|
7
|
+
const _SeoDefaults = (props) => {
|
|
8
|
+
// const router = useRouter();
|
|
9
|
+
// props.openGraph.url = getSiteUrl(router.asPath);
|
|
10
|
+
return _jsx(Head, { children: buildTags(props) });
|
|
11
|
+
};
|
|
12
|
+
export const SeoDefaults = memo(_SeoDefaults);
|
package/Seo/helpers.d.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { NextSeoProps, DefaultSeoProps } from "next-seo/lib/types";
|
|
3
|
-
export declare type SeoData = {
|
|
4
|
-
hidden?: boolean;
|
|
5
|
-
title?: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
keywords?: string | string[];
|
|
8
|
-
ogimage?: string;
|
|
9
|
-
};
|
|
10
|
-
declare type SeoPropsOpenGraph = NextSeoProps["openGraph"] & {
|
|
11
|
-
image?: string;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* @see https://github.com/garmeeh/next-seo/blob/master/src/types.ts#L395
|
|
15
|
-
*/
|
|
16
|
-
export declare type SeoProps = Omit<NextSeoProps, "additionalMetaTags" | "additionalLinkTags" | "mobileAlternate" | "robotsProps"> & {
|
|
17
|
-
metaTags?: NextSeoProps["additionalMetaTags"];
|
|
18
|
-
linkTags?: NextSeoProps["additionalLinkTags"];
|
|
19
|
-
seo?: SeoData;
|
|
20
|
-
hidden?: SeoData["hidden"];
|
|
21
|
-
keywords?: SeoData["keywords"];
|
|
22
|
-
openGraph?: SeoPropsOpenGraph;
|
|
23
|
-
og?: SeoPropsOpenGraph;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* @see https://github.com/garmeeh/next-seo/blob/master/src/types.ts#L413
|
|
27
|
-
*/
|
|
28
|
-
export declare type SeoDefaultsProps = Omit<DefaultSeoProps, "additionalMetaTags" | "additionalLinkTags" | "dangerouslySetAllPagesToNoIndex" | "dangerouslySetAllPagesToNoFollow" | "defaultOpenGraphImageWidth" | "defaultOpenGraphImageHeight" | "defaultOpenGraphVideoWidth" | "defaultOpenGraphVideoHeight" | "mobileAlternate" | "robotsProps"> & {
|
|
29
|
-
metaTags?: DefaultSeoProps["additionalMetaTags"];
|
|
30
|
-
linkTags?: DefaultSeoProps["additionalLinkTags"];
|
|
31
|
-
};
|
|
32
|
-
declare type BuildTagsParams = SeoProps & SeoDefaultsProps;
|
|
33
|
-
/**
|
|
34
|
-
* We do a couple of things in addition while many other are removed.
|
|
35
|
-
*
|
|
36
|
-
* - Add `seo` meta object coming from a CMS probably
|
|
37
|
-
* - Add `ogimage` and `openGraph.image` as single image source
|
|
38
|
-
* - Add `og` alias to define `openGraph`
|
|
39
|
-
* - Add check for `title` equale to `templateTitle` to avoid meta titles like
|
|
40
|
-
* "My site | My site" often happening in homepages
|
|
41
|
-
* - Remove the open graph videos and images
|
|
42
|
-
*
|
|
43
|
-
* - Shorter code
|
|
44
|
-
*
|
|
45
|
-
* @returns
|
|
46
|
-
*/
|
|
47
|
-
export declare const buildTags: ({ seo, hidden, keywords, title, titleTemplate, defaultTitle, noindex, nofollow, description, languageAlternates, twitter, facebook, openGraph, og: ogAlias, canonical, metaTags, linkTags, }?: BuildTagsParams) => React.ReactNode[];
|
|
48
|
-
export {};
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { NextSeoProps, DefaultSeoProps } from "next-seo/lib/types";
|
|
3
|
+
export declare type SeoData = {
|
|
4
|
+
hidden?: boolean;
|
|
5
|
+
title?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
keywords?: string | string[];
|
|
8
|
+
ogimage?: string;
|
|
9
|
+
};
|
|
10
|
+
declare type SeoPropsOpenGraph = NextSeoProps["openGraph"] & {
|
|
11
|
+
image?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @see https://github.com/garmeeh/next-seo/blob/master/src/types.ts#L395
|
|
15
|
+
*/
|
|
16
|
+
export declare type SeoProps = Omit<NextSeoProps, "additionalMetaTags" | "additionalLinkTags" | "mobileAlternate" | "robotsProps"> & {
|
|
17
|
+
metaTags?: NextSeoProps["additionalMetaTags"];
|
|
18
|
+
linkTags?: NextSeoProps["additionalLinkTags"];
|
|
19
|
+
seo?: SeoData;
|
|
20
|
+
hidden?: SeoData["hidden"];
|
|
21
|
+
keywords?: SeoData["keywords"];
|
|
22
|
+
openGraph?: SeoPropsOpenGraph;
|
|
23
|
+
og?: SeoPropsOpenGraph;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @see https://github.com/garmeeh/next-seo/blob/master/src/types.ts#L413
|
|
27
|
+
*/
|
|
28
|
+
export declare type SeoDefaultsProps = Omit<DefaultSeoProps, "additionalMetaTags" | "additionalLinkTags" | "dangerouslySetAllPagesToNoIndex" | "dangerouslySetAllPagesToNoFollow" | "defaultOpenGraphImageWidth" | "defaultOpenGraphImageHeight" | "defaultOpenGraphVideoWidth" | "defaultOpenGraphVideoHeight" | "mobileAlternate" | "robotsProps"> & {
|
|
29
|
+
metaTags?: DefaultSeoProps["additionalMetaTags"];
|
|
30
|
+
linkTags?: DefaultSeoProps["additionalLinkTags"];
|
|
31
|
+
};
|
|
32
|
+
declare type BuildTagsParams = SeoProps & SeoDefaultsProps;
|
|
33
|
+
/**
|
|
34
|
+
* We do a couple of things in addition while many other are removed.
|
|
35
|
+
*
|
|
36
|
+
* - Add `seo` meta object coming from a CMS probably
|
|
37
|
+
* - Add `ogimage` and `openGraph.image` as single image source
|
|
38
|
+
* - Add `og` alias to define `openGraph`
|
|
39
|
+
* - Add check for `title` equale to `templateTitle` to avoid meta titles like
|
|
40
|
+
* "My site | My site" often happening in homepages
|
|
41
|
+
* - Remove the open graph videos and images
|
|
42
|
+
*
|
|
43
|
+
* - Shorter code
|
|
44
|
+
*
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
export declare const buildTags: ({ seo, hidden, keywords, title, titleTemplate, defaultTitle, noindex, nofollow, description, languageAlternates, twitter, facebook, openGraph, og: ogAlias, canonical, metaTags, linkTags, }?: BuildTagsParams) => React.ReactNode[];
|
|
48
|
+
export {};
|