@redneckz/wildless-cms-uni-blocks 0.6.43 → 0.6.45
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/bundle/ProjectSettings.d.ts +2 -0
- package/bundle/bundle.umd.js +41 -23
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/services/BlockRouter/BlockRouter.d.ts +1 -1
- package/bundle/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
- package/bundle/utils/normalizeURLPath.d.ts +1 -0
- package/bundle/utils/url.d.ts +1 -0
- package/dist/ProjectSettings.d.ts +2 -0
- package/dist/ProjectSettings.js +5 -0
- package/dist/ProjectSettings.js.map +1 -1
- package/dist/api/LikeAPI.js +2 -2
- package/dist/api/LikeAPI.js.map +1 -1
- package/dist/components/Header/Header.js +1 -6
- package/dist/components/Header/Header.js.map +1 -1
- package/dist/hooks/useLink.js +3 -5
- package/dist/hooks/useLink.js.map +1 -1
- package/dist/hooks/useLocation.js +11 -5
- package/dist/hooks/useLocation.js.map +1 -1
- package/dist/services/BlockRouter/BlockRouter.d.ts +1 -1
- package/dist/services/BlockRouter/BlockRouter.js.map +1 -1
- package/dist/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
- package/dist/services/sitemap/checkIsHrefSameOrigin.js +1 -1
- package/dist/services/sitemap/checkIsHrefSameOrigin.js.map +1 -1
- package/dist/services/sitemap/isHrefActive.js +2 -3
- package/dist/services/sitemap/isHrefActive.js.map +1 -1
- package/dist/services/sitemap/isTopItemActive.js +3 -1
- package/dist/services/sitemap/isTopItemActive.js.map +1 -1
- package/dist/setup-fixture.js +3 -3
- package/dist/setup-fixture.js.map +1 -1
- package/dist/utils/normalizeURLPath.d.ts +1 -0
- package/dist/utils/normalizeURLPath.js +12 -0
- package/dist/utils/normalizeURLPath.js.map +1 -0
- package/dist/utils/url.d.ts +1 -0
- package/dist/utils/url.js +9 -1
- package/dist/utils/url.js.map +1 -1
- package/dist/wlc.json +3 -1
- package/lib/ProjectSettings.d.ts +2 -0
- package/lib/ProjectSettings.js +5 -0
- package/lib/ProjectSettings.js.map +1 -1
- package/lib/api/LikeAPI.js +2 -2
- package/lib/api/LikeAPI.js.map +1 -1
- package/lib/components/Header/Header.js +1 -6
- package/lib/components/Header/Header.js.map +1 -1
- package/lib/hooks/useLink.js +3 -5
- package/lib/hooks/useLink.js.map +1 -1
- package/lib/hooks/useLocation.js +11 -5
- package/lib/hooks/useLocation.js.map +1 -1
- package/lib/services/BlockRouter/BlockRouter.d.ts +1 -1
- package/lib/services/BlockRouter/BlockRouter.js.map +1 -1
- package/lib/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
- package/lib/services/sitemap/checkIsHrefSameOrigin.js +1 -1
- package/lib/services/sitemap/checkIsHrefSameOrigin.js.map +1 -1
- package/lib/services/sitemap/isHrefActive.js +3 -4
- package/lib/services/sitemap/isHrefActive.js.map +1 -1
- package/lib/services/sitemap/isTopItemActive.js +3 -1
- package/lib/services/sitemap/isTopItemActive.js.map +1 -1
- package/lib/setup-fixture.js +3 -3
- package/lib/setup-fixture.js.map +1 -1
- package/lib/utils/normalizeURLPath.d.ts +1 -0
- package/lib/utils/normalizeURLPath.js +9 -0
- package/lib/utils/normalizeURLPath.js.map +1 -0
- package/lib/utils/url.d.ts +1 -0
- package/lib/utils/url.js +7 -0
- package/lib/utils/url.js.map +1 -1
- package/lib/wlc.json +3 -1
- package/mobile/bundle/ProjectSettings.d.ts +2 -0
- package/mobile/bundle/bundle.umd.js +40 -17
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/services/BlockRouter/BlockRouter.d.ts +1 -1
- package/mobile/bundle/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
- package/mobile/bundle/utils/normalizeURLPath.d.ts +1 -0
- package/mobile/bundle/utils/url.d.ts +1 -0
- package/mobile/dist/ProjectSettings.d.ts +2 -0
- package/mobile/dist/ProjectSettings.js +5 -0
- package/mobile/dist/ProjectSettings.js.map +1 -1
- package/mobile/dist/api/LikeAPI.js +2 -2
- package/mobile/dist/api/LikeAPI.js.map +1 -1
- package/mobile/dist/hooks/useLink.js +3 -5
- package/mobile/dist/hooks/useLink.js.map +1 -1
- package/mobile/dist/hooks/useLocation.js +11 -5
- package/mobile/dist/hooks/useLocation.js.map +1 -1
- package/mobile/dist/services/BlockRouter/BlockRouter.d.ts +1 -1
- package/mobile/dist/services/BlockRouter/BlockRouter.js.map +1 -1
- package/mobile/dist/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
- package/mobile/dist/services/sitemap/checkIsHrefSameOrigin.js +1 -1
- package/mobile/dist/services/sitemap/checkIsHrefSameOrigin.js.map +1 -1
- package/mobile/dist/services/sitemap/isHrefActive.js +2 -3
- package/mobile/dist/services/sitemap/isHrefActive.js.map +1 -1
- package/mobile/dist/services/sitemap/isTopItemActive.js +3 -1
- package/mobile/dist/services/sitemap/isTopItemActive.js.map +1 -1
- package/mobile/dist/setup-fixture.js +3 -3
- package/mobile/dist/setup-fixture.js.map +1 -1
- package/mobile/dist/utils/normalizeURLPath.d.ts +1 -0
- package/mobile/dist/utils/normalizeURLPath.js +12 -0
- package/mobile/dist/utils/normalizeURLPath.js.map +1 -0
- package/mobile/dist/utils/url.d.ts +1 -0
- package/mobile/dist/utils/url.js +9 -1
- package/mobile/dist/utils/url.js.map +1 -1
- package/mobile/dist/wlc.json +3 -1
- package/mobile/lib/ProjectSettings.d.ts +2 -0
- package/mobile/lib/ProjectSettings.js +5 -0
- package/mobile/lib/ProjectSettings.js.map +1 -1
- package/mobile/lib/api/LikeAPI.js +2 -2
- package/mobile/lib/api/LikeAPI.js.map +1 -1
- package/mobile/lib/hooks/useLink.js +3 -5
- package/mobile/lib/hooks/useLink.js.map +1 -1
- package/mobile/lib/hooks/useLocation.js +11 -5
- package/mobile/lib/hooks/useLocation.js.map +1 -1
- package/mobile/lib/services/BlockRouter/BlockRouter.d.ts +1 -1
- package/mobile/lib/services/BlockRouter/BlockRouter.js.map +1 -1
- package/mobile/lib/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
- package/mobile/lib/services/sitemap/checkIsHrefSameOrigin.js +1 -1
- package/mobile/lib/services/sitemap/checkIsHrefSameOrigin.js.map +1 -1
- package/mobile/lib/services/sitemap/isHrefActive.js +3 -4
- package/mobile/lib/services/sitemap/isHrefActive.js.map +1 -1
- package/mobile/lib/services/sitemap/isTopItemActive.js +3 -1
- package/mobile/lib/services/sitemap/isTopItemActive.js.map +1 -1
- package/mobile/lib/setup-fixture.js +3 -3
- package/mobile/lib/setup-fixture.js.map +1 -1
- package/mobile/lib/utils/normalizeURLPath.d.ts +1 -0
- package/mobile/lib/utils/normalizeURLPath.js +9 -0
- package/mobile/lib/utils/normalizeURLPath.js.map +1 -0
- package/mobile/lib/utils/url.d.ts +1 -0
- package/mobile/lib/utils/url.js +7 -0
- package/mobile/lib/utils/url.js.map +1 -1
- package/mobile/lib/wlc.json +3 -1
- package/mobile/src/ProjectSettings.ts +6 -0
- package/mobile/src/api/LikeAPI.ts +2 -2
- package/mobile/src/hooks/useLink.ts +6 -7
- package/mobile/src/hooks/useLocation.ts +12 -6
- package/mobile/src/services/BlockRouter/BlockRouter.ts +1 -1
- package/mobile/src/services/sitemap/checkIsHrefSameOrigin.ts +5 -4
- package/mobile/src/services/sitemap/isHrefActive.ts +7 -4
- package/mobile/src/services/sitemap/isTopItemActive.ts +3 -1
- package/mobile/src/setup-fixture.ts +3 -3
- package/mobile/src/utils/normalizeURLPath.ts +10 -0
- package/mobile/src/utils/url.ts +10 -0
- package/mobile/src/wlc.json +3 -1
- package/package.json +1 -1
- package/src/ProjectSettings.ts +6 -0
- package/src/api/LikeAPI.ts +2 -2
- package/src/components/Header/Header.tsx +2 -10
- package/src/hooks/useLink.ts +6 -7
- package/src/hooks/useLocation.ts +12 -6
- package/src/services/BlockRouter/BlockRouter.ts +1 -1
- package/src/services/sitemap/checkIsHrefSameOrigin.ts +5 -4
- package/src/services/sitemap/isHrefActive.ts +7 -4
- package/src/services/sitemap/isTopItemActive.ts +3 -1
- package/src/setup-fixture.ts +3 -3
- package/src/utils/normalizeURLPath.ts +10 -0
- package/src/utils/url.ts +10 -0
- package/src/wlc.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-fixture.js","sourceRoot":"","sources":["../src/setup-fixture.ts"],"names":[],"mappings":"AAAA,OAAO,mCAAmC,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAE3B,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE;IACnB,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"setup-fixture.js","sourceRoot":"","sources":["../src/setup-fixture.ts"],"names":[],"mappings":"AAAA,OAAO,mCAAmC,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAE3B,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAS,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE/D,OAAO;QACL,IAAI,EAAE,GAAG,UAAU,CAAC,QAAQ,CAAC,MAAM,GAAG,eAAe,CAAC,SAAS,cAAc;QAC7E,QAAQ,EAAE,eAAe;QACzB,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE;YACpB,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;YAC5C,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE;YACvB,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;YAC/C,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,aAAa,EAAO,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE;IAC7D,EAAE,CAAC,cAAc,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,aAAa,CAAC,CAAC;IAC1C,OAAO,CAAC,EAAE,CAAC,CAAC;AACd,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const normalizeURLPath: (href?: string) => string | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { projectSettings } from '../ProjectSettings.js';
|
|
2
|
+
import { isURL } from './url.js';
|
|
3
|
+
export const normalizeURLPath = (href) => {
|
|
4
|
+
if (isURL(href) || href?.startsWith('/')) {
|
|
5
|
+
return href;
|
|
6
|
+
}
|
|
7
|
+
return `${projectSettings.BASE_PATH || ''}${href}`;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=normalizeURLPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeURLPath.js","sourceRoot":"","sources":["../../src/utils/normalizeURLPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAa,EAAE,EAAE;IAChD,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,GAAG,eAAe,CAAC,SAAS,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;AACrD,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const isURL: (href?: string) => boolean | undefined;
|
|
2
2
|
export declare const withoutQuery: (href?: string) => string;
|
|
3
3
|
export declare const getOrigin: (href?: string) => string | undefined;
|
|
4
|
+
export declare const getPathname: (href?: string) => string | undefined;
|
|
4
5
|
export declare const getHash: (href?: string) => string | undefined;
|
|
5
6
|
export declare const isHash: (href?: string) => boolean | undefined;
|
package/mobile/lib/utils/url.js
CHANGED
|
@@ -10,6 +10,13 @@ export const getOrigin = (href) => {
|
|
|
10
10
|
const endOfOrigin = url.indexOf('/', endOfProto + protoSeparator.length);
|
|
11
11
|
return endOfOrigin !== -1 ? url.substring(0, endOfOrigin) : url;
|
|
12
12
|
};
|
|
13
|
+
export const getPathname = (href) => {
|
|
14
|
+
if (!href || !isURL(href)) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const url = new URL(href);
|
|
18
|
+
return url.pathname;
|
|
19
|
+
};
|
|
13
20
|
export const getHash = (href) => {
|
|
14
21
|
if (!href || !isURL(href)) {
|
|
15
22
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAa,EAA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IACvC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QACzB,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAEpC,OAAO,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAa,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC"}
|
package/mobile/lib/wlc.json
CHANGED
|
@@ -7,6 +7,7 @@ export interface ProjectSettings {
|
|
|
7
7
|
SITEMAP?: string;
|
|
8
8
|
FOOTER?: string;
|
|
9
9
|
CDN?: string; // Should ends with "/"
|
|
10
|
+
BASE_PATH?: string; // Should ends with "/"
|
|
10
11
|
YANDEX_MAP_API_KEY?: string;
|
|
11
12
|
YANDEX_METRIKA_ID?: string;
|
|
12
13
|
}
|
|
@@ -45,6 +46,11 @@ export const projectSettings = new (class implements ProjectSettings {
|
|
|
45
46
|
get CDN() {
|
|
46
47
|
return this._.CDN;
|
|
47
48
|
}
|
|
49
|
+
get BASE_PATH() {
|
|
50
|
+
return this._.BASE_PATH && !this._.BASE_PATH.endsWith('/')
|
|
51
|
+
? `${this._.BASE_PATH}/`
|
|
52
|
+
: this._.BASE_PATH;
|
|
53
|
+
}
|
|
48
54
|
get YANDEX_MAP_API_KEY() {
|
|
49
55
|
return this._.YANDEX_MAP_API_KEY;
|
|
50
56
|
}
|
|
@@ -114,7 +114,7 @@ export function LikeAPI() {
|
|
|
114
114
|
|
|
115
115
|
async function auth(): Promise<UserData> {
|
|
116
116
|
try {
|
|
117
|
-
const userData: UserData = JSON.parse(globalThis.localStorage
|
|
117
|
+
const userData: UserData = JSON.parse(globalThis.localStorage?.getItem(STORAGE_KEY) || '');
|
|
118
118
|
if (userData?.token) {
|
|
119
119
|
return userData;
|
|
120
120
|
}
|
|
@@ -136,7 +136,7 @@ export function LikeAPI() {
|
|
|
136
136
|
|
|
137
137
|
const { token, name } = await response.json();
|
|
138
138
|
|
|
139
|
-
globalThis.localStorage
|
|
139
|
+
globalThis.localStorage?.setItem(STORAGE_KEY, JSON.stringify({ token, name }));
|
|
140
140
|
|
|
141
141
|
return { token, name } as UserData;
|
|
142
142
|
} catch (e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LinkProps } from '../model/LinkProps';
|
|
1
|
+
import type { LinkProps, Target } from '../model/LinkProps';
|
|
2
2
|
import { useBlockRouter } from '../services/BlockRouter/useBlockRouter';
|
|
3
3
|
import { adjustHref } from '../utils/adjustHref';
|
|
4
4
|
import { isHash, isURL } from '../utils/url';
|
|
@@ -25,11 +25,7 @@ export function useLink(): <L extends Partial<LinkProps & ClickHandler>>(
|
|
|
25
25
|
onClick: handlerDecorator((ev?: { preventDefault: () => void }) => {
|
|
26
26
|
props.onClick && props.onClick(ev);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
const isLocalTarget = !props.target || props.target === '_self';
|
|
30
|
-
|
|
31
|
-
if (!isLocalHref || !isLocalTarget) {
|
|
32
|
-
// Default handle
|
|
28
|
+
if (isRemoteHref(href, props.target)) {
|
|
33
29
|
return;
|
|
34
30
|
}
|
|
35
31
|
|
|
@@ -37,9 +33,12 @@ export function useLink(): <L extends Partial<LinkProps & ClickHandler>>(
|
|
|
37
33
|
if (isHash(href)) {
|
|
38
34
|
blockRouter.goto(href);
|
|
39
35
|
} else {
|
|
40
|
-
router.push(href);
|
|
36
|
+
href && router.push(href);
|
|
41
37
|
}
|
|
42
38
|
}, props),
|
|
43
39
|
};
|
|
44
40
|
};
|
|
45
41
|
}
|
|
42
|
+
|
|
43
|
+
const isRemoteHref = (href?: string, target?: Target) =>
|
|
44
|
+
isURL(href) || (target && target !== '_self') || href?.startsWith('/');
|
|
@@ -15,14 +15,10 @@ interface LocationStorageData {
|
|
|
15
15
|
region: RegionData;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const localStorageLocation = globalThis?.localStorage.getItem('location');
|
|
19
|
-
const currentLocation: LocationStorageData | null = localStorageLocation
|
|
20
|
-
? JSON.parse(localStorageLocation)
|
|
21
|
-
: null;
|
|
22
|
-
|
|
23
18
|
export function useLocation(
|
|
24
19
|
defaultLocation: string,
|
|
25
20
|
): [RegionData, (newLocation: RegionData) => void] {
|
|
21
|
+
const currentLocation = getLocalStorageLocation();
|
|
26
22
|
const [location, setLocation] = useState<RegionData>(
|
|
27
23
|
currentLocation?.region ?? { name: defaultLocation },
|
|
28
24
|
);
|
|
@@ -38,7 +34,7 @@ export function useLocation(
|
|
|
38
34
|
|
|
39
35
|
const onChangeLocation = useCallback(
|
|
40
36
|
(region: RegionData) => {
|
|
41
|
-
globalThis?.
|
|
37
|
+
globalThis.localStorage?.setItem('location', JSON.stringify({ manual: true, region }));
|
|
42
38
|
setLocation(region);
|
|
43
39
|
},
|
|
44
40
|
[setLocation],
|
|
@@ -46,3 +42,13 @@ export function useLocation(
|
|
|
46
42
|
|
|
47
43
|
return [location, onChangeLocation];
|
|
48
44
|
}
|
|
45
|
+
|
|
46
|
+
const getLocalStorageLocation = (): LocationStorageData | null => {
|
|
47
|
+
const localStorageLocation = globalThis.localStorage?.getItem('location');
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
return localStorageLocation ? JSON.parse(localStorageLocation) : null;
|
|
51
|
+
} catch (_) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { Router } from '../../hooks/useRouter';
|
|
1
2
|
import { getOrigin } from '../../utils/url';
|
|
2
3
|
|
|
3
|
-
export const checkIsHrefSameOrigin = (
|
|
4
|
-
href
|
|
5
|
-
|
|
6
|
-
)
|
|
4
|
+
export const checkIsHrefSameOrigin = (href: string | undefined, router: Router) =>
|
|
5
|
+
[getOrigin(href), getOrigin(router.href)].every(
|
|
6
|
+
(link, _, arr) => Boolean(link) && link === arr[0],
|
|
7
|
+
);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeURLPath } from '../../utils/normalizeURLPath';
|
|
2
|
+
import { getPathname, isURL, withoutQuery } from '../../utils/url';
|
|
2
3
|
|
|
3
4
|
export const isHrefActive = (
|
|
4
5
|
href: string | undefined,
|
|
5
6
|
router: { pathname?: string; href?: string },
|
|
6
7
|
cmp: (targetHref: string, baseHref: string) => boolean = (targetHref, baseHref) =>
|
|
7
8
|
baseHref.startsWith(targetHref),
|
|
8
|
-
) =>
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
) =>
|
|
10
|
+
cmp(
|
|
11
|
+
withoutQuery(normalizeURLPath(href)),
|
|
12
|
+
withoutQuery(isURL(href) ? router.href : getPathname(router.href)),
|
|
13
|
+
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Router } from '../../hooks/useRouter';
|
|
2
|
+
import { projectSettings } from '../../ProjectSettings';
|
|
2
3
|
import { checkIsHrefSameOrigin } from './checkIsHrefSameOrigin';
|
|
3
4
|
import { isHrefActive } from './isHrefActive';
|
|
4
5
|
import { isSubItemActive } from './isSubItemActive';
|
|
@@ -9,4 +10,5 @@ export const isTopItemActive =
|
|
|
9
10
|
(topItem: TopMenuItem): boolean =>
|
|
10
11
|
topItem.items?.some(isSubItemActive(router)) ||
|
|
11
12
|
isHrefActive(topItem.href, router) ||
|
|
12
|
-
checkIsHrefSameOrigin(topItem.href, router)
|
|
13
|
+
checkIsHrefSameOrigin(topItem.href, router) ||
|
|
14
|
+
Boolean(projectSettings.BASE_PATH?.startsWith(topItem.href || '/'));
|
|
@@ -8,11 +8,11 @@ import wlc from './wlc.json';
|
|
|
8
8
|
projectSettings.setup(wlc);
|
|
9
9
|
|
|
10
10
|
useRouter.setup(() => {
|
|
11
|
-
const [
|
|
11
|
+
const [, setHref] = useState<string>(globalThis.location.href);
|
|
12
12
|
|
|
13
13
|
return {
|
|
14
|
-
href:
|
|
15
|
-
pathname: '/
|
|
14
|
+
href: `${globalThis.location.origin}${projectSettings.BASE_PATH}cards-credit`, //for header active links
|
|
15
|
+
pathname: '/cards-credit',
|
|
16
16
|
query: {},
|
|
17
17
|
push: (url: string) => {
|
|
18
18
|
globalThis.history.pushState(null, '', url);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { projectSettings } from '../ProjectSettings';
|
|
2
|
+
import { isURL } from './url';
|
|
3
|
+
|
|
4
|
+
export const normalizeURLPath = (href?: string) => {
|
|
5
|
+
if (isURL(href) || href?.startsWith('/')) {
|
|
6
|
+
return href;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return `${projectSettings.BASE_PATH || ''}${href}`;
|
|
10
|
+
};
|
package/mobile/src/utils/url.ts
CHANGED
|
@@ -15,6 +15,16 @@ export const getOrigin = (href?: string) => {
|
|
|
15
15
|
return endOfOrigin !== -1 ? url.substring(0, endOfOrigin) : url;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
export const getPathname = (href?: string) => {
|
|
19
|
+
if (!href || !isURL(href)) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const url = new URL(href);
|
|
24
|
+
|
|
25
|
+
return url.pathname;
|
|
26
|
+
};
|
|
27
|
+
|
|
18
28
|
export const getHash = (href?: string) => {
|
|
19
29
|
if (!href || !isURL(href)) {
|
|
20
30
|
return undefined;
|
package/mobile/src/wlc.json
CHANGED
package/package.json
CHANGED
package/src/ProjectSettings.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface ProjectSettings {
|
|
|
7
7
|
SITEMAP?: string;
|
|
8
8
|
FOOTER?: string;
|
|
9
9
|
CDN?: string; // Should ends with "/"
|
|
10
|
+
BASE_PATH?: string; // Should ends with "/"
|
|
10
11
|
YANDEX_MAP_API_KEY?: string;
|
|
11
12
|
YANDEX_METRIKA_ID?: string;
|
|
12
13
|
}
|
|
@@ -45,6 +46,11 @@ export const projectSettings = new (class implements ProjectSettings {
|
|
|
45
46
|
get CDN() {
|
|
46
47
|
return this._.CDN;
|
|
47
48
|
}
|
|
49
|
+
get BASE_PATH() {
|
|
50
|
+
return this._.BASE_PATH && !this._.BASE_PATH.endsWith('/')
|
|
51
|
+
? `${this._.BASE_PATH}/`
|
|
52
|
+
: this._.BASE_PATH;
|
|
53
|
+
}
|
|
48
54
|
get YANDEX_MAP_API_KEY() {
|
|
49
55
|
return this._.YANDEX_MAP_API_KEY;
|
|
50
56
|
}
|
package/src/api/LikeAPI.ts
CHANGED
|
@@ -114,7 +114,7 @@ export function LikeAPI() {
|
|
|
114
114
|
|
|
115
115
|
async function auth(): Promise<UserData> {
|
|
116
116
|
try {
|
|
117
|
-
const userData: UserData = JSON.parse(globalThis.localStorage
|
|
117
|
+
const userData: UserData = JSON.parse(globalThis.localStorage?.getItem(STORAGE_KEY) || '');
|
|
118
118
|
if (userData?.token) {
|
|
119
119
|
return userData;
|
|
120
120
|
}
|
|
@@ -136,7 +136,7 @@ export function LikeAPI() {
|
|
|
136
136
|
|
|
137
137
|
const { token, name } = await response.json();
|
|
138
138
|
|
|
139
|
-
globalThis.localStorage
|
|
139
|
+
globalThis.localStorage?.setItem(STORAGE_KEY, JSON.stringify({ token, name }));
|
|
140
140
|
|
|
141
141
|
return { token, name } as UserData;
|
|
142
142
|
} catch (e) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import {
|
|
2
|
+
import { useRouter } from '../../hooks/useRouter';
|
|
3
3
|
import type { BgColorVersion } from '../../model/BgColorVersion';
|
|
4
4
|
import type { UniBlockProps } from '../../model/JSXBlock';
|
|
5
|
-
import type { TopMenuItem } from '../../model/SitemapProps';
|
|
6
5
|
import { projectSettings } from '../../ProjectSettings';
|
|
7
6
|
import { isTopItemActive } from '../../services/sitemap/isTopItemActive';
|
|
8
7
|
import type { SitemapDataProps } from '../../services/sitemap/SitemapProps';
|
|
@@ -31,7 +30,7 @@ export const Header = JSX<HeaderProps>(
|
|
|
31
30
|
rest.options?.page?.fallback,
|
|
32
31
|
);
|
|
33
32
|
|
|
34
|
-
const activeTopItem =
|
|
33
|
+
const activeTopItem = topItems?.find(isTopItemActive(router));
|
|
35
34
|
|
|
36
35
|
const topMenu = topItems?.map((_, i) => (
|
|
37
36
|
<TopItem
|
|
@@ -72,10 +71,3 @@ export const Header = JSX<HeaderProps>(
|
|
|
72
71
|
);
|
|
73
72
|
},
|
|
74
73
|
);
|
|
75
|
-
|
|
76
|
-
const getActiveItem = (topItems: TopMenuItem[] | undefined, router: Router) => {
|
|
77
|
-
const [firstPortal] = topItems || [];
|
|
78
|
-
|
|
79
|
-
// Если по слагу невозможно понять к какому подпорталу этот слаг относиться, то выбираем первый подпортал.
|
|
80
|
-
return topItems?.find(isTopItemActive(router)) || firstPortal;
|
|
81
|
-
};
|
package/src/hooks/useLink.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LinkProps } from '../model/LinkProps';
|
|
1
|
+
import type { LinkProps, Target } from '../model/LinkProps';
|
|
2
2
|
import { useBlockRouter } from '../services/BlockRouter/useBlockRouter';
|
|
3
3
|
import { adjustHref } from '../utils/adjustHref';
|
|
4
4
|
import { isHash, isURL } from '../utils/url';
|
|
@@ -25,11 +25,7 @@ export function useLink(): <L extends Partial<LinkProps & ClickHandler>>(
|
|
|
25
25
|
onClick: handlerDecorator((ev?: { preventDefault: () => void }) => {
|
|
26
26
|
props.onClick && props.onClick(ev);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
const isLocalTarget = !props.target || props.target === '_self';
|
|
30
|
-
|
|
31
|
-
if (!isLocalHref || !isLocalTarget) {
|
|
32
|
-
// Default handle
|
|
28
|
+
if (isRemoteHref(href, props.target)) {
|
|
33
29
|
return;
|
|
34
30
|
}
|
|
35
31
|
|
|
@@ -37,9 +33,12 @@ export function useLink(): <L extends Partial<LinkProps & ClickHandler>>(
|
|
|
37
33
|
if (isHash(href)) {
|
|
38
34
|
blockRouter.goto(href);
|
|
39
35
|
} else {
|
|
40
|
-
router.push(href);
|
|
36
|
+
href && router.push(href);
|
|
41
37
|
}
|
|
42
38
|
}, props),
|
|
43
39
|
};
|
|
44
40
|
};
|
|
45
41
|
}
|
|
42
|
+
|
|
43
|
+
const isRemoteHref = (href?: string, target?: Target) =>
|
|
44
|
+
isURL(href) || (target && target !== '_self') || href?.startsWith('/');
|
package/src/hooks/useLocation.ts
CHANGED
|
@@ -15,14 +15,10 @@ interface LocationStorageData {
|
|
|
15
15
|
region: RegionData;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const localStorageLocation = globalThis?.localStorage.getItem('location');
|
|
19
|
-
const currentLocation: LocationStorageData | null = localStorageLocation
|
|
20
|
-
? JSON.parse(localStorageLocation)
|
|
21
|
-
: null;
|
|
22
|
-
|
|
23
18
|
export function useLocation(
|
|
24
19
|
defaultLocation: string,
|
|
25
20
|
): [RegionData, (newLocation: RegionData) => void] {
|
|
21
|
+
const currentLocation = getLocalStorageLocation();
|
|
26
22
|
const [location, setLocation] = useState<RegionData>(
|
|
27
23
|
currentLocation?.region ?? { name: defaultLocation },
|
|
28
24
|
);
|
|
@@ -38,7 +34,7 @@ export function useLocation(
|
|
|
38
34
|
|
|
39
35
|
const onChangeLocation = useCallback(
|
|
40
36
|
(region: RegionData) => {
|
|
41
|
-
globalThis?.
|
|
37
|
+
globalThis.localStorage?.setItem('location', JSON.stringify({ manual: true, region }));
|
|
42
38
|
setLocation(region);
|
|
43
39
|
},
|
|
44
40
|
[setLocation],
|
|
@@ -46,3 +42,13 @@ export function useLocation(
|
|
|
46
42
|
|
|
47
43
|
return [location, onChangeLocation];
|
|
48
44
|
}
|
|
45
|
+
|
|
46
|
+
const getLocalStorageLocation = (): LocationStorageData | null => {
|
|
47
|
+
const localStorageLocation = globalThis.localStorage?.getItem('location');
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
return localStorageLocation ? JSON.parse(localStorageLocation) : null;
|
|
51
|
+
} catch (_) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { Router } from '../../hooks/useRouter';
|
|
1
2
|
import { getOrigin } from '../../utils/url';
|
|
2
3
|
|
|
3
|
-
export const checkIsHrefSameOrigin = (
|
|
4
|
-
href
|
|
5
|
-
|
|
6
|
-
)
|
|
4
|
+
export const checkIsHrefSameOrigin = (href: string | undefined, router: Router) =>
|
|
5
|
+
[getOrigin(href), getOrigin(router.href)].every(
|
|
6
|
+
(link, _, arr) => Boolean(link) && link === arr[0],
|
|
7
|
+
);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeURLPath } from '../../utils/normalizeURLPath';
|
|
2
|
+
import { getPathname, isURL, withoutQuery } from '../../utils/url';
|
|
2
3
|
|
|
3
4
|
export const isHrefActive = (
|
|
4
5
|
href: string | undefined,
|
|
5
6
|
router: { pathname?: string; href?: string },
|
|
6
7
|
cmp: (targetHref: string, baseHref: string) => boolean = (targetHref, baseHref) =>
|
|
7
8
|
baseHref.startsWith(targetHref),
|
|
8
|
-
) =>
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
) =>
|
|
10
|
+
cmp(
|
|
11
|
+
withoutQuery(normalizeURLPath(href)),
|
|
12
|
+
withoutQuery(isURL(href) ? router.href : getPathname(router.href)),
|
|
13
|
+
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Router } from '../../hooks/useRouter';
|
|
2
|
+
import { projectSettings } from '../../ProjectSettings';
|
|
2
3
|
import { checkIsHrefSameOrigin } from './checkIsHrefSameOrigin';
|
|
3
4
|
import { isHrefActive } from './isHrefActive';
|
|
4
5
|
import { isSubItemActive } from './isSubItemActive';
|
|
@@ -9,4 +10,5 @@ export const isTopItemActive =
|
|
|
9
10
|
(topItem: TopMenuItem): boolean =>
|
|
10
11
|
topItem.items?.some(isSubItemActive(router)) ||
|
|
11
12
|
isHrefActive(topItem.href, router) ||
|
|
12
|
-
checkIsHrefSameOrigin(topItem.href, router)
|
|
13
|
+
checkIsHrefSameOrigin(topItem.href, router) ||
|
|
14
|
+
Boolean(projectSettings.BASE_PATH?.startsWith(topItem.href || '/'));
|
package/src/setup-fixture.ts
CHANGED
|
@@ -8,11 +8,11 @@ import wlc from './wlc.json';
|
|
|
8
8
|
projectSettings.setup(wlc);
|
|
9
9
|
|
|
10
10
|
useRouter.setup(() => {
|
|
11
|
-
const [
|
|
11
|
+
const [, setHref] = useState<string>(globalThis.location.href);
|
|
12
12
|
|
|
13
13
|
return {
|
|
14
|
-
href:
|
|
15
|
-
pathname: '/
|
|
14
|
+
href: `${globalThis.location.origin}${projectSettings.BASE_PATH}cards-credit`, //for header active links
|
|
15
|
+
pathname: '/cards-credit',
|
|
16
16
|
query: {},
|
|
17
17
|
push: (url: string) => {
|
|
18
18
|
globalThis.history.pushState(null, '', url);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { projectSettings } from '../ProjectSettings';
|
|
2
|
+
import { isURL } from './url';
|
|
3
|
+
|
|
4
|
+
export const normalizeURLPath = (href?: string) => {
|
|
5
|
+
if (isURL(href) || href?.startsWith('/')) {
|
|
6
|
+
return href;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return `${projectSettings.BASE_PATH || ''}${href}`;
|
|
10
|
+
};
|
package/src/utils/url.ts
CHANGED
|
@@ -15,6 +15,16 @@ export const getOrigin = (href?: string) => {
|
|
|
15
15
|
return endOfOrigin !== -1 ? url.substring(0, endOfOrigin) : url;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
export const getPathname = (href?: string) => {
|
|
19
|
+
if (!href || !isURL(href)) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const url = new URL(href);
|
|
24
|
+
|
|
25
|
+
return url.pathname;
|
|
26
|
+
};
|
|
27
|
+
|
|
18
28
|
export const getHash = (href?: string) => {
|
|
19
29
|
if (!href || !isURL(href)) {
|
|
20
30
|
return undefined;
|
package/src/wlc.json
CHANGED