@koine/next 1.0.24 → 1.0.27

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/config/index.js CHANGED
@@ -142,7 +142,18 @@ export function withKoine(_a) {
142
142
  // @see https://github.com/vercel/next.js/discussions/30174#discussion-3643870
143
143
  scrollRestoration: true }, (nextConfig.experimental || {})), {
144
144
  // @see https://nextjs.org/docs/advanced-features/compiler#modularize-imports
145
- modularizeImports: __assign({}, (((_b = nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.experimental) === null || _b === void 0 ? void 0 : _b.modularizeImports) || {})) }),
145
+ modularizeImports: __assign(__assign({}, (((_b = nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.experimental) === null || _b === void 0 ? void 0 : _b.modularizeImports) || {})), {
146
+ // FIXME: make these work with the right file/folder structure?
147
+ // "@koine/next/?(((\\w*)?/?)*)": {
148
+ // transform: "@koine/next/{{ matches.[1] }}/{{member}}",
149
+ // },
150
+ // "@koine/react/?(((\\w*)?/?)*)": {
151
+ // transform: "@koine/react/{{ matches.[1] }}/{{member}}",
152
+ // },
153
+ // "@koine/utils/?(((\\w*)?/?)*)": {
154
+ // transform: "@koine/utils/{{ matches.[1] }}/{{member}}",
155
+ // },
156
+ "@koine/utils": { transform: "@koine/utils/{{member}}" } }) }),
146
157
  // @see https://github.com/vercel/next.js/issues/7322#issuecomment-887330111
147
158
  reactStrictMode: true }, nextConfig);
148
159
  if (svg) {
@@ -152,7 +152,18 @@ function withKoine(_a) {
152
152
  // @see https://github.com/vercel/next.js/discussions/30174#discussion-3643870
153
153
  scrollRestoration: true }, (nextConfig.experimental || {})), {
154
154
  // @see https://nextjs.org/docs/advanced-features/compiler#modularize-imports
155
- modularizeImports: tslib_1.__assign({}, (((_b = nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.experimental) === null || _b === void 0 ? void 0 : _b.modularizeImports) || {})) }),
155
+ modularizeImports: tslib_1.__assign(tslib_1.__assign({}, (((_b = nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.experimental) === null || _b === void 0 ? void 0 : _b.modularizeImports) || {})), {
156
+ // FIXME: make these work with the right file/folder structure?
157
+ // "@koine/next/?(((\\w*)?/?)*)": {
158
+ // transform: "@koine/next/{{ matches.[1] }}/{{member}}",
159
+ // },
160
+ // "@koine/react/?(((\\w*)?/?)*)": {
161
+ // transform: "@koine/react/{{ matches.[1] }}/{{member}}",
162
+ // },
163
+ // "@koine/utils/?(((\\w*)?/?)*)": {
164
+ // transform: "@koine/utils/{{ matches.[1] }}/{{member}}",
165
+ // },
166
+ "@koine/utils": { transform: "@koine/utils/{{member}}" } }) }),
156
167
  // @see https://github.com/vercel/next.js/issues/7322#issuecomment-887330111
157
168
  reactStrictMode: true }, nextConfig);
158
169
  if (svg) {
package/package.json CHANGED
@@ -7,9 +7,9 @@
7
7
  "peerDependencies": {
8
8
  "react": "^16.8 || ^17 || ^18",
9
9
  "next": "^12.1.6",
10
- "@koine/utils": "1.0.24",
10
+ "@koine/utils": "1.0.27",
11
11
  "framer-motion": "^6.3.10",
12
- "@koine/react": "1.0.24",
12
+ "@koine/react": "1.0.27",
13
13
  "styled-components": "^5.3.5",
14
14
  "@mui/base": "^5.0.0-alpha.83",
15
15
  "react-icons": "^4.4.0",
@@ -20,6 +20,7 @@
20
20
  "yup": "^0.32.11",
21
21
  "react-hook-form": "^7.31.3",
22
22
  "type-fest": "^2.13.0",
23
+ "react-popper": "^2.3.0",
23
24
  "tslib": "^2.4.0",
24
25
  "next-auth": "^4.3.4",
25
26
  "@mui/material": "^5.8.2",
@@ -29,7 +30,7 @@
29
30
  "next-translate": "^1.4.0",
30
31
  "next-seo": "^5.4.0"
31
32
  },
32
- "version": "1.0.24",
33
+ "version": "1.0.27",
33
34
  "module": "./index.js",
34
35
  "types": "./index.d.ts"
35
36
  }
package/typings.d.ts CHANGED
@@ -97,7 +97,6 @@ declare namespace Koine {
97
97
  * the `koine` ecosystem. For instance Google Analytics globally available
98
98
  * variables.
99
99
  */
100
-
101
- declare const gtag: (
102
- ...args: Record<string, unknown>[]
103
- ) => Record<string, unknown>;
100
+ declare interface Window {
101
+ gtag: (...args: Record<string, unknown>[]) => Record<string, unknown>;
102
+ }
@@ -1,24 +0,0 @@
1
- import type { UnpackNestedValue } from "react-hook-form";
2
- import { KoineApi } from "../utils/api";
3
- export declare function useSubmit<RequestBody extends {}, ResponseSuccesfull extends KoineApi.ResponseSuccesfull = {}, ResponseFailed extends KoineApi.ResponseFailed = Record<keyof RequestBody, string | string[]>>(url: string, transformData?: (json: UnpackNestedValue<RequestBody>) => any): {
4
- submit: (json: any) => Promise<KoineApi.Response<ResponseSuccesfull, ResponseFailed>>;
5
- loading: boolean;
6
- } & {
7
- status: number;
8
- msg: string;
9
- } & ({
10
- ok?: boolean | undefined;
11
- fail?: boolean | undefined;
12
- loading: true;
13
- data?: undefined;
14
- } | {
15
- ok: true;
16
- fail?: false | undefined;
17
- loading?: false | undefined;
18
- data: ResponseSuccesfull;
19
- } | {
20
- ok?: false | undefined;
21
- fail: true;
22
- loading?: false | undefined;
23
- data: ResponseFailed;
24
- });
@@ -1,28 +0,0 @@
1
- import { __assign, __awaiter, __generator } from "tslib";
2
- import { useAsyncFn } from "@koine/react";
3
- import { api } from "../utils/api";
4
- export function useSubmit(url, transformData) {
5
- var _this = this;
6
- var _a = useAsyncFn(function (json) { return __awaiter(_this, void 0, void 0, function () {
7
- var response;
8
- return __generator(this, function (_a) {
9
- switch (_a.label) {
10
- case 0:
11
- if (transformData)
12
- json = transformData(json);
13
- return [4 /*yield*/, api.post(url, {
14
- json: json,
15
- })];
16
- case 1:
17
- response = _a.sent();
18
- if (process.env["NODE_ENV"] !== "production") {
19
- console.log("[@koine/next] useSubmit response", response);
20
- }
21
- return [2 /*return*/, response];
22
- }
23
- });
24
- }); }, [url, transformData]), state = _a[0], submit = _a[1];
25
- var loading = state.loading, error = state.error, value = state.value;
26
- var fail = !loading && (!!error || (value === null || value === void 0 ? void 0 : value.fail));
27
- return __assign(__assign({ submit: submit, loading: loading }, (value || {})), { fail: fail });
28
- }
package/utils/api.d.ts DELETED
@@ -1,55 +0,0 @@
1
- declare type _Response = Response;
2
- export declare namespace KoineApi {
3
- type ResponseSuccesfull = unknown;
4
- type ResponseFailed = unknown;
5
- type ResponseShared<T extends Record<string, unknown> = {}> = T & {
6
- status: _Response["status"];
7
- msg: _Response["statusText"];
8
- };
9
- type Response<Succesfull extends ResponseSuccesfull = ResponseSuccesfull, Failed extends ResponseFailed = ResponseFailed> = {
10
- status: _Response["status"];
11
- msg: _Response["statusText"];
12
- ok: true;
13
- fail?: false;
14
- data: Succesfull;
15
- } | {
16
- status: _Response["status"];
17
- msg: _Response["statusText"];
18
- ok?: false;
19
- fail: true;
20
- data: Failed;
21
- };
22
- /**
23
- * Request options
24
- */
25
- type RequestOptions<TJson = unknown> = {
26
- /**
27
- * JSON request body
28
- *
29
- * @default {}
30
- */
31
- json?: TJson;
32
- /**
33
- * Params will be serialized into a string and appended to the URL
34
- */
35
- params?: Record<string, unknown>;
36
- /**
37
- * Headers will be merged with
38
- * ```
39
- * { "content-type": "application/json" }
40
- * ```
41
- */
42
- headers?: RequestInit["headers"];
43
- /**
44
- * Timeout in `ms`, if `falsy` there is no timeout
45
- *
46
- * @default 10000
47
- */
48
- timeout?: number | false | null;
49
- };
50
- type RequestMethod = "get" | "post" | "put" | "patch" | "delete";
51
- type RequestFn = <Succesfull extends ResponseSuccesfull = unknown, Failed extends ResponseFailed = unknown>(endpoint: string, options?: RequestOptions) => Promise<Response<Succesfull, Failed>>;
52
- type Client = Record<RequestMethod, RequestFn>;
53
- }
54
- export declare const api: KoineApi.Client;
55
- export {};
package/utils/api.js DELETED
@@ -1,44 +0,0 @@
1
- import { __assign, __awaiter, __generator } from "tslib";
2
- import { buildUrlQueryString } from "@koine/utils";
3
- export var api = ["get", "post", "put", "patch", "delete"].reduce(function (api, method) {
4
- api[method] = function (endpoint, options) {
5
- if (options === void 0) { options = {}; }
6
- return __awaiter(void 0, void 0, void 0, function () {
7
- var _a, json, params, _b, headers, _c, timeout, requestInit, timeoutNumber, controller, timeoutId, url, response, result;
8
- return __generator(this, function (_d) {
9
- switch (_d.label) {
10
- case 0:
11
- _a = options.json, json = _a === void 0 ? {} : _a, params = options.params, _b = options.headers, headers = _b === void 0 ? {} : _b, _c = options.timeout, timeout = _c === void 0 ? 10000 : _c;
12
- requestInit = {
13
- method: method.toUpperCase(),
14
- headers: __assign({ "content-type": "application/json" }, headers),
15
- };
16
- timeoutNumber = Number(timeout);
17
- url = "/api/".concat(endpoint.replace(/^\/*/, ""));
18
- if (method !== "get") {
19
- requestInit.body = JSON.stringify(json);
20
- }
21
- if (timeoutNumber > 0) {
22
- controller = new AbortController();
23
- timeoutId = setTimeout(function () { return controller.abort(); }, timeoutNumber);
24
- requestInit.signal = controller.signal;
25
- }
26
- if (params) {
27
- url += buildUrlQueryString(params);
28
- }
29
- return [4 /*yield*/, fetch(url, requestInit)];
30
- case 1:
31
- response = _d.sent();
32
- if (timeoutId) {
33
- clearTimeout(timeoutId);
34
- }
35
- return [4 /*yield*/, response.json()];
36
- case 2:
37
- result = (_d.sent());
38
- return [2 /*return*/, result];
39
- }
40
- });
41
- });
42
- };
43
- return api;
44
- }, {});