@koine/next 2.0.0-beta.2 → 2.0.0-beta.4
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/12/AnalyticsGoogle.js +65 -25
- package/12/AnalyticsGoogle.mjs +41 -15
- package/12/DisableErrorOverlay.js +29 -16
- package/12/DisableErrorOverlay.mjs +8 -5
- package/12/DynamicNamespaces.d.ts +1 -1
- package/12/DynamicNamespaces.js +22 -12
- package/12/DynamicNamespaces.mjs +1 -2
- package/12/Favicon.js +28 -9
- package/12/Favicon.mjs +6 -2
- package/12/Link.d.ts +1 -1
- package/12/Link.js +36 -13
- package/12/Link.mjs +14 -6
- package/12/NextProgress.js +47 -24
- package/12/NextProgress.mjs +26 -17
- package/12/Seo.d.ts +1 -1
- package/12/Seo.js +27 -32
- package/12/Seo.mjs +5 -4
- package/12/SeoDefaults.d.ts +1 -1
- package/12/SeoDefaults.js +27 -13
- package/12/SeoDefaults.mjs +5 -3
- package/12/T.d.ts +1 -1
- package/12/T.js +42 -16
- package/12/T.mjs +20 -6
- package/12/ThemeContext.js +22 -7
- package/12/ThemeContext.mjs +3 -3
- package/12/ThemeProvider.js +164 -147
- package/12/ThemeProvider.mjs +139 -129
- package/12/TransText.js +22 -7
- package/12/TransText.mjs +1 -1
- package/12/app/AppHead.js +29 -9
- package/12/app/AppHead.mjs +8 -2
- package/12/app/AppMain.d.ts +4 -4
- package/12/app/AppMain.js +5 -1
- package/12/app/AppMain.mjs +1 -1
- package/12/app/css/AppMain.js +37 -16
- package/12/app/css/AppMain.mjs +15 -5
- package/12/app/css/AppTheme.d.ts +1 -1
- package/12/app/css/AppTheme.js +28 -13
- package/12/app/css/AppTheme.mjs +7 -4
- package/12/app/css/auth/index.d.ts +1 -1
- package/12/app/css/auth/index.js +38 -15
- package/12/app/css/auth/index.mjs +17 -6
- package/12/app/css/index.d.ts +1 -1
- package/12/app/css/index.js +34 -59
- package/12/app/css/index.mjs +14 -6
- package/12/app/index.js +6 -4
- package/12/app/sc/AppMain.js +68 -27
- package/12/app/sc/AppMain.mjs +46 -13
- package/12/app/sc/AppTheme.d.ts +1 -1
- package/12/app/sc/AppTheme.js +31 -13
- package/12/app/sc/AppTheme.mjs +9 -4
- package/12/app/sc/auth/index.d.ts +1 -1
- package/12/app/sc/auth/index.js +38 -15
- package/12/app/sc/auth/index.mjs +17 -6
- package/12/app/sc/index.d.ts +1 -1
- package/12/app/sc/index.js +34 -61
- package/12/app/sc/index.mjs +14 -6
- package/12/document/Document.js +47 -29
- package/12/document/Document.mjs +24 -14
- package/12/document/css/index.js +47 -32
- package/12/document/css/index.mjs +26 -18
- package/12/document/index.js +18 -6
- package/12/document/sc/index.js +71 -65
- package/12/document/sc/index.mjs +46 -45
- package/12/getT.js +22 -13
- package/12/getT.mjs +2 -4
- package/12/index.js +99 -51
- package/12/index.mjs +2 -2
- package/12/seoBuildTags.js +81 -76
- package/12/seoBuildTags.mjs +59 -55
- package/12/to.js +21 -19
- package/12/to.mjs +4 -10
- package/12/translationAsOptions.js +15 -9
- package/12/translationAsOptions.mjs +6 -6
- package/12/types-i18n.js +4 -3
- package/12/types-i18n.mjs +1 -2
- package/12/types-seo.js +3 -1
- package/12/types-seo.mjs +1 -1
- package/12/useBackUrl.js +30 -16
- package/12/useBackUrl.mjs +8 -8
- package/12/useDateFormat.js +37 -38
- package/12/useDateFormat.mjs +15 -28
- package/12/useForm.d.ts +1 -1
- package/12/useForm.js +46 -20
- package/12/useForm.mjs +25 -13
- package/12/useLocale.js +22 -8
- package/12/useT.d.ts +1 -1
- package/12/useT.js +53 -39
- package/12/useT.mjs +32 -14
- package/12/useTheme.js +22 -11
- package/12/useTheme.mjs +1 -2
- package/12/useTo.js +23 -16
- package/12/useTo.mjs +3 -10
- package/README.md +1 -1
- package/config/index.js +225 -251
- package/config/index.mjs +187 -204
- package/getSiteUrl.js +22 -15
- package/getSiteUrl.mjs +2 -4
- package/index.js +19 -6
- package/load.js +21 -8
- package/load.mjs +3 -4
- package/package.json +19 -17
- package/12/app/css/auth/package.json +0 -6
- package/12/app/css/package.json +0 -6
- package/12/app/package.json +0 -6
- package/12/app/sc/auth/package.json +0 -6
- package/12/app/sc/package.json +0 -6
- package/12/document/css/package.json +0 -6
- package/12/document/package.json +0 -6
- package/12/document/sc/package.json +0 -6
- package/12/package.json +0 -6
- package/config/package.json +0 -6
package/12/seoBuildTags.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
3
|
import isArray from "@koine/utils/isArray";
|
|
4
|
-
|
|
5
|
-
tplTitle: ""
|
|
4
|
+
const defaults = {
|
|
5
|
+
tplTitle: ""
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* Comparing to `next-seo` we do a couple of things in addition while many
|
|
@@ -18,89 +18,93 @@ var defaults = {
|
|
|
18
18
|
* - Shorter code
|
|
19
19
|
*
|
|
20
20
|
* @returns
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var $names = {};
|
|
27
|
-
var $properties = {};
|
|
21
|
+
*/ export const seoBuildTags = ({ seo, hidden, keywords, title = "", titleTemplate, defaultTitle, noindex, nofollow, description, languageAlternates = [], twitter, facebook, openGraph, og: ogAlias, canonical, metaTags, linkTags } = {})=>{
|
|
22
|
+
const id = "seo-";
|
|
23
|
+
const render = [];
|
|
24
|
+
const $names = {};
|
|
25
|
+
const $properties = {};
|
|
28
26
|
if (titleTemplate) {
|
|
29
27
|
defaults.tplTitle = titleTemplate;
|
|
30
28
|
}
|
|
31
|
-
title = title ||
|
|
29
|
+
title = title || seo?.title || "";
|
|
32
30
|
if (title) {
|
|
33
31
|
if (defaults.tplTitle && defaults.tplTitle !== title) {
|
|
34
32
|
title = defaults.tplTitle.replace(/%s/g, title);
|
|
35
33
|
}
|
|
36
|
-
}
|
|
37
|
-
else if (defaultTitle) {
|
|
34
|
+
} else if (defaultTitle) {
|
|
38
35
|
title = defaultTitle;
|
|
39
36
|
}
|
|
40
37
|
if (title) {
|
|
41
|
-
render.push(_jsx("title", {
|
|
38
|
+
render.push(/*#__PURE__*/ _jsx("title", {
|
|
39
|
+
children: title
|
|
40
|
+
}, id + "title"));
|
|
42
41
|
$properties["og:title"] = title; // overridden later...
|
|
43
42
|
}
|
|
44
|
-
$names["robots"] =
|
|
45
|
-
description = description ||
|
|
43
|
+
$names["robots"] = `${noindex || hidden ? "noindex" : "index"},${nofollow || hidden ? "nofollow" : "follow"}`;
|
|
44
|
+
description = description || seo?.description;
|
|
46
45
|
if (description) {
|
|
47
46
|
$names["description"] = description;
|
|
48
47
|
$properties["og:description"] = description; // overridden later...
|
|
49
48
|
}
|
|
50
|
-
keywords = keywords ||
|
|
49
|
+
keywords = keywords || seo?.keywords;
|
|
51
50
|
if (keywords) {
|
|
52
51
|
$names["keywords"] = isArray(keywords) ? keywords.join(", ") : keywords;
|
|
53
52
|
}
|
|
54
|
-
if (
|
|
55
|
-
languageAlternates.forEach(
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
if (languageAlternates?.length > 0) {
|
|
54
|
+
languageAlternates.forEach(({ href, hrefLang })=>{
|
|
55
|
+
render.push(/*#__PURE__*/ _jsx("link", {
|
|
56
|
+
rel: "alternate",
|
|
57
|
+
hrefLang: hrefLang,
|
|
58
|
+
href: href
|
|
59
|
+
}, id + "languageAlternate-" + hrefLang));
|
|
58
60
|
});
|
|
59
61
|
}
|
|
60
62
|
if (canonical) {
|
|
61
|
-
render.push(_jsx("link", {
|
|
63
|
+
render.push(/*#__PURE__*/ _jsx("link", {
|
|
64
|
+
rel: "canonical",
|
|
65
|
+
href: canonical
|
|
66
|
+
}, id + "canonical"));
|
|
62
67
|
$properties["og:url"] = canonical;
|
|
63
68
|
}
|
|
64
|
-
if (facebook
|
|
65
|
-
$properties["fb:app_id"] = facebook.appId;
|
|
69
|
+
if (facebook?.appId) $properties["fb:app_id"] = facebook.appId;
|
|
66
70
|
if (twitter) {
|
|
67
|
-
if (twitter.cardType)
|
|
68
|
-
|
|
69
|
-
if (twitter.
|
|
70
|
-
$names["twitter:site"] = twitter.site;
|
|
71
|
-
if (twitter.handle)
|
|
72
|
-
$names["twitter:creator"] = twitter.handle;
|
|
71
|
+
if (twitter.cardType) $names["twitter:card"] = twitter.cardType;
|
|
72
|
+
if (twitter.site) $names["twitter:site"] = twitter.site;
|
|
73
|
+
if (twitter.handle) $names["twitter:creator"] = twitter.handle;
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
-
if (og
|
|
76
|
-
|
|
77
|
-
if (og
|
|
78
|
-
|
|
79
|
-
if (og
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (ogimage)
|
|
89
|
-
$properties["og:image"] = ogimage;
|
|
90
|
-
Object.keys($names).forEach(function (key) {
|
|
91
|
-
render.push(_jsx("meta", { name: key, content: $names[key] }, id + "name-" + key));
|
|
75
|
+
const og = ogAlias || openGraph;
|
|
76
|
+
if (og?.title) $properties["og:title"] = og?.title;
|
|
77
|
+
if (og?.description) $properties["og:description"] = og?.description;
|
|
78
|
+
if (og?.url) $properties["og:url"] = og.url;
|
|
79
|
+
if (og?.type) $properties["og:type"] = og.type.toLowerCase();
|
|
80
|
+
if (og?.locale) $properties["og:locale"] = og.locale;
|
|
81
|
+
if (og?.siteName) $properties["og:siteName"] = og.siteName;
|
|
82
|
+
const ogimage = og?.image || seo?.ogimage;
|
|
83
|
+
if (ogimage) $properties["og:image"] = ogimage;
|
|
84
|
+
Object.keys($names).forEach((key)=>{
|
|
85
|
+
render.push(/*#__PURE__*/ _jsx("meta", {
|
|
86
|
+
name: key,
|
|
87
|
+
content: $names[key]
|
|
88
|
+
}, id + "name-" + key));
|
|
92
89
|
});
|
|
93
|
-
Object.keys($properties).forEach(
|
|
94
|
-
render.push(_jsx("meta", {
|
|
90
|
+
Object.keys($properties).forEach((key)=>{
|
|
91
|
+
render.push(/*#__PURE__*/ _jsx("meta", {
|
|
92
|
+
property: key,
|
|
93
|
+
content: $properties[key]
|
|
94
|
+
}, id + "prop-" + +key));
|
|
95
95
|
});
|
|
96
96
|
if (metaTags && metaTags.length > 0) {
|
|
97
|
-
metaTags.forEach(
|
|
98
|
-
render.push(_jsx("meta",
|
|
97
|
+
metaTags.forEach((tag)=>{
|
|
98
|
+
render.push(/*#__PURE__*/ _jsx("meta", {
|
|
99
|
+
...tag
|
|
100
|
+
}, id + "meta-" + (tag.name || tag.property || tag.httpEquiv)));
|
|
99
101
|
});
|
|
100
102
|
}
|
|
101
|
-
if (linkTags
|
|
102
|
-
linkTags.forEach(
|
|
103
|
-
render.push(_jsx("link",
|
|
103
|
+
if (linkTags?.length) {
|
|
104
|
+
linkTags.forEach((tag)=>{
|
|
105
|
+
render.push(/*#__PURE__*/ _jsx("link", {
|
|
106
|
+
...tag
|
|
107
|
+
}, id + "link-" + (tag.href || tag.rel)));
|
|
104
108
|
});
|
|
105
109
|
}
|
|
106
110
|
// TODO: alternates and canonical
|
package/12/to.js
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
to: function() {
|
|
13
|
+
return to;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
});
|
|
19
|
+
function to(...args) {
|
|
20
|
+
let relative = "";
|
|
21
|
+
const [t] = args;
|
|
18
22
|
if (args.length === 3) {
|
|
19
23
|
if (args[2]) {
|
|
20
24
|
relative = t(args[1], args[2]).replace("*", "");
|
|
21
25
|
}
|
|
22
|
-
}
|
|
23
|
-
else if (args.length === 2) {
|
|
26
|
+
} else if (args.length === 2) {
|
|
24
27
|
relative = t(args[1]);
|
|
25
28
|
}
|
|
26
29
|
return relative;
|
|
27
30
|
}
|
|
28
|
-
|
|
29
|
-
exports.default = to;
|
|
31
|
+
const _default = to;
|
package/12/to.mjs
CHANGED
|
@@ -4,20 +4,14 @@
|
|
|
4
4
|
* the route name. The types of these portions are automatically inferred.
|
|
5
5
|
*
|
|
6
6
|
* @borrows [awesome-template-literal-types](https://github.com/ghoullier/awesome-template-literal-types)
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
-
args[_i] = arguments[_i];
|
|
12
|
-
}
|
|
13
|
-
var relative = "";
|
|
14
|
-
var t = args[0];
|
|
7
|
+
*/ export function to(...args) {
|
|
8
|
+
let relative = "";
|
|
9
|
+
const [t] = args;
|
|
15
10
|
if (args.length === 3) {
|
|
16
11
|
if (args[2]) {
|
|
17
12
|
relative = t(args[1], args[2]).replace("*", "");
|
|
18
13
|
}
|
|
19
|
-
}
|
|
20
|
-
else if (args.length === 2) {
|
|
14
|
+
} else if (args.length === 2) {
|
|
21
15
|
relative = t(args[1]);
|
|
22
16
|
}
|
|
23
17
|
return relative;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "translationAsOptions", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return translationAsOptions;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
4
11
|
function translationAsOptions(t, i18nKey) {
|
|
5
|
-
|
|
6
|
-
returnObjects: true
|
|
12
|
+
const dictionary = t(i18nKey, undefined, {
|
|
13
|
+
returnObjects: true
|
|
7
14
|
});
|
|
8
|
-
return Object.keys(dictionary).map(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
return Object.keys(dictionary).map((key)=>({
|
|
16
|
+
value: key,
|
|
17
|
+
label: dictionary[key]
|
|
18
|
+
}));
|
|
12
19
|
}
|
|
13
|
-
exports.translationAsOptions = translationAsOptions;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export function translationAsOptions(t, i18nKey) {
|
|
2
|
-
|
|
3
|
-
returnObjects: true
|
|
2
|
+
const dictionary = t(i18nKey, undefined, {
|
|
3
|
+
returnObjects: true
|
|
4
4
|
});
|
|
5
|
-
return Object.keys(dictionary).map(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
return Object.keys(dictionary).map((key)=>({
|
|
6
|
+
value: key,
|
|
7
|
+
label: dictionary[key]
|
|
8
|
+
}));
|
|
9
9
|
}
|
package/12/types-i18n.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @file
|
|
4
3
|
*
|
|
@@ -10,5 +9,7 @@
|
|
|
10
9
|
*
|
|
11
10
|
* @notes
|
|
12
11
|
* I might take a better look at how things were done in [i18next](https://github.com/i18next/i18next/blob/master/index.d.ts)
|
|
13
|
-
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
*/ "use strict";
|
|
13
|
+
Object.defineProperty(exports, "__esModule", {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
package/12/types-i18n.mjs
CHANGED
package/12/types-seo.js
CHANGED
package/12/types-seo.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { };
|
package/12/useBackUrl.js
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
"use client";
|
|
3
|
-
|
|
4
|
-
exports
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
function _export(target, all) {
|
|
7
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
useBackUrl: function() {
|
|
14
|
+
return useBackUrl;
|
|
15
|
+
},
|
|
16
|
+
default: function() {
|
|
17
|
+
return _default;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
21
|
+
const _router = require("next/router");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _createStorage = /*#__PURE__*/ _interop_require_default._(require("@koine/browser/createStorage"));
|
|
24
|
+
const back = (0, _createStorage.default)({
|
|
25
|
+
lastUrl: ""
|
|
11
26
|
});
|
|
12
27
|
function useBackUrl() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
28
|
+
const { asPath } = (0, _router.useRouter)();
|
|
29
|
+
const calledOnce = (0, _react.useRef)(false);
|
|
30
|
+
const [backUrl, setBackUrl] = (0, _react.useState)();
|
|
16
31
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
|
-
(0,
|
|
32
|
+
(0, _react.useEffect)(()=>{
|
|
18
33
|
if (calledOnce.current) {
|
|
19
34
|
return;
|
|
20
35
|
}
|
|
21
|
-
|
|
36
|
+
const prevLastUrl = back.get("lastUrl");
|
|
22
37
|
// console.log("useBackUrl: prevLastUrl", prevLastUrl);
|
|
23
38
|
// first set it to use on a link, set to undefined if the previous URL
|
|
24
39
|
// is the same as the current one
|
|
@@ -29,5 +44,4 @@ function useBackUrl() {
|
|
|
29
44
|
});
|
|
30
45
|
return backUrl;
|
|
31
46
|
}
|
|
32
|
-
|
|
33
|
-
exports.default = useBackUrl;
|
|
47
|
+
const _default = useBackUrl;
|
package/12/useBackUrl.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
3
2
|
import { useRouter } from "next/router";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import createStorage from "@koine/browser/createStorage";
|
|
5
|
-
|
|
6
|
-
lastUrl: ""
|
|
5
|
+
const back = createStorage({
|
|
6
|
+
lastUrl: ""
|
|
7
7
|
});
|
|
8
8
|
export function useBackUrl() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const { asPath } = useRouter();
|
|
10
|
+
const calledOnce = useRef(false);
|
|
11
|
+
const [backUrl, setBackUrl] = useState();
|
|
12
12
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
13
|
-
useEffect(
|
|
13
|
+
useEffect(()=>{
|
|
14
14
|
if (calledOnce.current) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
const prevLastUrl = back.get("lastUrl");
|
|
18
18
|
// console.log("useBackUrl: prevLastUrl", prevLastUrl);
|
|
19
19
|
// first set it to use on a link, set to undefined if the previous URL
|
|
20
20
|
// is the same as the current one
|
package/12/useDateFormat.js
CHANGED
|
@@ -1,43 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
"use client";
|
|
3
|
-
|
|
4
|
-
exports
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
function _export(target, all) {
|
|
7
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
useDateFormat: function() {
|
|
14
|
+
return useDateFormat;
|
|
15
|
+
},
|
|
16
|
+
default: function() {
|
|
17
|
+
return _default;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
21
|
+
const _format = /*#__PURE__*/ _interop_require_default._(require("date-fns/format"));
|
|
22
|
+
const _router = require("next/router");
|
|
23
|
+
const _react = require("react");
|
|
24
|
+
const _useDateLocale = /*#__PURE__*/ _interop_require_default._(require("@koine/react/hooks/useDateLocale"));
|
|
25
|
+
const useDateFormat = ()=>{
|
|
26
|
+
const [formatter, setFormatter] = (0, _react.useState)(()=>(...args)=>(0, _format.default)(...args));
|
|
27
|
+
const router = (0, _router.useRouter)();
|
|
28
|
+
const locale = (0, _useDateLocale.default)(router.locale);
|
|
29
|
+
(0, _react.useEffect)(()=>{
|
|
27
30
|
if (locale) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
args[_i] = arguments[_i];
|
|
34
|
-
}
|
|
35
|
-
return newFormatter_1.apply(void 0, args);
|
|
36
|
-
};
|
|
37
|
-
});
|
|
31
|
+
const newFormatter = (date, _format1, options)=>(0, _format.default)(date, _format1, {
|
|
32
|
+
...options || {},
|
|
33
|
+
locale
|
|
34
|
+
});
|
|
35
|
+
setFormatter(()=>(...args)=>newFormatter(...args));
|
|
38
36
|
}
|
|
39
|
-
}, [
|
|
37
|
+
}, [
|
|
38
|
+
locale
|
|
39
|
+
]);
|
|
40
40
|
return formatter;
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
exports.default = exports.useDateFormat;
|
|
42
|
+
const _default = useDateFormat;
|
package/12/useDateFormat.mjs
CHANGED
|
@@ -1,39 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { __assign } from "tslib";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
import { useRouter } from "next/router";
|
|
5
2
|
import format from "date-fns/format";
|
|
3
|
+
import { useRouter } from "next/router";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
6
5
|
import useDateLocale from "@koine/react/hooks/useDateLocale";
|
|
7
6
|
/**
|
|
8
7
|
* Automatically returns the `date-fns/format` function with the right locale
|
|
9
8
|
* passed as option (grabbed from next router value).
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
16
|
-
args[_i] = arguments[_i];
|
|
17
|
-
}
|
|
18
|
-
return format.apply(void 0, args);
|
|
19
|
-
};
|
|
20
|
-
}), formatter = _a[0], setFormatter = _a[1];
|
|
21
|
-
var router = useRouter();
|
|
22
|
-
var locale = useDateLocale(router.locale);
|
|
23
|
-
useEffect(function () {
|
|
9
|
+
*/ export const useDateFormat = ()=>{
|
|
10
|
+
const [formatter, setFormatter] = useState(()=>(...args)=>format(...args));
|
|
11
|
+
const router = useRouter();
|
|
12
|
+
const locale = useDateLocale(router.locale);
|
|
13
|
+
useEffect(()=>{
|
|
24
14
|
if (locale) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
args[_i] = arguments[_i];
|
|
31
|
-
}
|
|
32
|
-
return newFormatter_1.apply(void 0, args);
|
|
33
|
-
};
|
|
34
|
-
});
|
|
15
|
+
const newFormatter = (date, _format, options)=>format(date, _format, {
|
|
16
|
+
...options || {},
|
|
17
|
+
locale
|
|
18
|
+
});
|
|
19
|
+
setFormatter(()=>(...args)=>newFormatter(...args));
|
|
35
20
|
}
|
|
36
|
-
}, [
|
|
21
|
+
}, [
|
|
22
|
+
locale
|
|
23
|
+
]);
|
|
37
24
|
return formatter;
|
|
38
25
|
};
|
|
39
26
|
export default useDateFormat;
|
package/12/useForm.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UseFormProps, FieldValues } from "react-hook-form";
|
|
2
1
|
import type { ObjectSchema } from "@kuus/yup";
|
|
2
|
+
import type { FieldValues, UseFormProps } from "react-hook-form";
|
|
3
3
|
import { type TranslateLoose } from "./types-i18n";
|
|
4
4
|
export declare function useForm<T extends FieldValues>(schema: ObjectSchema<any>, t: TranslateLoose, formProps?: UseFormProps, debug?: boolean): {
|
|
5
5
|
watch: import("react-hook-form").UseFormWatch<T>;
|
package/12/useForm.js
CHANGED
|
@@ -1,19 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
"use client";
|
|
3
|
-
|
|
4
|
-
exports
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
function _export(target, all) {
|
|
7
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
useForm: function() {
|
|
14
|
+
return useForm;
|
|
15
|
+
},
|
|
16
|
+
default: function() {
|
|
17
|
+
return _default;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const _yup = require("@hookform/resolvers/yup");
|
|
21
|
+
const _react = require("react");
|
|
22
|
+
const _reacthookform = require("react-hook-form");
|
|
23
|
+
function useForm(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
schema, t, formProps = {}, debug) {
|
|
13
25
|
// const form = _useForm<InferType<ObjectSchema<T, object>>>({
|
|
14
|
-
|
|
26
|
+
const form = (0, _reacthookform.useForm)({
|
|
15
27
|
// @ts-expect-error FIXME:
|
|
16
|
-
resolver: (0,
|
|
28
|
+
resolver: (0, _yup.yupResolver)(schema),
|
|
29
|
+
// make the form behave more closer as native:
|
|
30
|
+
// shouldUnregister: true,
|
|
31
|
+
...formProps
|
|
32
|
+
});
|
|
17
33
|
// const { control, register, setValue } = form;
|
|
18
34
|
// const field = { control, register, setValue, t };
|
|
19
35
|
// if (process.env["NODE_ENV"] !== "production") {
|
|
@@ -29,11 +45,21 @@ schema, t, formProps, debug) {
|
|
|
29
45
|
// if (formProps.mode === "onChange") {
|
|
30
46
|
// return { field, ...form };
|
|
31
47
|
// }
|
|
32
|
-
return (0,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
return (0, _react.useMemo)(()=>{
|
|
49
|
+
const { control, register, setValue } = form;
|
|
50
|
+
const field = {
|
|
51
|
+
control,
|
|
52
|
+
register,
|
|
53
|
+
setValue,
|
|
54
|
+
t
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
field,
|
|
58
|
+
...form
|
|
59
|
+
};
|
|
60
|
+
}, [
|
|
61
|
+
t,
|
|
62
|
+
form
|
|
63
|
+
]);
|
|
37
64
|
}
|
|
38
|
-
|
|
39
|
-
exports.default = useForm;
|
|
65
|
+
const _default = useForm;
|