@koine/next 1.0.1 → 1.0.2

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 (66) hide show
  1. package/Analytics/AnalyticsGoogle.d.ts +6 -0
  2. package/Analytics/index.d.ts +1 -0
  3. package/Auth/helpers.d.ts +17 -0
  4. package/Auth/index.d.ts +4 -0
  5. package/Auth/useLogin.d.ts +7 -0
  6. package/Auth/useLoginUrl.d.ts +1 -0
  7. package/Auth/useLogout.d.ts +6 -0
  8. package/Favicon/Favicon.d.ts +4 -0
  9. package/Favicon/index.d.ts +1 -0
  10. package/Forms/index.d.ts +2 -0
  11. package/Forms/useForm.d.ts +32 -0
  12. package/Forms/useSubmit.d.ts +24 -0
  13. package/Head/Head.d.ts +1 -0
  14. package/Head/index.d.ts +1 -0
  15. package/I18n/I18n.d.ts +48 -0
  16. package/I18n/index.d.ts +1 -0
  17. package/Img/Img.d.ts +21 -0
  18. package/Img/index.d.ts +1 -0
  19. package/Link/Link.d.ts +8 -0
  20. package/Link/index.d.ts +1 -0
  21. package/NextProgress/NextProgress.d.ts +14 -0
  22. package/NextProgress/index.d.ts +1 -0
  23. package/Seo/Seo.d.ts +3 -0
  24. package/Seo/SeoDefaults.d.ts +3 -0
  25. package/Seo/helpers.d.ts +48 -0
  26. package/Seo/index.d.ts +12 -0
  27. package/Theme/Theme.d.ts +46 -0
  28. package/Theme/index.d.ts +1 -0
  29. package/Theme.js +1905 -0
  30. package/_tslib.js +41 -0
  31. package/app/App--emotion.d.ts +10 -0
  32. package/app/App--sc.d.ts +10 -0
  33. package/app/App--vanilla.d.ts +10 -0
  34. package/app/AppAuth--emotion.d.ts +10 -0
  35. package/app/AppAuth--sc.d.ts +10 -0
  36. package/app/AppHead.d.ts +3 -0
  37. package/app/AppMain--vanilla.d.ts +27 -0
  38. package/app/AppMain.d.ts +34 -0
  39. package/app/AppTheme--emotion.d.ts +15 -0
  40. package/app/AppTheme--sc.d.ts +13 -0
  41. package/app/AppTheme--vanilla.d.ts +10 -0
  42. package/app/index.d.ts +11 -0
  43. package/app/motion-features.d.ts +2 -0
  44. package/app.js +235 -0
  45. package/config/index.d.ts +58 -0
  46. package/config.js +156 -880
  47. package/document/Document--emotion.d.ts +5 -0
  48. package/document/Document--sc.d.ts +11 -0
  49. package/document/Document--vanilla.d.ts +11 -0
  50. package/document/Document.d.ts +10 -0
  51. package/document/emotion.d.ts +5 -0
  52. package/document/index.d.ts +4 -0
  53. package/document.js +207 -0
  54. package/emotion.js +1329 -0
  55. package/es.object.assign.js +1074 -0
  56. package/es.string.replace.js +785 -0
  57. package/es.string.split.js +201 -0
  58. package/index.d.ts +12 -0
  59. package/index.esm.js +4437 -4406
  60. package/index.js +743 -0
  61. package/index.umd.js +4635 -4623
  62. package/package.json +12 -4
  63. package/types.d.ts +91 -0
  64. package/utils/api.d.ts +55 -0
  65. package/utils/index.d.ts +19 -0
  66. package/motion-features.esm.js +0 -2
package/_tslib.js ADDED
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ /*! *****************************************************************************
4
+ Copyright (c) Microsoft Corporation.
5
+
6
+ Permission to use, copy, modify, and/or distribute this software for any
7
+ purpose with or without fee is hereby granted.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
16
+ ***************************************************************************** */
17
+
18
+ function __rest(s, e) {
19
+ var t = {};
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
21
+ t[p] = s[p];
22
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
23
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
24
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
25
+ t[p[i]] = s[p[i]];
26
+ }
27
+ return t;
28
+ }
29
+
30
+ function __awaiter(thisArg, _arguments, P, generator) {
31
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
32
+ return new (P || (P = Promise))(function (resolve, reject) {
33
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
34
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
35
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
36
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
37
+ });
38
+ }
39
+
40
+ exports.__awaiter = __awaiter;
41
+ exports.__rest = __rest;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { AppProps as NextAppProps } from "next/app";
3
+ import { AppThemeEmotionProps } from "./AppTheme--emotion";
4
+ import { AppMainProps } from "./AppMain";
5
+ export declare type AppEmotionProps = NextAppProps & AppThemeEmotionProps & AppMainProps;
6
+ /**
7
+ * App
8
+ */
9
+ export declare const AppEmotion: React.FC<AppEmotionProps>;
10
+ export default AppEmotion;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { AppProps as NextAppProps } from "next/app";
3
+ import { AppThemeScProps } from "./AppTheme--sc";
4
+ import { AppMainProps } from "./AppMain";
5
+ export declare type AppBaseProps = NextAppProps & AppThemeScProps & AppMainProps;
6
+ /**
7
+ * App
8
+ */
9
+ export declare const AppBase: React.FC<AppBaseProps>;
10
+ export default AppBase;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { AppProps as NextAppProps } from "next/app";
3
+ import { AppThemeVanillaProps } from "./AppTheme--vanilla";
4
+ import { AppMainVanillaProps } from "./AppMain--vanilla";
5
+ export declare type AppVanillaProps = NextAppProps & AppThemeVanillaProps & AppMainVanillaProps;
6
+ /**
7
+ * App
8
+ */
9
+ export declare const AppVanilla: React.FC<AppVanillaProps>;
10
+ export default AppVanilla;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { AppProps as NextAppProps } from "next/app";
3
+ import { AppThemeEmotionProps } from "./AppTheme--emotion";
4
+ import { AppMainProps } from "./AppMain";
5
+ export declare type AppAuthEmotionProps = NextAppProps & AppThemeEmotionProps & AppMainProps;
6
+ /**
7
+ * App with authentication provided by `next-auth`
8
+ */
9
+ export declare const AppAuthEmotion: React.FC<AppAuthEmotionProps>;
10
+ export default AppAuthEmotion;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { AppProps as NextAppProps } from "next/app";
3
+ import { AppThemeScProps } from "./AppTheme--sc";
4
+ import { AppMainProps } from "./AppMain";
5
+ export declare type AppAuthScProps = NextAppProps & AppThemeScProps & AppMainProps;
6
+ /**
7
+ * App with authentication provided by `next-auth`
8
+ */
9
+ export declare const AppAuthSc: React.FC<AppAuthScProps>;
10
+ export default AppAuthSc;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ export declare type AppHeadProps = unknown;
3
+ export declare const AppHead: React.FC<AppHeadProps>;
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+ import { AppProps as NextAppProps } from "next/app";
3
+ import { SeoDefaultsProps } from "../Seo";
4
+ export declare type AppMainVanillaProps = NextAppProps & {
5
+ /**
6
+ * A wrapping layout component
7
+ */
8
+ Layout: React.FC<Record<string, unknown>>;
9
+ /**
10
+ * Seo site wide default configuration
11
+ */
12
+ seo?: SeoDefaultsProps;
13
+ /**
14
+ * JSX to render just after SEO
15
+ */
16
+ pre?: React.ReactNode;
17
+ /**
18
+ * JSX to render just at the end of the markup
19
+ */
20
+ post?: React.ReactNode;
21
+ };
22
+ /**
23
+ * App main
24
+ *
25
+ * It does not imply any specific styling or animation solution
26
+ */
27
+ export declare const AppMainVanilla: React.FC<AppMainVanillaProps>;
@@ -0,0 +1,34 @@
1
+ import React from "react";
2
+ import { AppProps as NextAppProps } from "next/app";
3
+ import { HTMLMotionProps } from "framer-motion";
4
+ import { SeoDefaultsProps } from "../Seo";
5
+ export declare type AppMainProps = NextAppProps & {
6
+ /**
7
+ * A wrapping layout component
8
+ */
9
+ Layout: React.FC<Record<string, unknown>>;
10
+ /**
11
+ * Seo site wide default configuration
12
+ */
13
+ seo?: SeoDefaultsProps;
14
+ /**
15
+ * It defaults to fade in/out
16
+ */
17
+ transition?: Omit<HTMLMotionProps<"div">, "key">;
18
+ /**
19
+ * JSX to render just after SEO
20
+ */
21
+ pre?: React.ReactNode;
22
+ /**
23
+ * JSX to render just at the end of the markup
24
+ */
25
+ post?: React.ReactNode;
26
+ };
27
+ /**
28
+ * App main
29
+ *
30
+ * It implies a setup for `styled-components` and `framer-motion` libraries.
31
+ *
32
+ * About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
33
+ */
34
+ export declare const AppMain: React.FC<AppMainProps>;
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import { AppProps as NextAppProps } from "next/app";
3
+ import { Theme } from "@mui/material/styles";
4
+ import { EmotionCache } from "@emotion/react";
5
+ export declare type AppThemeEmotionProps = NextAppProps & {
6
+ emotionCache?: EmotionCache;
7
+ /**
8
+ * A theme object
9
+ */
10
+ theme: Theme;
11
+ };
12
+ /**
13
+ * App theme with `emotion` (good for `@mui`)s
14
+ */
15
+ export declare const AppThemeEmotion: React.FC<AppThemeEmotionProps>;
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { AppProps as NextAppProps } from "next/app";
3
+ import { Theme } from "@koine/react";
4
+ export declare type AppThemeScProps = NextAppProps & {
5
+ /**
6
+ * A theme object
7
+ */
8
+ theme: Theme;
9
+ };
10
+ /**
11
+ * App theme with `styled-components`
12
+ */
13
+ export declare const AppThemeSc: React.FC<AppThemeScProps>;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { AppProps as NextAppProps } from "next/app";
3
+ import { ThemeProviderProps } from "../Theme";
4
+ export declare type AppThemeVanillaProps = NextAppProps & {
5
+ theme: ThemeProviderProps["defaultTheme"];
6
+ };
7
+ /**
8
+ * App theme with vanilla class based theme (good for `tailwindcss`)
9
+ */
10
+ export declare const AppThemeVanilla: React.FC<AppThemeVanillaProps>;
package/app/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export * from "./App--emotion";
2
+ export * from "./App--sc";
3
+ export * from "./App--vanilla";
4
+ export * from "./AppAuth--emotion";
5
+ export * from "./AppAuth--sc";
6
+ export * from "./AppHead";
7
+ export * from "./AppMain";
8
+ export * from "./AppMain--vanilla";
9
+ export * from "./AppTheme--emotion";
10
+ export * from "./AppTheme--sc";
11
+ export * from "./AppTheme--vanilla";
@@ -0,0 +1,2 @@
1
+ import { domMax } from "framer-motion";
2
+ export default domMax;
package/app.js ADDED
@@ -0,0 +1,235 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('./es.object.assign.js');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var React = require('react');
8
+ var Head = require('next/head');
9
+ var styles = require('@mui/material/styles');
10
+ var react = require('@emotion/react');
11
+ var CssBaseline = require('@mui/material/CssBaseline');
12
+ var react$1 = require('@koine/react');
13
+ var emotion = require('./emotion.js');
14
+ var Theme = require('./Theme.js');
15
+ var router = require('next/router');
16
+ require('./es.string.replace.js');
17
+ require('@koine/utils');
18
+ var styledComponents = require('styled-components');
19
+ var react$2 = require('next-auth/react');
20
+ require('next/script');
21
+
22
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
23
+
24
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
25
+ var Head__default = /*#__PURE__*/_interopDefaultLegacy(Head);
26
+ var CssBaseline__default = /*#__PURE__*/_interopDefaultLegacy(CssBaseline);
27
+
28
+ const AppHead = props => {
29
+ return jsxRuntime.jsx(Head__default["default"], Object.assign({}, props, {
30
+ children: jsxRuntime.jsx("meta", {
31
+ name: "viewport",
32
+ content: "width=device-width"
33
+ })
34
+ }));
35
+ };
36
+
37
+ let _ = t => t,
38
+ _t;
39
+
40
+ const clientSideEmotionCache = emotion.createEmotionCache();
41
+ /**
42
+ * App theme with `emotion` (good for `@mui`)s
43
+ */
44
+
45
+ const AppThemeEmotion = ({
46
+ emotionCache: _emotionCache = clientSideEmotionCache,
47
+ theme,
48
+ children
49
+ }) => {
50
+ return jsxRuntime.jsx(react.CacheProvider, Object.assign({
51
+ value: _emotionCache
52
+ }, {
53
+ children: jsxRuntime.jsxs(styles.ThemeProvider, Object.assign({
54
+ theme: theme
55
+ }, {
56
+ children: [jsxRuntime.jsx(CssBaseline__default["default"], {}), jsxRuntime.jsx(react.Global, {
57
+ styles: react.css(_t || (_t = _`
58
+ ${0}
59
+ `), react$1.stylesGlobal)
60
+ }), children]
61
+ }))
62
+ }));
63
+ };
64
+
65
+ /**
66
+ * App main
67
+ *
68
+ * It implies a setup for `styled-components` and `framer-motion` libraries.
69
+ *
70
+ * About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
71
+ */
72
+
73
+
74
+ const AppMain = ({
75
+ Component,
76
+ pageProps,
77
+ Layout,
78
+ // theme,
79
+ seo,
80
+ transition: _transition = {
81
+ initial: {
82
+ opacity: 0
83
+ },
84
+ animate: {
85
+ opacity: 1
86
+ },
87
+ exit: {
88
+ opacity: 0
89
+ }
90
+ },
91
+ pre,
92
+ post
93
+ }) => {
94
+ const {
95
+ pathname
96
+ } = router.useRouter();
97
+ return jsxRuntime.jsxs(React__default["default"].Fragment, {
98
+ children: [jsxRuntime.jsx(Theme.SeoDefaults, Object.assign({}, seo)), pre, jsxRuntime.jsx(Theme.NextProgress, {}), jsxRuntime.jsx(Layout, {
99
+ children: /*#__PURE__*/React.createElement(Component, Object.assign({}, pageProps, {
100
+ key: pathname
101
+ }))
102
+ }), post]
103
+ });
104
+ };
105
+
106
+ /**
107
+ * App
108
+ */
109
+
110
+ const AppEmotion = props => {
111
+ return jsxRuntime.jsxs(React__default["default"].Fragment, {
112
+ children: [jsxRuntime.jsx(AppHead, {}), jsxRuntime.jsx(AppThemeEmotion, Object.assign({}, props, {
113
+ children: jsxRuntime.jsx(AppMain, Object.assign({}, props))
114
+ }))]
115
+ });
116
+ };
117
+
118
+ /**
119
+ * App theme with `styled-components`
120
+ */
121
+
122
+ const AppThemeSc = ({
123
+ theme,
124
+ children
125
+ }) => {
126
+ return jsxRuntime.jsxs(styledComponents.ThemeProvider, Object.assign({
127
+ theme: theme
128
+ }, {
129
+ children: [jsxRuntime.jsx(react$1.StylesGlobal, {}), children]
130
+ }));
131
+ };
132
+
133
+ /**
134
+ * App
135
+ */
136
+
137
+ const AppBase = props => {
138
+ return jsxRuntime.jsxs(React__default["default"].Fragment, {
139
+ children: [jsxRuntime.jsx(AppHead, {}), jsxRuntime.jsx(AppThemeSc, Object.assign({}, props, {
140
+ children: jsxRuntime.jsx(AppMain, Object.assign({}, props))
141
+ }))]
142
+ });
143
+ };
144
+
145
+ /**
146
+ * App theme with vanilla class based theme (good for `tailwindcss`)
147
+ */
148
+
149
+ const AppThemeVanilla = ({
150
+ theme,
151
+ children
152
+ }) => {
153
+ // return (
154
+ // <ThemeVanillaProvider initialTheme={theme}>{children}</ThemeVanillaProvider>
155
+ // );
156
+ return jsxRuntime.jsx(Theme.ThemeProvider, Object.assign({
157
+ defaultTheme: theme,
158
+ attribute: "class"
159
+ }, {
160
+ children: children
161
+ }));
162
+ };
163
+
164
+ /**
165
+ * App main
166
+ *
167
+ * It does not imply any specific styling or animation solution
168
+ */
169
+
170
+ const AppMainVanilla = ({
171
+ Component,
172
+ pageProps,
173
+ Layout,
174
+ seo,
175
+ pre,
176
+ post
177
+ }) => {
178
+ return jsxRuntime.jsxs(React__default["default"].Fragment, {
179
+ children: [jsxRuntime.jsx(Theme.SeoDefaults, Object.assign({}, seo)), pre, jsxRuntime.jsx(Layout, {
180
+ children: jsxRuntime.jsx(Component, Object.assign({}, pageProps))
181
+ }), post]
182
+ });
183
+ };
184
+
185
+ /**
186
+ * App
187
+ */
188
+
189
+ const AppVanilla = props => {
190
+ return jsxRuntime.jsxs(React__default["default"].Fragment, {
191
+ children: [jsxRuntime.jsx(AppHead, {}), jsxRuntime.jsx(AppThemeVanilla, Object.assign({}, props, {
192
+ children: jsxRuntime.jsx(AppMainVanilla, Object.assign({}, props))
193
+ }))]
194
+ });
195
+ };
196
+
197
+ /**
198
+ * App with authentication provided by `next-auth`
199
+ */
200
+
201
+ const AppAuthEmotion = props => {
202
+ return jsxRuntime.jsxs(react$2.SessionProvider, Object.assign({
203
+ session: props.pageProps.session
204
+ }, {
205
+ children: [jsxRuntime.jsx(AppHead, {}), jsxRuntime.jsx(AppThemeEmotion, Object.assign({}, props, {
206
+ children: jsxRuntime.jsx(AppMain, Object.assign({}, props))
207
+ }))]
208
+ }));
209
+ };
210
+
211
+ /**
212
+ * App with authentication provided by `next-auth`
213
+ */
214
+
215
+ const AppAuthSc = props => {
216
+ return jsxRuntime.jsxs(react$2.SessionProvider, Object.assign({
217
+ session: props.pageProps.session
218
+ }, {
219
+ children: [jsxRuntime.jsx(AppHead, {}), jsxRuntime.jsx(AppThemeSc, Object.assign({}, props, {
220
+ children: jsxRuntime.jsx(AppMain, Object.assign({}, props))
221
+ }))]
222
+ }));
223
+ };
224
+
225
+ exports.AppAuthEmotion = AppAuthEmotion;
226
+ exports.AppAuthSc = AppAuthSc;
227
+ exports.AppBase = AppBase;
228
+ exports.AppEmotion = AppEmotion;
229
+ exports.AppHead = AppHead;
230
+ exports.AppMain = AppMain;
231
+ exports.AppMainVanilla = AppMainVanilla;
232
+ exports.AppThemeEmotion = AppThemeEmotion;
233
+ exports.AppThemeSc = AppThemeSc;
234
+ exports.AppThemeVanilla = AppThemeVanilla;
235
+ exports.AppVanilla = AppVanilla;
@@ -0,0 +1,58 @@
1
+ import type { NextConfig } from "next";
2
+ import type { Redirect, Rewrite } from "next/dist/lib/load-custom-routes";
3
+ /**
4
+ * Normalise pathname
5
+ *
6
+ * From a path like `/some//malformed/path///` it returns `some/malformed/path`
7
+ *
8
+ * - Removes subsequent slashes
9
+ * - Removing initial and ending slashes
10
+ */
11
+ export declare function normaliseUrlPathname(pathname: string): string;
12
+ /**
13
+ * Clean a pathname and encode each part
14
+ *
15
+ * @see {@link normaliseUrlPathname}
16
+ */
17
+ export declare function encodePathname(pathname: string): string;
18
+ /**
19
+ */
20
+ export declare function getPathRedirect(locale: string, localisedPathname: string, templateName: string, dynamic?: boolean, permanent?: boolean): {
21
+ source: string;
22
+ destination: string;
23
+ permanent: boolean;
24
+ locale: false;
25
+ };
26
+ /**
27
+ */
28
+ export declare function getPathRewrite(source: string, destination: string, dynamic?: boolean): {
29
+ source: string;
30
+ destination: string;
31
+ };
32
+ /**
33
+ */
34
+ export declare function getRedirects({ defaultLocale, routes, dynamicRoutes, permanent, }: {
35
+ defaultLocale: string;
36
+ routes: Record<string, string>;
37
+ dynamicRoutes: Record<string, boolean>;
38
+ permanent?: boolean;
39
+ }): Promise<Redirect[]>;
40
+ /**
41
+ */
42
+ export declare function getRewrites({ routes, dynamicRoutes, }: {
43
+ routes: Record<string, string>;
44
+ dynamicRoutes: Record<string, boolean>;
45
+ }): Promise<Rewrite[]>;
46
+ declare type KoineNextConfig = {
47
+ /** @default true Nx monorepo setup */
48
+ nx?: boolean;
49
+ /** @default true Svg to react components */
50
+ svg?: boolean;
51
+ /** @default true Styled components enabled */
52
+ sc?: boolean;
53
+ };
54
+ /**
55
+ * Get Next.js config with some basic opinionated defaults
56
+ */
57
+ export declare function withKoine({ nx, svg, sc, ...nextConfig }?: NextConfig & KoineNextConfig): NextConfig;
58
+ export default withKoine;