@koine/next 1.0.8 → 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 +0 -0
- package/Analytics/AnalyticsGoogle.js +2 -2
- package/Analytics/index.d.ts +0 -0
- package/Analytics/index.js +0 -0
- package/Analytics/package.json +6 -0
- package/Auth/helpers.d.ts +0 -0
- package/Auth/helpers.js +0 -0
- package/Auth/index.d.ts +0 -0
- package/Auth/index.js +0 -0
- package/Auth/package.json +6 -0
- package/Auth/useLogin.d.ts +1 -1
- package/Auth/useLogin.js +4 -1
- package/Auth/useLoginUrl.d.ts +0 -0
- package/Auth/useLoginUrl.js +0 -0
- package/Auth/useLogout.d.ts +0 -0
- package/Auth/useLogout.js +0 -0
- package/Favicon/Favicon.d.ts +0 -0
- package/Favicon/Favicon.js +1 -1
- package/Favicon/index.d.ts +0 -0
- package/Favicon/index.js +0 -0
- package/Favicon/package.json +6 -0
- package/Forms/index.d.ts +0 -0
- package/Forms/index.js +0 -0
- package/Forms/package.json +6 -0
- package/Forms/useForm.d.ts +0 -0
- package/Forms/useForm.js +7 -3
- package/Forms/useSubmit.d.ts +0 -0
- package/Forms/useSubmit.js +10 -7
- package/Head/Head.d.ts +0 -0
- package/Head/Head.js +0 -0
- package/Head/index.d.ts +0 -0
- package/Head/index.js +0 -0
- package/Head/package.json +6 -0
- package/I18n/I18n.d.ts +3 -7
- package/I18n/I18n.js +2 -14
- package/I18n/index.d.ts +0 -0
- package/I18n/index.js +0 -0
- package/I18n/package.json +6 -0
- package/Img/Img.d.ts +4 -4
- package/Img/Img.js +2 -4
- package/Img/index.d.ts +0 -0
- package/Img/index.js +0 -0
- package/Img/package.json +6 -0
- package/Link/Link.d.ts +4 -3
- package/Link/Link.js +2 -5
- package/Link/index.d.ts +0 -0
- package/Link/index.js +0 -0
- package/Link/package.json +6 -0
- package/NextProgress/NextProgress.d.ts +20 -9
- package/NextProgress/NextProgress.js +2 -3
- package/NextProgress/index.d.ts +2 -1
- package/NextProgress/index.js +1 -1
- package/NextProgress/package.json +6 -0
- package/README.md +0 -0
- package/Seo/Seo.d.ts +0 -0
- package/Seo/Seo.js +0 -0
- package/Seo/SeoDefaults.d.ts +0 -0
- package/Seo/SeoDefaults.js +0 -0
- package/Seo/helpers.d.ts +0 -0
- package/Seo/helpers.js +17 -19
- package/Seo/index.d.ts +0 -0
- package/Seo/index.js +0 -0
- package/Seo/package.json +6 -0
- package/Theme/Theme.d.ts +3 -3
- package/Theme/Theme.js +18 -18
- package/Theme/index.d.ts +0 -0
- package/Theme/index.js +0 -0
- package/Theme/package.json +6 -0
- package/app/AppHead.d.ts +1 -2
- package/app/AppHead.js +2 -2
- package/app/AppMain.d.ts +35 -0
- package/app/AppMain.js +1 -0
- package/app/css/AppMain.d.ts +8 -0
- package/app/{AppMain--vanilla.js → css/AppMain.js} +3 -3
- package/app/css/AppTheme.d.ts +10 -0
- package/app/{AppTheme--vanilla.js → css/AppTheme.js} +3 -3
- 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} +3 -3
- package/app/{AppTheme--emotion.js → em/AppTheme.js} +5 -5
- 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 +1 -10
- package/app/index.js +1 -10
- 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 +14 -1
- package/config/index.js +68 -38
- package/config/package.json +6 -0
- package/document/Document.d.ts +7 -2
- package/document/Document.js +8 -3
- 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/{Document--emotion.js → em/index.js} +24 -11
- package/document/em/package.json +6 -0
- package/document/index.d.ts +2 -4
- package/document/index.js +2 -4
- package/document/package.json +6 -0
- package/document/{Document--sc.d.ts → sc/index.d.ts} +11 -2
- package/document/sc/index.js +44 -0
- package/document/sc/package.json +6 -0
- package/index.d.ts +0 -3
- package/index.js +0 -3
- 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 +2 -35
- package/typings.d.ts +10 -7
- package/utils/api.d.ts +0 -0
- package/utils/api.js +8 -6
- package/utils/emotion-cache.d.ts +0 -0
- package/utils/emotion-cache.js +0 -0
- package/utils/index.d.ts +0 -1
- package/utils/index.js +0 -1
- package/utils/package.json +6 -0
- package/app/App--emotion.d.ts +0 -10
- package/app/App--emotion.js +0 -11
- package/app/App--sc.d.ts +0 -10
- package/app/App--sc.js +0 -11
- package/app/App--vanilla.d.ts +0 -10
- package/app/App--vanilla.js +0 -11
- package/app/AppAuth--emotion.d.ts +0 -10
- package/app/AppAuth--emotion.js +0 -12
- package/app/AppAuth--sc.d.ts +0 -10
- package/app/AppAuth--sc.js +0 -12
- package/app/AppMain--emotion.d.ts +0 -34
- package/app/AppMain--emotion.js +0 -27
- package/app/AppMain--sc.d.ts +0 -34
- package/app/AppMain--sc.js +0 -27
- package/app/AppMain--vanilla.d.ts +0 -27
- package/app/AppTheme--sc.d.ts +0 -13
- package/app/AppTheme--sc.js +0 -9
- package/app/AppTheme--vanilla.d.ts +0 -10
- package/app/motion-features.d.ts +0 -2
- package/app/motion-features.js +0 -2
- package/document/Document--emotion.d.ts +0 -5
- package/document/Document--sc.js +0 -33
- package/document/Document--vanilla.d.ts +0 -11
- package/document/Document--vanilla.js +0 -20
- package/index.umd.js +0 -6621
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThemeProvider = exports.useTheme = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
/**
|
|
7
|
+
* @file
|
|
8
|
+
*
|
|
9
|
+
* Adapted from [next-themes](https://github.com/pacocoursey/next-themes)
|
|
10
|
+
*/
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const script_1 = tslib_1.__importDefault(require("next/script"));
|
|
13
|
+
const utils_1 = require("@koine/utils");
|
|
14
|
+
const THEME_STORAGE_KEY = "theme";
|
|
15
|
+
const colorSchemes = ["light", "dark"];
|
|
16
|
+
const MEDIA = "(prefers-color-scheme: dark)";
|
|
17
|
+
const ThemeContext = (0, react_1.createContext)({
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
19
|
+
setTheme: (_) => { },
|
|
20
|
+
themes: [],
|
|
21
|
+
});
|
|
22
|
+
const useTheme = () => (0, react_1.useContext)(ThemeContext);
|
|
23
|
+
exports.useTheme = useTheme;
|
|
24
|
+
const ThemeProvider = ({ forcedTheme, disableTransitionOnChange = false, enableSystem = true, enableColorScheme = true, themes = ["light", "dark"], defaultTheme = enableSystem ? "system" : "light", attribute = "data-theme", value, children, nonce, }) => {
|
|
25
|
+
const [theme, setThemeState] = (0, react_1.useState)(() => getTheme(THEME_STORAGE_KEY, defaultTheme));
|
|
26
|
+
const [resolvedTheme, setResolvedTheme] = (0, react_1.useState)(() => getTheme(THEME_STORAGE_KEY));
|
|
27
|
+
const attrs = !value ? themes : Object.values(value);
|
|
28
|
+
const applyTheme = (0, react_1.useCallback)((theme) => {
|
|
29
|
+
let resolved = theme;
|
|
30
|
+
if (utils_1.isServer || !resolved)
|
|
31
|
+
return;
|
|
32
|
+
// If theme is system, resolve it before setting theme
|
|
33
|
+
if (theme === "system" && enableSystem) {
|
|
34
|
+
resolved = getSystemTheme();
|
|
35
|
+
}
|
|
36
|
+
const name = value ? value[resolved] : resolved;
|
|
37
|
+
const enable = disableTransitionOnChange ? disableAnimation() : null;
|
|
38
|
+
const d = document.documentElement;
|
|
39
|
+
if (attribute === "class") {
|
|
40
|
+
d.classList.remove(...attrs);
|
|
41
|
+
if (name)
|
|
42
|
+
d.classList.add(name);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
if (name) {
|
|
46
|
+
d.setAttribute(attribute, name);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
d.removeAttribute(attribute);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (enableColorScheme) {
|
|
53
|
+
const fallback = colorSchemes.includes(defaultTheme)
|
|
54
|
+
? defaultTheme
|
|
55
|
+
: "";
|
|
56
|
+
const colorScheme = colorSchemes.includes(resolved)
|
|
57
|
+
? resolved
|
|
58
|
+
: fallback;
|
|
59
|
+
d.style.colorScheme = colorScheme;
|
|
60
|
+
}
|
|
61
|
+
enable?.();
|
|
62
|
+
}, [
|
|
63
|
+
attribute,
|
|
64
|
+
attrs,
|
|
65
|
+
defaultTheme,
|
|
66
|
+
disableTransitionOnChange,
|
|
67
|
+
enableColorScheme,
|
|
68
|
+
enableSystem,
|
|
69
|
+
value,
|
|
70
|
+
]);
|
|
71
|
+
const setTheme = (0, react_1.useCallback)((theme) => {
|
|
72
|
+
setThemeState(theme);
|
|
73
|
+
// Save to storage
|
|
74
|
+
try {
|
|
75
|
+
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
// Unsupported
|
|
79
|
+
}
|
|
80
|
+
}, []);
|
|
81
|
+
const handleMediaQuery = (0, react_1.useCallback)((e) => {
|
|
82
|
+
const resolved = getSystemTheme(e);
|
|
83
|
+
setResolvedTheme(resolved);
|
|
84
|
+
if (theme === "system" && enableSystem && !forcedTheme) {
|
|
85
|
+
applyTheme("system");
|
|
86
|
+
}
|
|
87
|
+
}, [theme, enableSystem, forcedTheme, applyTheme]);
|
|
88
|
+
// Always listen to System preference
|
|
89
|
+
(0, react_1.useEffect)(() => {
|
|
90
|
+
const media = window.matchMedia(MEDIA);
|
|
91
|
+
// Intentionally use deprecated listener methods to support iOS & old browsers
|
|
92
|
+
media.addListener(handleMediaQuery);
|
|
93
|
+
handleMediaQuery(media);
|
|
94
|
+
return () => media.removeListener(handleMediaQuery);
|
|
95
|
+
}, [handleMediaQuery]);
|
|
96
|
+
// localStorage event handling
|
|
97
|
+
(0, react_1.useEffect)(() => {
|
|
98
|
+
const handleStorage = (e) => {
|
|
99
|
+
if (e.key !== THEME_STORAGE_KEY) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// If default theme set, use it if localstorage === null (happens on local storage manual deletion)
|
|
103
|
+
const theme = e.newValue || defaultTheme;
|
|
104
|
+
setTheme(theme);
|
|
105
|
+
};
|
|
106
|
+
window.addEventListener("storage", handleStorage);
|
|
107
|
+
return () => window.removeEventListener("storage", handleStorage);
|
|
108
|
+
}, [defaultTheme, setTheme]);
|
|
109
|
+
// Whenever theme or forcedTheme changes, apply it
|
|
110
|
+
(0, react_1.useEffect)(() => {
|
|
111
|
+
applyTheme(forcedTheme ?? theme);
|
|
112
|
+
}, [applyTheme, forcedTheme, theme]);
|
|
113
|
+
return ((0, jsx_runtime_1.jsxs)(ThemeContext.Provider, { value: {
|
|
114
|
+
theme,
|
|
115
|
+
setTheme,
|
|
116
|
+
forcedTheme,
|
|
117
|
+
resolvedTheme: theme === "system" ? resolvedTheme : theme,
|
|
118
|
+
themes: enableSystem ? [...themes, "system"] : themes,
|
|
119
|
+
systemTheme: (enableSystem ? resolvedTheme : undefined),
|
|
120
|
+
}, children: [(0, jsx_runtime_1.jsx)(ThemeScript, { ...{
|
|
121
|
+
forcedTheme,
|
|
122
|
+
disableTransitionOnChange,
|
|
123
|
+
enableSystem,
|
|
124
|
+
enableColorScheme,
|
|
125
|
+
themes,
|
|
126
|
+
defaultTheme,
|
|
127
|
+
attribute,
|
|
128
|
+
value,
|
|
129
|
+
children,
|
|
130
|
+
attrs,
|
|
131
|
+
nonce,
|
|
132
|
+
} }), children] }));
|
|
133
|
+
};
|
|
134
|
+
exports.ThemeProvider = ThemeProvider;
|
|
135
|
+
const ThemeScript = (0, react_1.memo)(({ forcedTheme, attribute, enableSystem, enableColorScheme, defaultTheme, value, attrs, nonce, }) => {
|
|
136
|
+
const defaultSystem = defaultTheme === "system";
|
|
137
|
+
// Code-golfing the amount of characters in the script
|
|
138
|
+
const optimization = (() => {
|
|
139
|
+
const removeClasses = `d.remove(${attrs
|
|
140
|
+
.map((t) => `'${t}'`)
|
|
141
|
+
.join(",")})`;
|
|
142
|
+
return `var d=document.documentElement.classList;${removeClasses};`;
|
|
143
|
+
})();
|
|
144
|
+
const fallbackColorScheme = (() => {
|
|
145
|
+
if (!enableColorScheme) {
|
|
146
|
+
return "";
|
|
147
|
+
}
|
|
148
|
+
const fallback = colorSchemes.includes(defaultTheme)
|
|
149
|
+
? defaultTheme
|
|
150
|
+
: null;
|
|
151
|
+
if (fallback) {
|
|
152
|
+
return `if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${defaultTheme}'`;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
return `if(e==='light'||e==='dark')d.style.colorScheme=e`;
|
|
156
|
+
}
|
|
157
|
+
})();
|
|
158
|
+
const updateDOM = (name, literal = false, setColorScheme = true) => {
|
|
159
|
+
const resolvedName = value ? value[name] : name;
|
|
160
|
+
const val = literal ? name + `|| ''` : `'${resolvedName}'`;
|
|
161
|
+
let text = "";
|
|
162
|
+
// MUCH faster to set colorScheme alongside HTML attribute/class
|
|
163
|
+
// as it only incurs 1 style recalculation rather than 2
|
|
164
|
+
// This can save over 250ms of work for pages with big DOM
|
|
165
|
+
if (enableColorScheme &&
|
|
166
|
+
setColorScheme &&
|
|
167
|
+
!literal &&
|
|
168
|
+
colorSchemes.includes(name)) {
|
|
169
|
+
text += `d.style.colorScheme = '${name}';`;
|
|
170
|
+
}
|
|
171
|
+
if (attribute === "class") {
|
|
172
|
+
if (literal || resolvedName) {
|
|
173
|
+
text += `d.add(${val})`;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
text += `null`;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
if (resolvedName) {
|
|
181
|
+
text += `d[s](n, ${val})`;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return text;
|
|
185
|
+
};
|
|
186
|
+
const scriptSrc = (() => {
|
|
187
|
+
if (forcedTheme) {
|
|
188
|
+
return `!function(){${optimization}${updateDOM(forcedTheme)}}()`;
|
|
189
|
+
}
|
|
190
|
+
if (enableSystem) {
|
|
191
|
+
return `!function(){try {${optimization}var e=localStorage.getItem('${THEME_STORAGE_KEY}');if("system"===e||(!e&&${defaultSystem})){var t="${MEDIA}",m=window.matchMedia(t);if(m.media!==t||m.matches){${updateDOM("dark")}}else{${updateDOM("light")}}}else if(e){${value ? `var x=${JSON.stringify(value)};` : ""}${updateDOM(value ? `x[e]` : "e", true)}}${!defaultSystem
|
|
192
|
+
? `else{` + updateDOM(defaultTheme, false, false) + "}"
|
|
193
|
+
: ""}${fallbackColorScheme}}catch(e){}}()`;
|
|
194
|
+
}
|
|
195
|
+
return `!function(){try{${optimization}var e=localStorage.getItem("${THEME_STORAGE_KEY}");if(e){${value ? `var x=${JSON.stringify(value)};` : ""}${updateDOM(value ? `x[e]` : "e", true)}}else{${updateDOM(defaultTheme, false, false)};}${fallbackColorScheme}}catch(t){}}();`;
|
|
196
|
+
})();
|
|
197
|
+
// We MUST use next/script's `beforeInteractive` strategy to avoid flashing on load.
|
|
198
|
+
// However, it only accepts the `src` prop, not `dangerouslySetInnerHTML` or `children`
|
|
199
|
+
// But our script cannot be external because it changes at runtime based on React props
|
|
200
|
+
// so we trick next/script by passing `src` as a base64 JS script
|
|
201
|
+
const encodedScript = `data:text/javascript;base64,${encodeBase64(scriptSrc)}`;
|
|
202
|
+
return ((0, jsx_runtime_1.jsx)(script_1.default, { id: "next-theme-script", strategy: "beforeInteractive", src: encodedScript, nonce: nonce }));
|
|
203
|
+
},
|
|
204
|
+
// Never re-render this component
|
|
205
|
+
() => true);
|
|
206
|
+
// Helpers
|
|
207
|
+
const getTheme = (key, fallback) => {
|
|
208
|
+
if (utils_1.isServer)
|
|
209
|
+
return undefined;
|
|
210
|
+
let theme;
|
|
211
|
+
try {
|
|
212
|
+
theme = localStorage.getItem(key) || undefined;
|
|
213
|
+
}
|
|
214
|
+
catch (e) {
|
|
215
|
+
// Unsupported
|
|
216
|
+
}
|
|
217
|
+
return theme || fallback;
|
|
218
|
+
};
|
|
219
|
+
const disableAnimation = () => {
|
|
220
|
+
const css = document.createElement("style");
|
|
221
|
+
css.appendChild(document.createTextNode(`*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`));
|
|
222
|
+
document.head.appendChild(css);
|
|
223
|
+
return () => {
|
|
224
|
+
// Force restyle
|
|
225
|
+
(() => window.getComputedStyle(document.body))();
|
|
226
|
+
// Wait for next tick before removing
|
|
227
|
+
setTimeout(() => {
|
|
228
|
+
document.head.removeChild(css);
|
|
229
|
+
}, 1);
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
const getSystemTheme = (e) => {
|
|
233
|
+
if (!e)
|
|
234
|
+
e = window.matchMedia(MEDIA);
|
|
235
|
+
const isDark = e.matches;
|
|
236
|
+
const systemTheme = isDark ? "dark" : "light";
|
|
237
|
+
return systemTheme;
|
|
238
|
+
};
|
|
239
|
+
const encodeBase64 = (str) => {
|
|
240
|
+
return utils_1.isServer ? Buffer.from(str).toString("base64") : btoa(str);
|
|
241
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppHead = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const head_1 = tslib_1.__importDefault(require("next/head"));
|
|
7
|
+
const AppHead = () => {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(head_1.default, { children: (0, jsx_runtime_1.jsx)("meta", { name: "viewport", content: "width=device-width" }) }));
|
|
9
|
+
};
|
|
10
|
+
exports.AppHead = AppHead;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppMain = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
+
const Seo_1 = require("../../Seo");
|
|
8
|
+
/**
|
|
9
|
+
* App main
|
|
10
|
+
*
|
|
11
|
+
* It does not imply any specific styling or animation solution
|
|
12
|
+
*/
|
|
13
|
+
const AppMain = ({ Component, pageProps, Layout, seo, pre, post, }) => {
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(Seo_1.SeoDefaults, { ...seo }), pre, (0, jsx_runtime_1.jsx)(Layout, { children: (0, jsx_runtime_1.jsx)(Component, { ...pageProps }) }), post] }));
|
|
15
|
+
};
|
|
16
|
+
exports.AppMain = AppMain;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppTheme = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
// import { ThemeVanillaProvider, ThemeVanillaValue } from "@koine/react";
|
|
6
|
+
const Theme_1 = require("../../Theme");
|
|
7
|
+
/**
|
|
8
|
+
* App theme with vanilla class based theme (good for `tailwindcss`)
|
|
9
|
+
*/
|
|
10
|
+
const AppTheme = ({ theme, children }) => {
|
|
11
|
+
// return (
|
|
12
|
+
// <ThemeVanillaProvider initialTheme={theme}>{children}</ThemeVanillaProvider>
|
|
13
|
+
// );
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(Theme_1.ThemeProvider, { defaultTheme: theme, attribute: "class", children: children }));
|
|
15
|
+
};
|
|
16
|
+
exports.AppTheme = AppTheme;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NextApp = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
+
const react_2 = require("next-auth/react");
|
|
8
|
+
const AppHead_1 = require("../../AppHead");
|
|
9
|
+
const AppTheme_1 = require("../AppTheme");
|
|
10
|
+
const AppMain_1 = require("../AppMain");
|
|
11
|
+
/**
|
|
12
|
+
* App with authentication provided by `next-auth`
|
|
13
|
+
*/
|
|
14
|
+
const NextApp = (props) => {
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.default.StrictMode, { children: [(0, jsx_runtime_1.jsx)(AppHead_1.AppHead, {}), (0, jsx_runtime_1.jsx)(react_2.SessionProvider, { session: props.pageProps.session, children: (0, jsx_runtime_1.jsx)(AppTheme_1.AppTheme, { ...props, children: (0, jsx_runtime_1.jsx)(AppMain_1.AppMain, { ...props }) }) })] }));
|
|
16
|
+
};
|
|
17
|
+
exports.NextApp = NextApp;
|
|
18
|
+
exports.default = exports.NextApp;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NextApp = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
+
const AppHead_1 = require("../AppHead");
|
|
8
|
+
const AppTheme_1 = require("./AppTheme");
|
|
9
|
+
const AppMain_1 = require("./AppMain");
|
|
10
|
+
/**
|
|
11
|
+
* App
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { NextApp, NextAppProps } from "@koine/next/app/css/auth";
|
|
17
|
+
* import { Favicon, AnalyticsGoogle } from "@koine/next";
|
|
18
|
+
* import { theme } from "src/helpers/theme";
|
|
19
|
+
* import { Layout } from "src/components/Layout";
|
|
20
|
+
* // import "@fontsource/myfont/800.css";
|
|
21
|
+
* // import "src/helpers/theme.css";
|
|
22
|
+
*
|
|
23
|
+
* const motion = () => import("@koine/react/m/max").then((m) => m.default);
|
|
24
|
+
*
|
|
25
|
+
* export default function App(props: NextAppProps) {
|
|
26
|
+
* return (
|
|
27
|
+
* <NextApp
|
|
28
|
+
* {...props}
|
|
29
|
+
* Layout={Layout}
|
|
30
|
+
* theme={theme}
|
|
31
|
+
* seo={{
|
|
32
|
+
* titleTemplate: "%s | MyApp",
|
|
33
|
+
* defaultTitle: "MyApp",
|
|
34
|
+
* openGraph: {
|
|
35
|
+
* type: "website",
|
|
36
|
+
* locale: "en_US",
|
|
37
|
+
* url: "https://myapp.com/",
|
|
38
|
+
* site_name: "MyApp",
|
|
39
|
+
* },
|
|
40
|
+
* twitter: {
|
|
41
|
+
* handle: "@MklrNl",
|
|
42
|
+
* site: "@MyApp",
|
|
43
|
+
* cardType: "summary_large_image",
|
|
44
|
+
* },
|
|
45
|
+
* }}
|
|
46
|
+
* pre={
|
|
47
|
+
* <>
|
|
48
|
+
* <AnalyticsGoogle id="UA-xxxxxxxx-x" />
|
|
49
|
+
* <Favicon name="MyApp" color="#000000" />
|
|
50
|
+
* </>
|
|
51
|
+
* }
|
|
52
|
+
* />
|
|
53
|
+
* );
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
const NextApp = (props) => {
|
|
59
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.default.StrictMode, { children: [(0, jsx_runtime_1.jsx)(AppHead_1.AppHead, {}), (0, jsx_runtime_1.jsx)(AppTheme_1.AppTheme, { ...props, children: (0, jsx_runtime_1.jsx)(AppMain_1.AppMain, { ...props }) })] }));
|
|
60
|
+
};
|
|
61
|
+
exports.NextApp = NextApp;
|
|
62
|
+
exports.default = exports.NextApp;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppMain = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const router_1 = require("next/router");
|
|
7
|
+
const framer_motion_1 = require("framer-motion");
|
|
8
|
+
const m_1 = require("@koine/react/m");
|
|
9
|
+
const Seo_1 = require("../../Seo");
|
|
10
|
+
const NextProgress_1 = require("../../NextProgress");
|
|
11
|
+
/**
|
|
12
|
+
* App main
|
|
13
|
+
*
|
|
14
|
+
* It implies a setup for `styled-components` and `framer-motion` libraries.
|
|
15
|
+
*
|
|
16
|
+
* About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
|
|
17
|
+
*/
|
|
18
|
+
const AppMain = ({ Component, pageProps, Layout, ProgressOverlay, seo, motion, transition = {
|
|
19
|
+
initial: { opacity: 0 },
|
|
20
|
+
animate: { opacity: 1 },
|
|
21
|
+
exit: { opacity: 0 },
|
|
22
|
+
}, pre, post, }) => {
|
|
23
|
+
const { pathname } = (0, router_1.useRouter)();
|
|
24
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Seo_1.SeoDefaults, { ...seo }), pre, (0, jsx_runtime_1.jsxs)(m_1.MotionProvider, { features: motion, children: [ProgressOverlay && (0, jsx_runtime_1.jsx)(NextProgress_1.NextProgress, { Overlay: ProgressOverlay }), (0, jsx_runtime_1.jsx)(Layout, { children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { exitBeforeEnter: true, initial: false, children: (0, jsx_runtime_1.jsx)(framer_motion_1.m.div, { ...transition, children: (0, react_1.createElement)(Component, { ...pageProps, key: pathname }) }, pathname) }) })] }), post] }));
|
|
25
|
+
};
|
|
26
|
+
exports.AppMain = AppMain;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppTheme = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const styles_1 = require("@mui/material/styles");
|
|
7
|
+
const react_1 = require("@emotion/react");
|
|
8
|
+
const CssBaseline_1 = tslib_1.__importDefault(require("@mui/material/CssBaseline"));
|
|
9
|
+
const react_2 = require("@emotion/react");
|
|
10
|
+
const sc_1 = require("@koine/react/sc");
|
|
11
|
+
const emotion_cache_1 = require("../../utils/emotion-cache");
|
|
12
|
+
// client-side cache, shared for the whole session of the user in the browser.
|
|
13
|
+
const clientSideEmotionCache = (0, emotion_cache_1.createEmotionCache)();
|
|
14
|
+
/**
|
|
15
|
+
* App theme with `emotion` (good for `@mui`)s
|
|
16
|
+
*/
|
|
17
|
+
const AppTheme = ({ emotionCache = clientSideEmotionCache, theme, children, }) => {
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(react_1.CacheProvider, { value: emotionCache, children: (0, jsx_runtime_1.jsxs)(styles_1.ThemeProvider, { theme: theme, children: [(0, jsx_runtime_1.jsx)(CssBaseline_1.default, {}), (0, jsx_runtime_1.jsx)(react_2.Global, { styles: (0, react_2.css) `
|
|
19
|
+
${sc_1.stylesGlobal}
|
|
20
|
+
` }), children] }) }));
|
|
21
|
+
};
|
|
22
|
+
exports.AppTheme = AppTheme;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NextApp = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
+
const react_2 = require("next-auth/react");
|
|
8
|
+
const AppHead_1 = require("../../AppHead");
|
|
9
|
+
const AppTheme_1 = require("../AppTheme");
|
|
10
|
+
const AppMain_1 = require("../AppMain");
|
|
11
|
+
/**
|
|
12
|
+
* App with authentication provided by `next-auth`
|
|
13
|
+
*/
|
|
14
|
+
const NextApp = (props) => {
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.default.StrictMode, { children: [(0, jsx_runtime_1.jsx)(AppHead_1.AppHead, {}), (0, jsx_runtime_1.jsx)(react_2.SessionProvider, { session: props.pageProps.session, children: (0, jsx_runtime_1.jsx)(AppTheme_1.AppTheme, { ...props, children: (0, jsx_runtime_1.jsx)(AppMain_1.AppMain, { ...props }) }) })] }));
|
|
16
|
+
};
|
|
17
|
+
exports.NextApp = NextApp;
|
|
18
|
+
exports.default = exports.NextApp;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NextApp = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
+
const AppHead_1 = require("../AppHead");
|
|
8
|
+
const AppTheme_1 = require("./AppTheme");
|
|
9
|
+
const AppMain_1 = require("./AppMain");
|
|
10
|
+
/**
|
|
11
|
+
* App
|
|
12
|
+
*/
|
|
13
|
+
const NextApp = (props) => {
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.default.StrictMode, { children: [(0, jsx_runtime_1.jsx)(AppHead_1.AppHead, {}), (0, jsx_runtime_1.jsx)(AppTheme_1.AppTheme, { ...props, children: (0, jsx_runtime_1.jsx)(AppMain_1.AppMain, { ...props }) })] }));
|
|
15
|
+
};
|
|
16
|
+
exports.NextApp = NextApp;
|
|
17
|
+
exports.default = exports.NextApp;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppMain = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const router_1 = require("next/router");
|
|
7
|
+
const framer_motion_1 = require("framer-motion");
|
|
8
|
+
const m_1 = require("@koine/react/m");
|
|
9
|
+
const Seo_1 = require("../../Seo");
|
|
10
|
+
const NextProgress_1 = require("../../NextProgress");
|
|
11
|
+
/**
|
|
12
|
+
* App main
|
|
13
|
+
*
|
|
14
|
+
* It implies a setup for `styled-components` and `framer-motion` libraries.
|
|
15
|
+
*
|
|
16
|
+
* About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
|
|
17
|
+
*/
|
|
18
|
+
const AppMain = ({ Component, pageProps, Layout, ProgressOverlay, seo, motion, transition = {
|
|
19
|
+
initial: { opacity: 0 },
|
|
20
|
+
animate: { opacity: 1 },
|
|
21
|
+
exit: { opacity: 0 },
|
|
22
|
+
}, pre, post, }) => {
|
|
23
|
+
const { pathname } = (0, router_1.useRouter)();
|
|
24
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Seo_1.SeoDefaults, { ...seo }), pre, (0, jsx_runtime_1.jsxs)(m_1.MotionProvider, { features: motion, children: [ProgressOverlay && (0, jsx_runtime_1.jsx)(NextProgress_1.NextProgress, { Overlay: ProgressOverlay }), (0, jsx_runtime_1.jsx)(Layout, { children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { exitBeforeEnter: true, initial: false, children: (0, jsx_runtime_1.jsx)(framer_motion_1.m.div, { ...transition, children: (0, react_1.createElement)(Component, { ...pageProps, key: pathname }) }, pathname) }) })] }), post] }));
|
|
25
|
+
};
|
|
26
|
+
exports.AppMain = AppMain;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppTheme = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const styled_components_1 = require("styled-components");
|
|
6
|
+
const sc_1 = require("@koine/react/sc");
|
|
7
|
+
/**
|
|
8
|
+
* App theme with `styled-components`
|
|
9
|
+
*/
|
|
10
|
+
const AppTheme = ({ theme, children }) => {
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)(styled_components_1.ThemeProvider, { theme: theme, children: [(0, jsx_runtime_1.jsx)(sc_1.StylesGlobal, {}), children] }));
|
|
12
|
+
};
|
|
13
|
+
exports.AppTheme = AppTheme;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NextApp = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
+
const react_2 = require("next-auth/react");
|
|
8
|
+
const AppHead_1 = require("../../AppHead");
|
|
9
|
+
const AppTheme_1 = require("../AppTheme");
|
|
10
|
+
const AppMain_1 = require("../AppMain");
|
|
11
|
+
/**
|
|
12
|
+
* App with authentication provided by `next-auth`
|
|
13
|
+
*/
|
|
14
|
+
const NextApp = (props) => {
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.default.StrictMode, { children: [(0, jsx_runtime_1.jsx)(AppHead_1.AppHead, {}), (0, jsx_runtime_1.jsx)(react_2.SessionProvider, { session: props.pageProps.session, children: (0, jsx_runtime_1.jsx)(AppTheme_1.AppTheme, { ...props, children: (0, jsx_runtime_1.jsx)(AppMain_1.AppMain, { ...props }) }) })] }));
|
|
16
|
+
};
|
|
17
|
+
exports.NextApp = NextApp;
|
|
18
|
+
exports.default = exports.NextApp;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NextApp = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
+
const AppHead_1 = require("../AppHead");
|
|
8
|
+
const AppTheme_1 = require("./AppTheme");
|
|
9
|
+
const AppMain_1 = require("./AppMain");
|
|
10
|
+
/**
|
|
11
|
+
* App
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { NextApp, NextAppProps } from "@koine/next/app/sc/auth";
|
|
17
|
+
* import { Favicon, AnalyticsGoogle } from "@koine/next";
|
|
18
|
+
* import { theme } from "src/helpers/theme";
|
|
19
|
+
* import { Layout, ProgressOverlay } from "src/components/Layout";
|
|
20
|
+
* // import "@fontsource/myfont/800.css";
|
|
21
|
+
* // import "src/helpers/theme.css";
|
|
22
|
+
*
|
|
23
|
+
* const motion = () => import("@koine/react/m/max").then((m) => m.default);
|
|
24
|
+
*
|
|
25
|
+
* export default function App(props: NextAppProps) {
|
|
26
|
+
* return (
|
|
27
|
+
* <NextApp
|
|
28
|
+
* {...props}
|
|
29
|
+
* Layout={Layout}
|
|
30
|
+
* ProgressOverlay={ProgressOverlay}
|
|
31
|
+
* theme={theme}
|
|
32
|
+
* motion={motion}
|
|
33
|
+
* seo={{
|
|
34
|
+
* titleTemplate: "%s | MyApp",
|
|
35
|
+
* defaultTitle: "MyApp",
|
|
36
|
+
* openGraph: {
|
|
37
|
+
* type: "website",
|
|
38
|
+
* locale: "en_US",
|
|
39
|
+
* url: "https://myapp.com/",
|
|
40
|
+
* site_name: "MyApp",
|
|
41
|
+
* },
|
|
42
|
+
* twitter: {
|
|
43
|
+
* handle: "@MklrNl",
|
|
44
|
+
* site: "@MyApp",
|
|
45
|
+
* cardType: "summary_large_image",
|
|
46
|
+
* },
|
|
47
|
+
* }}
|
|
48
|
+
* pre={
|
|
49
|
+
* <>
|
|
50
|
+
* <AnalyticsGoogle id="UA-xxxxxxxx-x" />
|
|
51
|
+
* <Favicon name="MyApp" color="#000000" />
|
|
52
|
+
* </>
|
|
53
|
+
* }
|
|
54
|
+
* />
|
|
55
|
+
* );
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
const NextApp = (props) => {
|
|
61
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.default.StrictMode, { children: [(0, jsx_runtime_1.jsx)(AppHead_1.AppHead, {}), (0, jsx_runtime_1.jsx)(AppTheme_1.AppTheme, { ...props, children: (0, jsx_runtime_1.jsx)(AppMain_1.AppMain, { ...props }) })] }));
|
|
62
|
+
};
|
|
63
|
+
exports.NextApp = NextApp;
|
|
64
|
+
exports.default = exports.NextApp;
|