@koine/next 1.0.3 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/Analytics/AnalyticsGoogle.d.ts +5 -6
  2. package/Analytics/AnalyticsGoogle.js +37 -0
  3. package/Analytics/index.d.ts +1 -1
  4. package/Analytics/index.js +1 -0
  5. package/Auth/helpers.d.ts +17 -17
  6. package/Auth/helpers.js +21 -0
  7. package/Auth/index.d.ts +4 -4
  8. package/Auth/index.js +4 -0
  9. package/Auth/useLogin.d.ts +7 -7
  10. package/Auth/useLogin.js +47 -0
  11. package/Auth/useLoginUrl.d.ts +1 -1
  12. package/Auth/useLoginUrl.js +11 -0
  13. package/Auth/useLogout.d.ts +6 -6
  14. package/Auth/useLogout.js +52 -0
  15. package/Favicon/Favicon.d.ts +3 -4
  16. package/Favicon/Favicon.js +4 -0
  17. package/Favicon/index.d.ts +1 -1
  18. package/Favicon/index.js +1 -0
  19. package/Forms/index.d.ts +2 -2
  20. package/Forms/index.js +2 -0
  21. package/Forms/useForm.d.ts +32 -32
  22. package/Forms/useForm.js +33 -0
  23. package/Forms/useSubmit.d.ts +24 -24
  24. package/Forms/useSubmit.js +20 -0
  25. package/Head/Head.d.ts +1 -1
  26. package/Head/Head.js +1 -0
  27. package/Head/index.d.ts +1 -1
  28. package/Head/index.js +1 -0
  29. package/I18n/I18n.d.ts +48 -48
  30. package/I18n/I18n.js +86 -0
  31. package/I18n/index.d.ts +1 -1
  32. package/I18n/index.js +1 -0
  33. package/Img/Img.d.ts +21 -21
  34. package/Img/Img.js +30 -0
  35. package/Img/index.d.ts +1 -1
  36. package/Img/index.js +1 -0
  37. package/Link/Link.d.ts +8 -8
  38. package/Link/Link.js +12 -0
  39. package/Link/index.d.ts +1 -1
  40. package/Link/index.js +1 -0
  41. package/NextProgress/NextProgress.d.ts +13 -14
  42. package/NextProgress/NextProgress.js +38 -0
  43. package/NextProgress/index.d.ts +1 -1
  44. package/NextProgress/index.js +1 -0
  45. package/Seo/Seo.d.ts +3 -3
  46. package/Seo/Seo.js +8 -0
  47. package/Seo/SeoDefaults.d.ts +3 -3
  48. package/Seo/SeoDefaults.js +12 -0
  49. package/Seo/helpers.d.ts +48 -48
  50. package/Seo/helpers.js +113 -0
  51. package/Seo/index.d.ts +12 -12
  52. package/Seo/index.js +12 -0
  53. package/Theme/Theme.d.ts +46 -46
  54. package/Theme/Theme.js +235 -0
  55. package/Theme/index.d.ts +1 -1
  56. package/Theme/index.js +1 -0
  57. package/app/App--emotion.d.ts +10 -10
  58. package/app/App--emotion.js +11 -0
  59. package/app/App--sc.d.ts +10 -10
  60. package/app/App--sc.js +11 -0
  61. package/app/App--vanilla.d.ts +10 -10
  62. package/app/App--vanilla.js +11 -0
  63. package/app/AppAuth--emotion.d.ts +10 -10
  64. package/app/AppAuth--emotion.js +12 -0
  65. package/app/AppAuth--sc.d.ts +10 -10
  66. package/app/AppAuth--sc.js +12 -0
  67. package/app/AppHead.d.ts +3 -3
  68. package/app/AppHead.js +5 -0
  69. package/app/{AppMain.d.ts → AppMain--emotion.d.ts} +34 -34
  70. package/app/AppMain--emotion.js +27 -0
  71. package/app/AppMain--sc.d.ts +34 -0
  72. package/app/AppMain--sc.js +27 -0
  73. package/app/AppMain--vanilla.d.ts +27 -27
  74. package/app/AppMain--vanilla.js +11 -0
  75. package/app/AppTheme--emotion.d.ts +15 -15
  76. package/app/AppTheme--emotion.js +17 -0
  77. package/app/AppTheme--sc.d.ts +13 -13
  78. package/app/AppTheme--sc.js +9 -0
  79. package/app/AppTheme--vanilla.d.ts +10 -10
  80. package/app/AppTheme--vanilla.js +12 -0
  81. package/app/index.d.ts +11 -11
  82. package/app/index.js +11 -0
  83. package/app/motion-features.d.ts +2 -2
  84. package/app/motion-features.js +2 -0
  85. package/config/index.d.ts +58 -58
  86. package/config/index.js +144 -0
  87. package/document/Document--emotion.d.ts +5 -5
  88. package/document/Document--emotion.js +55 -0
  89. package/document/Document--sc.d.ts +11 -11
  90. package/document/Document--sc.js +33 -0
  91. package/document/Document--vanilla.d.ts +11 -11
  92. package/document/Document--vanilla.js +20 -0
  93. package/document/Document.d.ts +10 -10
  94. package/document/Document.js +14 -0
  95. package/document/index.d.ts +4 -4
  96. package/document/index.js +4 -0
  97. package/index.d.ts +15 -12
  98. package/index.js +15 -743
  99. package/index.umd.js +2061 -78
  100. package/package.json +27 -21
  101. package/{types.d.ts → typings.d.ts} +0 -0
  102. package/utils/api.d.ts +55 -55
  103. package/utils/api.js +33 -0
  104. package/{document/emotion.d.ts → utils/emotion-cache.d.ts} +5 -5
  105. package/utils/emotion-cache.js +8 -0
  106. package/utils/index.d.ts +20 -19
  107. package/utils/index.js +27 -0
  108. package/Theme.js +0 -1905
  109. package/_tslib.js +0 -41
  110. package/app.js +0 -250
  111. package/config.js +0 -183
  112. package/document.js +0 -207
  113. package/emotion.js +0 -1329
  114. package/es.object.assign.js +0 -1074
  115. package/es.string.replace.js +0 -785
  116. package/es.string.split.js +0 -201
  117. package/index.esm.js +0 -4600
  118. package/motion-features.js +0 -10
package/I18n/I18n.js ADDED
@@ -0,0 +1,86 @@
1
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
2
+ /**
3
+ * @file
4
+ *
5
+ * About the typescript support for translation strings @see:
6
+ * - https://github.com/vinissimus/next-translate/issues/721
7
+ *
8
+ * About the issue with page transitions @see:
9
+ * - https://github.com/vinissimus/next-translate/issues/447
10
+ * - https://github.com/vinissimus/next-translate/pull/743
11
+ */
12
+ import { useEffect, useState, useMemo } from "react";
13
+ import { useRouter } from "next/router";
14
+ import format from "date-fns/format";
15
+ import useTranslation from "next-translate/useTranslation";
16
+ import { useDateLocale } from "@koine/react";
17
+ export { default as T } from "next-translate/Trans";
18
+ /**
19
+ * FIXME: the use of `useMemo` is a hopefully-temporary solution to fix the FOUC
20
+ * problem of untranslated text during page transitions
21
+ *
22
+ * @see https://github.com/vinissimus/next-translate/issues/513#issuecomment-779826418
23
+ */
24
+ export function useT(namespace) {
25
+ const t = useTranslation().t;
26
+ // const typedT = <
27
+ // // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
28
+ // R extends unknown = string,
29
+ // // Q extends TranslationQuery = TranslationQuery
30
+ // // O extends TranslationOptions = TranslationOptions
31
+ // >(
32
+ // s: N extends TranslateNamespace
33
+ // ? Paths<Koine.NextTranslations[N]> | AllPaths
34
+ // : AllPaths,
35
+ // q?: TranslationQuery,
36
+ // o?: TranslationOptions
37
+ // ) =>
38
+ // // eslint-disable-next-line
39
+ // t.call(
40
+ // null,
41
+ // namespace ? `${namespace}:${s}` : s,
42
+ // q === "obj" ? null : q,
43
+ // q === "obj" || o === "obj" ? { returnObjects: true } : o
44
+ // // ) as R extends (undefined | never | unknown) ? TranslateReturn<TranslationQuery, TranslationOptions> : R;
45
+ // ) as R;
46
+ // return typedT;
47
+ const tMemoized = useMemo(() => (s, q, o) => t(namespace ? `${namespace}:${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
+ ), [t, namespace]);
50
+ // return tMemoized as Translate<N>;
51
+ return tMemoized;
52
+ }
53
+ /**
54
+ * @deprecated Not sure whether this will ever be useful
55
+ */
56
+ export function useLooseT(namespace) {
57
+ const { t } = useTranslation(namespace);
58
+ // return t;
59
+ const tMemoized = useMemo(() => t, [t]);
60
+ return tMemoized;
61
+ }
62
+ export function translationAsOptions(t, i18nKey) {
63
+ const dictionary = t(i18nKey, undefined, {
64
+ returnObjects: true,
65
+ });
66
+ return Object.keys(dictionary).map((key) => ({
67
+ value: key,
68
+ label: dictionary[key],
69
+ }));
70
+ }
71
+ /**
72
+ * Automatically returns the `date-fns/format` function with the right locale
73
+ * passed as option (grabbed from next router value).
74
+ */
75
+ export const useDateFormat = () => {
76
+ const [formatter, setFormatter] = useState(() => (...args) => format(...args));
77
+ const router = useRouter();
78
+ const locale = useDateLocale(router.locale);
79
+ useEffect(() => {
80
+ if (locale) {
81
+ const newFormatter = (date, _format, options) => format(date, _format, Object.assign(Object.assign({}, (options || {})), { locale }));
82
+ setFormatter(() => (...args) => newFormatter(...args));
83
+ }
84
+ }, [locale]);
85
+ return formatter;
86
+ };
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 as NextImageProps, StaticImageData } from "next/image";
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<NextImageProps, "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<NextImageProps, "src"> & {
18
- src: string | StaticImport;
19
- }, "alt" | "height" | "src" | "width" | "layout" | "priority" | "blurDataURL" | "objectFit" | "objectPosition">;
20
- };
21
- export {};
1
+ import React from "react";
2
+ import NextImage, { ImageProps as NextImageProps, StaticImageData } from "next/image";
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<NextImageProps, "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<NextImageProps, "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,30 @@
1
+ import { __rest } from "tslib";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import NextImage from "next/image";
5
+ export const NextImg = NextImage;
6
+ export const NextImgSmart = (props) => {
7
+ const [$loaded, setLoaded] = useState(false);
8
+ const [$error, setError] = useState(false);
9
+ const { nextImgProps, restProps } = getNextImgProps(props);
10
+ const { Wrap } = restProps;
11
+ return nextImgProps.priority ? (_jsx(NextImage, Object.assign({}, nextImgProps))) : (_jsx(Wrap, Object.assign({}, restProps, { "$loaded": $loaded, "$error": $error }, { children: _jsx(NextImage, Object.assign({}, nextImgProps, { onLoadingComplete: () => setLoaded(true), onError: () => setError(true) })) })));
12
+ };
13
+ export function getNextImgProps(_a) {
14
+ var { src, alt, layout, blurDataURL, width, height, priority, objectFit, objectPosition } = _a, restProps = __rest(_a, ["src", "alt", "layout", "blurDataURL", "width", "height", "priority", "objectFit", "objectPosition"]);
15
+ const nextImgProps = {
16
+ src,
17
+ alt,
18
+ layout,
19
+ blurDataURL,
20
+ width,
21
+ height,
22
+ priority,
23
+ objectFit,
24
+ objectPosition,
25
+ };
26
+ return {
27
+ nextImgProps,
28
+ restProps,
29
+ };
30
+ }
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/Link/Link.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import React from "react";
2
- import { LinkProps as NextLinkProps } from "next/link";
3
- import { KoineLinkProps } from "@koine/react";
4
- export declare type LinkProps = Omit<KoineLinkProps, "href"> & Omit<NextLinkProps, "as" | "passHref" | "children">;
5
- /**
6
- * @see https://next.js.org/docs/api-reference/next/link
7
- */
8
- export declare const Link: React.ForwardRefExoticComponent<Pick<LinkProps, "slot" | "style" | "title" | "key" | "download" | "href" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "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" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "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" | "replace" | "scroll" | "shallow" | "prefetch" | "locale"> & React.RefAttributes<HTMLAnchorElement>>;
1
+ import React from "react";
2
+ import { LinkProps as NextLinkProps } from "next/link";
3
+ import { KoineLinkProps } from "@koine/react";
4
+ export declare type LinkProps = Omit<KoineLinkProps, "href"> & Omit<NextLinkProps, "as" | "passHref" | "children">;
5
+ /**
6
+ * @see https://next.js.org/docs/api-reference/next/link
7
+ */
8
+ 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"> & React.RefAttributes<HTMLAnchorElement>>;
package/Link/Link.js ADDED
@@ -0,0 +1,12 @@
1
+ import { __rest } from "tslib";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from "react";
4
+ import NextLink from "next/link";
5
+ import { KoineLink } from "@koine/react";
6
+ /**
7
+ * @see https://next.js.org/docs/api-reference/next/link
8
+ */
9
+ export const Link = forwardRef(function Link(_a, ref) {
10
+ var { href, prefetch, replace, scroll, shallow, locale } = _a, props = __rest(_a, ["href", "prefetch", "replace", "scroll", "shallow", "locale"]);
11
+ return (_jsx(NextLink, Object.assign({ href: href, replace: replace, scroll: scroll, shallow: shallow, locale: locale, passHref: true }, { children: _jsx(KoineLink, Object.assign({ ref: ref }, props)) })));
12
+ });
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,13 @@
1
- /// <reference types="react" />
2
- export declare type NextProgressProps = {
3
- /** @default 0.3 */
4
- startAt: number;
5
- /** @default true */
6
- showOnShallow: boolean;
7
- /** @default 200 */
8
- stopDelayMs: number;
9
- };
10
- export declare const NextProgress: ({ startAt, showOnShallow, stopDelayMs, }: {
11
- startAt?: number | undefined;
12
- showOnShallow?: boolean | undefined;
13
- stopDelayMs?: number | undefined;
14
- }) => JSX.Element;
1
+ export declare type NextProgressProps = {
2
+ /** @default 0.3 */
3
+ startAt: number;
4
+ /** @default true */
5
+ showOnShallow: boolean;
6
+ /** @default 200 */
7
+ stopDelayMs: number;
8
+ };
9
+ export declare const NextProgress: ({ startAt, showOnShallow, stopDelayMs, }: {
10
+ startAt?: number | undefined;
11
+ showOnShallow?: boolean | undefined;
12
+ stopDelayMs?: number | undefined;
13
+ }) => JSX.Element;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { useRouter } from "next/router";
4
+ import { ProgressOverlay } from "@koine/react";
5
+ export const NextProgress = ({ startAt = 0.3, showOnShallow = true, stopDelayMs = 200, }) => {
6
+ const { events } = useRouter();
7
+ // const [progress, setProgress] = useState(0);
8
+ const [running, setRunning] = useState(false);
9
+ const timer = useRef(null);
10
+ const routeChangeStart = useCallback((_, { shallow }) => {
11
+ if (!shallow || showOnShallow) {
12
+ // setProgress(startAt);
13
+ setRunning(true);
14
+ }
15
+ }, [showOnShallow]);
16
+ const routeChangeEnd = useCallback((_, { shallow }) => {
17
+ if (!shallow || showOnShallow) {
18
+ if (timer.current) {
19
+ clearTimeout(timer.current);
20
+ }
21
+ timer.current = setTimeout(() => {
22
+ // setProgress(100);
23
+ setRunning(false);
24
+ }, stopDelayMs);
25
+ }
26
+ }, [showOnShallow, stopDelayMs, timer]);
27
+ useEffect(() => {
28
+ events.on("routeChangeStart", routeChangeStart);
29
+ events.on("routeChangeComplete", routeChangeEnd);
30
+ events.on("routeChangeError", routeChangeEnd);
31
+ return () => {
32
+ events.off("routeChangeStart", routeChangeStart);
33
+ events.off("routeChangeComplete", routeChangeEnd);
34
+ events.off("routeChangeError", routeChangeEnd);
35
+ };
36
+ }, [events, routeChangeStart, routeChangeEnd]);
37
+ return _jsx(ProgressOverlay, { running: running });
38
+ };
@@ -1 +1 @@
1
- export * from "./NextProgress";
1
+ export * from "./NextProgress";
@@ -0,0 +1 @@
1
+ export * from "./NextProgress";
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);
@@ -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 {};
package/Seo/helpers.js ADDED
@@ -0,0 +1,113 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { isArray } from "@koine/utils";
3
+ const defaults = {
4
+ tplTitle: "",
5
+ };
6
+ /**
7
+ * We do a couple of things in addition while many other are removed.
8
+ *
9
+ * - Add `seo` meta object coming from a CMS probably
10
+ * - Add `ogimage` and `openGraph.image` as single image source
11
+ * - Add `og` alias to define `openGraph`
12
+ * - Add check for `title` equale to `templateTitle` to avoid meta titles like
13
+ * "My site | My site" often happening in homepages
14
+ * - Remove the open graph videos and images
15
+ *
16
+ * - Shorter code
17
+ *
18
+ * @returns
19
+ */
20
+ export const buildTags = ({ seo, hidden, keywords, title = "", titleTemplate, defaultTitle, noindex, nofollow, description, languageAlternates = [], twitter, facebook, openGraph, og: ogAlias, canonical, metaTags, linkTags, } = {}) => {
21
+ const render = [];
22
+ const $names = {};
23
+ const $properties = {};
24
+ if (titleTemplate) {
25
+ defaults.tplTitle = titleTemplate;
26
+ }
27
+ title = title || (seo === null || seo === void 0 ? void 0 : seo.title) || "";
28
+ if (title) {
29
+ if (defaults.tplTitle && defaults.tplTitle !== title) {
30
+ title = defaults.tplTitle.replace(/%s/g, title);
31
+ }
32
+ }
33
+ else if (defaultTitle) {
34
+ title = defaultTitle;
35
+ }
36
+ if (title) {
37
+ render.push(_jsx("title", { children: title }, "title"));
38
+ $properties["og:title"] = title; // overridden later...
39
+ }
40
+ $names["robots"] = `${noindex || hidden ? "noindex" : "index"},${nofollow || hidden ? "nofollow" : "follow"}`;
41
+ description = description || (seo === null || seo === void 0 ? void 0 : seo.description);
42
+ if (description) {
43
+ $names["description"] = description;
44
+ $properties["og:description"] = description; // overridden later...
45
+ }
46
+ keywords = keywords || (seo === null || seo === void 0 ? void 0 : seo.keywords);
47
+ if (keywords) {
48
+ $names["keywords"] = isArray(keywords) ? keywords.join(", ") : keywords;
49
+ }
50
+ if ((languageAlternates === null || languageAlternates === void 0 ? void 0 : languageAlternates.length) > 0) {
51
+ languageAlternates.forEach((languageAlternate) => {
52
+ render.push(_jsx("link", { rel: "alternate", hrefLang: languageAlternate.hrefLang, href: languageAlternate.href }, `languageAlternate-${languageAlternate.hrefLang}`));
53
+ });
54
+ }
55
+ if (canonical) {
56
+ render.push(_jsx("link", { rel: "canonical", href: canonical }, "canonical"));
57
+ $properties["og:url"] = canonical;
58
+ }
59
+ if (facebook === null || facebook === void 0 ? void 0 : facebook.appId)
60
+ $properties["fb:app_id"] = facebook.appId;
61
+ if (twitter) {
62
+ if (twitter.cardType)
63
+ $names["twitter:card"] = twitter.cardType;
64
+ if (twitter.site)
65
+ $names["twitter:site"] = twitter.site;
66
+ if (twitter.handle)
67
+ $names["twitter:creator"] = twitter.handle;
68
+ }
69
+ const og = ogAlias || openGraph;
70
+ if (og === null || og === void 0 ? void 0 : og.title)
71
+ $properties["og:title"] = og === null || og === void 0 ? void 0 : og.title;
72
+ if (og === null || og === void 0 ? void 0 : og.description)
73
+ $properties["og:description"] = og === null || og === void 0 ? void 0 : og.description;
74
+ if (og === null || og === void 0 ? void 0 : og.url)
75
+ $properties["og:url"] = og.url;
76
+ if (og === null || og === void 0 ? void 0 : og.type)
77
+ $properties["og:type"] = og.type.toLowerCase();
78
+ if (og === null || og === void 0 ? void 0 : og.locale)
79
+ $properties["og:locale"] = og.locale;
80
+ if (og === null || og === void 0 ? void 0 : og.site_name)
81
+ $properties["og:site_name"] = og.site_name;
82
+ const ogimage = (og === null || og === void 0 ? void 0 : og.image) || (seo === null || seo === void 0 ? void 0 : seo.ogimage);
83
+ if (ogimage)
84
+ $properties["og:image"] = ogimage;
85
+ Object.keys($names).forEach((key) => {
86
+ render.push(_jsx("meta", { name: key, content: $names[key] }, key));
87
+ });
88
+ Object.keys($properties).forEach((key) => {
89
+ render.push(_jsx("meta", { property: key, content: $properties[key] }, key));
90
+ });
91
+ if (metaTags && metaTags.length > 0) {
92
+ metaTags.forEach((tag) => {
93
+ var _a, _b, _c;
94
+ render.push(_jsx("meta", Object.assign({}, tag), `meta:${(_c = (_b = (_a = tag.keyOverride) !== null && _a !== void 0 ? _a : tag.name) !== null && _b !== void 0 ? _b : tag.property) !== null && _c !== void 0 ? _c : tag.httpEquiv}`));
95
+ });
96
+ }
97
+ if (linkTags === null || linkTags === void 0 ? void 0 : linkTags.length) {
98
+ linkTags.forEach((tag) => {
99
+ var _a;
100
+ render.push(_jsx("link", Object.assign({}, tag), `link${(_a = tag.keyOverride) !== null && _a !== void 0 ? _a : tag.href}${tag.rel}`));
101
+ });
102
+ }
103
+ // TODO: alternates and canonical
104
+ // canonical = 'https://www.domain.com/';
105
+ // languageAlternates={[{
106
+ // hrefLang: 'en',
107
+ // href: 'https://www.domain.com/en',
108
+ // }]}
109
+ // <link rel="alternate" hreflang="x-default" href="https://www.domain.com/nl/">
110
+ // <link rel="alternate" hreflang="nl" href="https://www.domain.com/nl/">
111
+ // <link rel="alternate" hreflang="en" href="https://www.domain.com/en/">
112
+ return render;
113
+ };
package/Seo/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- /**
2
- * @file
3
- *
4
- * Adapted from https://github.com/garmeeh/next-seo
5
- *
6
- * See also:
7
- * - https://github.com/catnose99/next-head-seo
8
- * - https://nextjs.org/docs/api-reference/next/head
9
- */
10
- export * from "./helpers";
11
- export * from "./Seo";
12
- export * from "./SeoDefaults";
1
+ /**
2
+ * @file
3
+ *
4
+ * Adapted from https://github.com/garmeeh/next-seo
5
+ *
6
+ * See also:
7
+ * - https://github.com/catnose99/next-head-seo
8
+ * - https://nextjs.org/docs/api-reference/next/head
9
+ */
10
+ export * from "./helpers";
11
+ export * from "./Seo";
12
+ export * from "./SeoDefaults";
package/Seo/index.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @file
3
+ *
4
+ * Adapted from https://github.com/garmeeh/next-seo
5
+ *
6
+ * See also:
7
+ * - https://github.com/catnose99/next-head-seo
8
+ * - https://nextjs.org/docs/api-reference/next/head
9
+ */
10
+ export * from "./helpers";
11
+ export * from "./Seo";
12
+ export * from "./SeoDefaults";