@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.
Files changed (112) hide show
  1. package/12/AnalyticsGoogle.js +65 -25
  2. package/12/AnalyticsGoogle.mjs +41 -15
  3. package/12/DisableErrorOverlay.js +29 -16
  4. package/12/DisableErrorOverlay.mjs +8 -5
  5. package/12/DynamicNamespaces.d.ts +1 -1
  6. package/12/DynamicNamespaces.js +22 -12
  7. package/12/DynamicNamespaces.mjs +1 -2
  8. package/12/Favicon.js +28 -9
  9. package/12/Favicon.mjs +6 -2
  10. package/12/Link.d.ts +1 -1
  11. package/12/Link.js +36 -13
  12. package/12/Link.mjs +14 -6
  13. package/12/NextProgress.js +47 -24
  14. package/12/NextProgress.mjs +26 -17
  15. package/12/Seo.d.ts +1 -1
  16. package/12/Seo.js +27 -32
  17. package/12/Seo.mjs +5 -4
  18. package/12/SeoDefaults.d.ts +1 -1
  19. package/12/SeoDefaults.js +27 -13
  20. package/12/SeoDefaults.mjs +5 -3
  21. package/12/T.d.ts +1 -1
  22. package/12/T.js +42 -16
  23. package/12/T.mjs +20 -6
  24. package/12/ThemeContext.js +22 -7
  25. package/12/ThemeContext.mjs +3 -3
  26. package/12/ThemeProvider.js +164 -147
  27. package/12/ThemeProvider.mjs +139 -129
  28. package/12/TransText.js +22 -7
  29. package/12/TransText.mjs +1 -1
  30. package/12/app/AppHead.js +29 -9
  31. package/12/app/AppHead.mjs +8 -2
  32. package/12/app/AppMain.d.ts +4 -4
  33. package/12/app/AppMain.js +5 -1
  34. package/12/app/AppMain.mjs +1 -1
  35. package/12/app/css/AppMain.js +37 -16
  36. package/12/app/css/AppMain.mjs +15 -5
  37. package/12/app/css/AppTheme.d.ts +1 -1
  38. package/12/app/css/AppTheme.js +28 -13
  39. package/12/app/css/AppTheme.mjs +7 -4
  40. package/12/app/css/auth/index.d.ts +1 -1
  41. package/12/app/css/auth/index.js +38 -15
  42. package/12/app/css/auth/index.mjs +17 -6
  43. package/12/app/css/index.d.ts +1 -1
  44. package/12/app/css/index.js +34 -59
  45. package/12/app/css/index.mjs +14 -6
  46. package/12/app/index.js +6 -4
  47. package/12/app/sc/AppMain.js +68 -27
  48. package/12/app/sc/AppMain.mjs +46 -13
  49. package/12/app/sc/AppTheme.d.ts +1 -1
  50. package/12/app/sc/AppTheme.js +31 -13
  51. package/12/app/sc/AppTheme.mjs +9 -4
  52. package/12/app/sc/auth/index.d.ts +1 -1
  53. package/12/app/sc/auth/index.js +38 -15
  54. package/12/app/sc/auth/index.mjs +17 -6
  55. package/12/app/sc/index.d.ts +1 -1
  56. package/12/app/sc/index.js +34 -61
  57. package/12/app/sc/index.mjs +14 -6
  58. package/12/document/Document.js +47 -29
  59. package/12/document/Document.mjs +24 -14
  60. package/12/document/css/index.js +47 -32
  61. package/12/document/css/index.mjs +26 -18
  62. package/12/document/index.js +18 -6
  63. package/12/document/sc/index.js +71 -65
  64. package/12/document/sc/index.mjs +46 -45
  65. package/12/getT.js +22 -13
  66. package/12/getT.mjs +2 -4
  67. package/12/index.js +99 -51
  68. package/12/index.mjs +2 -2
  69. package/12/seoBuildTags.js +81 -76
  70. package/12/seoBuildTags.mjs +59 -55
  71. package/12/to.js +21 -19
  72. package/12/to.mjs +4 -10
  73. package/12/translationAsOptions.js +15 -9
  74. package/12/translationAsOptions.mjs +6 -6
  75. package/12/types-i18n.js +4 -3
  76. package/12/types-i18n.mjs +1 -2
  77. package/12/types-seo.js +3 -1
  78. package/12/types-seo.mjs +1 -1
  79. package/12/useBackUrl.js +30 -16
  80. package/12/useBackUrl.mjs +8 -8
  81. package/12/useDateFormat.js +37 -38
  82. package/12/useDateFormat.mjs +15 -28
  83. package/12/useForm.d.ts +1 -1
  84. package/12/useForm.js +46 -20
  85. package/12/useForm.mjs +25 -13
  86. package/12/useLocale.js +22 -8
  87. package/12/useT.d.ts +1 -1
  88. package/12/useT.js +53 -39
  89. package/12/useT.mjs +32 -14
  90. package/12/useTheme.js +22 -11
  91. package/12/useTheme.mjs +1 -2
  92. package/12/useTo.js +23 -16
  93. package/12/useTo.mjs +3 -10
  94. package/README.md +1 -1
  95. package/config/index.js +225 -251
  96. package/config/index.mjs +187 -204
  97. package/getSiteUrl.js +22 -15
  98. package/getSiteUrl.mjs +2 -4
  99. package/index.js +19 -6
  100. package/load.js +21 -8
  101. package/load.mjs +3 -4
  102. package/package.json +19 -17
  103. package/12/app/css/auth/package.json +0 -6
  104. package/12/app/css/package.json +0 -6
  105. package/12/app/package.json +0 -6
  106. package/12/app/sc/auth/package.json +0 -6
  107. package/12/app/sc/package.json +0 -6
  108. package/12/document/css/package.json +0 -6
  109. package/12/document/package.json +0 -6
  110. package/12/document/sc/package.json +0 -6
  111. package/12/package.json +0 -6
  112. package/config/package.json +0 -6
@@ -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
- var defaults = {
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
- export var seoBuildTags = function (_a) {
23
- var _b = _a === void 0 ? {} : _a, seo = _b.seo, hidden = _b.hidden, keywords = _b.keywords, _c = _b.title, title = _c === void 0 ? "" : _c, titleTemplate = _b.titleTemplate, defaultTitle = _b.defaultTitle, noindex = _b.noindex, nofollow = _b.nofollow, description = _b.description, _d = _b.languageAlternates, languageAlternates = _d === void 0 ? [] : _d, twitter = _b.twitter, facebook = _b.facebook, openGraph = _b.openGraph, ogAlias = _b.og, canonical = _b.canonical, metaTags = _b.metaTags, linkTags = _b.linkTags;
24
- var id = "seo-";
25
- var render = [];
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 || (seo === null || seo === void 0 ? void 0 : seo.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", { children: title }, id + "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"] = "".concat(noindex || hidden ? "noindex" : "index", ",").concat(nofollow || hidden ? "nofollow" : "follow");
45
- description = description || (seo === null || seo === void 0 ? void 0 : seo.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 || (seo === null || seo === void 0 ? void 0 : seo.keywords);
49
+ keywords = keywords || seo?.keywords;
51
50
  if (keywords) {
52
51
  $names["keywords"] = isArray(keywords) ? keywords.join(", ") : keywords;
53
52
  }
54
- if ((languageAlternates === null || languageAlternates === void 0 ? void 0 : languageAlternates.length) > 0) {
55
- languageAlternates.forEach(function (_a) {
56
- var href = _a.href, hrefLang = _a.hrefLang;
57
- render.push(_jsx("link", { rel: "alternate", hrefLang: hrefLang, href: href }, id + "languageAlternate-" + hrefLang));
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", { rel: "canonical", href: canonical }, id + "canonical"));
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 === null || facebook === void 0 ? void 0 : facebook.appId)
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
- $names["twitter:card"] = twitter.cardType;
69
- if (twitter.site)
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
- var og = ogAlias || openGraph;
75
- if (og === null || og === void 0 ? void 0 : og.title)
76
- $properties["og:title"] = og === null || og === void 0 ? void 0 : og.title;
77
- if (og === null || og === void 0 ? void 0 : og.description)
78
- $properties["og:description"] = og === null || og === void 0 ? void 0 : og.description;
79
- if (og === null || og === void 0 ? void 0 : og.url)
80
- $properties["og:url"] = og.url;
81
- if (og === null || og === void 0 ? void 0 : og.type)
82
- $properties["og:type"] = og.type.toLowerCase();
83
- if (og === null || og === void 0 ? void 0 : og.locale)
84
- $properties["og:locale"] = og.locale;
85
- if (og === null || og === void 0 ? void 0 : og.siteName)
86
- $properties["og:siteName"] = og.siteName;
87
- var ogimage = (og === null || og === void 0 ? void 0 : og.image) || (seo === null || seo === void 0 ? void 0 : seo.ogimage);
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(function (key) {
94
- render.push(_jsx("meta", { property: key, content: $properties[key] }, id + "prop-" + +key));
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(function (tag) {
98
- render.push(_jsx("meta", __assign({}, tag), id + "meta-" + (tag.name || tag.property || tag.httpEquiv)));
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 === null || linkTags === void 0 ? void 0 : linkTags.length) {
102
- linkTags.forEach(function (tag) {
103
- render.push(_jsx("link", __assign({}, tag), id + "link-" + (tag.href || tag.rel)));
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", { value: true });
3
- exports.to = void 0;
4
- /**
5
- * `To` named route utility. It accept either a single argument if that is a static
6
- * route name or a second argument that interpolates the dynamic portions of
7
- * the route name. The types of these portions are automatically inferred.
8
- *
9
- * @borrows [awesome-template-literal-types](https://github.com/ghoullier/awesome-template-literal-types)
10
- */
11
- function to() {
12
- var args = [];
13
- for (var _i = 0; _i < arguments.length; _i++) {
14
- args[_i] = arguments[_i];
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
- var relative = "";
17
- var t = args[0];
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
- exports.to = to;
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
- export function to() {
9
- var args = [];
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", { value: true });
3
- exports.translationAsOptions = void 0;
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
- var dictionary = t(i18nKey, undefined, {
6
- returnObjects: true,
12
+ const dictionary = t(i18nKey, undefined, {
13
+ returnObjects: true
7
14
  });
8
- return Object.keys(dictionary).map(function (key) { return ({
9
- value: key,
10
- label: dictionary[key],
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
- var dictionary = t(i18nKey, undefined, {
3
- returnObjects: true,
2
+ const dictionary = t(i18nKey, undefined, {
3
+ returnObjects: true
4
4
  });
5
- return Object.keys(dictionary).map(function (key) { return ({
6
- value: key,
7
- label: dictionary[key],
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", { value: true });
12
+ */ "use strict";
13
+ Object.defineProperty(exports, "__esModule", {
14
+ value: true
15
+ });
package/12/types-i18n.mjs CHANGED
@@ -9,5 +9,4 @@
9
9
  *
10
10
  * @notes
11
11
  * I might take a better look at how things were done in [i18next](https://github.com/i18next/i18next/blob/master/index.d.ts)
12
- */
13
- export {};
12
+ */ export { };
package/12/types-seo.js CHANGED
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
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
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.useBackUrl = void 0;
5
- var tslib_1 = require("tslib");
6
- var react_1 = require("react");
7
- var router_1 = require("next/router");
8
- var createStorage_1 = tslib_1.__importDefault(require("@koine/browser/createStorage"));
9
- var back = (0, createStorage_1.default)({
10
- lastUrl: "",
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
- var asPath = (0, router_1.useRouter)().asPath;
14
- var calledOnce = (0, react_1.useRef)(false);
15
- var _a = (0, react_1.useState)(), backUrl = _a[0], setBackUrl = _a[1];
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, react_1.useEffect)(function () {
32
+ (0, _react.useEffect)(()=>{
18
33
  if (calledOnce.current) {
19
34
  return;
20
35
  }
21
- var prevLastUrl = back.get("lastUrl");
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
- exports.useBackUrl = useBackUrl;
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
- var back = createStorage({
6
- lastUrl: "",
5
+ const back = createStorage({
6
+ lastUrl: ""
7
7
  });
8
8
  export function useBackUrl() {
9
- var asPath = useRouter().asPath;
10
- var calledOnce = useRef(false);
11
- var _a = useState(), backUrl = _a[0], setBackUrl = _a[1];
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(function () {
13
+ useEffect(()=>{
14
14
  if (calledOnce.current) {
15
15
  return;
16
16
  }
17
- var prevLastUrl = back.get("lastUrl");
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
@@ -1,43 +1,42 @@
1
- "use strict";
2
1
  "use client";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.useDateFormat = void 0;
5
- var tslib_1 = require("tslib");
6
- var react_1 = require("react");
7
- var router_1 = require("next/router");
8
- var format_1 = tslib_1.__importDefault(require("date-fns/format"));
9
- var useDateLocale_1 = tslib_1.__importDefault(require("@koine/react/hooks/useDateLocale"));
10
- /**
11
- * Automatically returns the `date-fns/format` function with the right locale
12
- * passed as option (grabbed from next router value).
13
- */
14
- var useDateFormat = function () {
15
- var _a = (0, react_1.useState)(function () {
16
- return function () {
17
- var args = [];
18
- for (var _i = 0; _i < arguments.length; _i++) {
19
- args[_i] = arguments[_i];
20
- }
21
- return format_1.default.apply(void 0, args);
22
- };
23
- }), formatter = _a[0], setFormatter = _a[1];
24
- var router = (0, router_1.useRouter)();
25
- var locale = (0, useDateLocale_1.default)(router.locale);
26
- (0, react_1.useEffect)(function () {
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
- var newFormatter_1 = function (date, _format, options) { return (0, format_1.default)(date, _format, tslib_1.__assign(tslib_1.__assign({}, (options || {})), { locale: locale })); };
29
- setFormatter(function () {
30
- return function () {
31
- var args = [];
32
- for (var _i = 0; _i < arguments.length; _i++) {
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
- }, [locale]);
37
+ }, [
38
+ locale
39
+ ]);
40
40
  return formatter;
41
41
  };
42
- exports.useDateFormat = useDateFormat;
43
- exports.default = exports.useDateFormat;
42
+ const _default = useDateFormat;
@@ -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
- export var useDateFormat = function () {
12
- var _a = useState(function () {
13
- return function () {
14
- var args = [];
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
- var newFormatter_1 = function (date, _format, options) { return format(date, _format, __assign(__assign({}, (options || {})), { locale: locale })); };
26
- setFormatter(function () {
27
- return function () {
28
- var args = [];
29
- for (var _i = 0; _i < arguments.length; _i++) {
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
- }, [locale]);
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
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.useForm = void 0;
5
- var tslib_1 = require("tslib");
6
- var react_1 = require("react");
7
- var react_hook_form_1 = require("react-hook-form");
8
- var yup_1 = require("@hookform/resolvers/yup");
9
- function useForm(
10
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
- schema, t, formProps, debug) {
12
- if (formProps === void 0) { formProps = {}; }
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
- var form = (0, react_hook_form_1.useForm)(tslib_1.__assign({
26
+ const form = (0, _reacthookform.useForm)({
15
27
  // @ts-expect-error FIXME:
16
- resolver: (0, yup_1.yupResolver)(schema) }, formProps));
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, react_1.useMemo)(function () {
33
- var control = form.control, register = form.register, setValue = form.setValue;
34
- var field = { control: control, register: register, setValue: setValue, t: t };
35
- return tslib_1.__assign({ field: field }, form);
36
- }, [t, form]);
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
- exports.useForm = useForm;
39
- exports.default = useForm;
65
+ const _default = useForm;