ag-common 0.0.661 → 0.0.662
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.
|
@@ -84,6 +84,15 @@ const CloseStyled = (0, styled_1.default)(Close_1.Close) `
|
|
|
84
84
|
z-index: 1;
|
|
85
85
|
`;
|
|
86
86
|
const Modal = ({ open, setOpen, children, position = 'left', topPosition = 'top', showCloseButton = true, closeOnMoveMouseOutside = false, className, closeOnClickOutside = true, }) => {
|
|
87
|
+
(0, react_1.useEffect)(() => {
|
|
88
|
+
const originalStyle = window.getComputedStyle(document.body).overflow || '';
|
|
89
|
+
if (open) {
|
|
90
|
+
document.body.style.overflow = 'hidden';
|
|
91
|
+
}
|
|
92
|
+
return () => {
|
|
93
|
+
document.body.style.overflow = originalStyle;
|
|
94
|
+
};
|
|
95
|
+
}, [open]);
|
|
87
96
|
const [bounced, setBounced] = (0, react_1.useState)(false);
|
|
88
97
|
const ref = (0, react_1.useRef)(null);
|
|
89
98
|
(0, useOnClickOutside_1.useOnClickOutside)({
|
|
@@ -38,28 +38,18 @@ export interface IStateCommon<TRequest extends IRequestCommon> extends IInitialS
|
|
|
38
38
|
cookieDocument: string | undefined;
|
|
39
39
|
}
|
|
40
40
|
export declare const getRenderLanguage: (host?: string | null) => TLang;
|
|
41
|
+
export declare const getClientReqHref: () => IRequestCommon;
|
|
41
42
|
/**
|
|
42
43
|
* get parsed url. use on client/SSR. defaults to window location if possible
|
|
43
44
|
* @param param0
|
|
44
45
|
* @returns
|
|
45
46
|
*/
|
|
46
|
-
export declare const getClientOrServerReqHref: ({ url, query,
|
|
47
|
+
export declare const getClientOrServerReqHref: ({ url, query, userAgent, }: {
|
|
47
48
|
url?: URLLite | undefined;
|
|
48
49
|
query?: Record<string, string> | undefined;
|
|
49
|
-
/**
|
|
50
|
-
* if true, wont use window location. default false
|
|
51
|
-
*/
|
|
52
|
-
forceServer?: boolean | undefined;
|
|
53
50
|
/** will use navigator if possible */
|
|
54
51
|
userAgent?: string | undefined;
|
|
55
|
-
}) =>
|
|
56
|
-
url: URLLite;
|
|
57
|
-
query: {
|
|
58
|
-
[x: string]: string;
|
|
59
|
-
};
|
|
60
|
-
userAgent: string;
|
|
61
|
-
lang: TLang;
|
|
62
|
-
};
|
|
52
|
+
}) => IRequestCommon;
|
|
63
53
|
/**
|
|
64
54
|
* get server side parsed url
|
|
65
55
|
* @param param0 * @returns
|
|
@@ -81,11 +71,4 @@ export declare const getServerReq: ({ pathname, query, headers, }: {
|
|
|
81
71
|
* eg ctx.query
|
|
82
72
|
*/
|
|
83
73
|
query: Record<string, string | string[] | undefined>;
|
|
84
|
-
}) =>
|
|
85
|
-
url: URLLite;
|
|
86
|
-
query: {
|
|
87
|
-
[x: string]: string;
|
|
88
|
-
};
|
|
89
|
-
userAgent: string;
|
|
90
|
-
lang: TLang;
|
|
91
|
-
};
|
|
74
|
+
}) => IRequestCommon;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getServerReq = exports.getClientOrServerReqHref = exports.getRenderLanguage = void 0;
|
|
3
|
+
exports.getServerReq = exports.getClientOrServerReqHref = exports.getClientReqHref = exports.getRenderLanguage = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
4
5
|
const i18n_1 = require("../../common/helpers/i18n");
|
|
5
6
|
const object_1 = require("../../common/helpers/object");
|
|
6
7
|
const object_2 = require("../../common/helpers/string/object");
|
|
@@ -30,27 +31,29 @@ const getRenderLanguage = (host) => {
|
|
|
30
31
|
return 'en';
|
|
31
32
|
};
|
|
32
33
|
exports.getRenderLanguage = getRenderLanguage;
|
|
34
|
+
const getClientReqHref = () => {
|
|
35
|
+
const nu = new URL(window.location.href);
|
|
36
|
+
const url = (0, url_1.stripUrl)(nu);
|
|
37
|
+
const query = (0, object_2.stringToObject)((0, common_1.trimSide)(url.search, true, '?') || '', '=', '&');
|
|
38
|
+
const userAgent = navigator.userAgent;
|
|
39
|
+
return { url, query, userAgent, lang: (0, exports.getRenderLanguage)(url.host) };
|
|
40
|
+
};
|
|
41
|
+
exports.getClientReqHref = getClientReqHref;
|
|
33
42
|
/**
|
|
34
43
|
* get parsed url. use on client/SSR. defaults to window location if possible
|
|
35
44
|
* @param param0
|
|
36
45
|
* @returns
|
|
37
46
|
*/
|
|
38
|
-
const getClientOrServerReqHref = ({ url, query,
|
|
47
|
+
const getClientOrServerReqHref = ({ url, query, userAgent, }) => {
|
|
39
48
|
if (typeof window !== 'undefined') {
|
|
40
|
-
|
|
41
|
-
const nu = new URL(window.location.href);
|
|
42
|
-
url = (0, url_1.stripUrl)(nu);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (typeof navigator !== 'undefined') {
|
|
46
|
-
userAgent = navigator.userAgent;
|
|
49
|
+
return (0, exports.getClientReqHref)();
|
|
47
50
|
}
|
|
48
51
|
if (!url) {
|
|
49
52
|
throw new Error('no href');
|
|
50
53
|
}
|
|
51
54
|
return {
|
|
52
55
|
url,
|
|
53
|
-
query: Object.assign(Object.assign({}, query), (0, object_2.stringToObject)(url.search || '', '=', '&')),
|
|
56
|
+
query: Object.assign(Object.assign({}, query), (0, object_2.stringToObject)((0, common_1.trimSide)(url.search, true, '?') || '', '=', '&')),
|
|
54
57
|
userAgent: userAgent !== null && userAgent !== void 0 ? userAgent : '?',
|
|
55
58
|
lang: (0, exports.getRenderLanguage)(url.host),
|
|
56
59
|
};
|
|
@@ -70,7 +73,6 @@ const getServerReq = ({ pathname, query, headers, }) => {
|
|
|
70
73
|
const ret = (0, exports.getClientOrServerReqHref)({
|
|
71
74
|
url: !href ? undefined : new URL(href),
|
|
72
75
|
query: parsedQuery,
|
|
73
|
-
forceServer: true,
|
|
74
76
|
userAgent: (_a = headers['user-agent']) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
|
|
75
77
|
});
|
|
76
78
|
return ret;
|
package/package.json
CHANGED