@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.
Files changed (152) hide show
  1. package/bundle/ProjectSettings.d.ts +2 -0
  2. package/bundle/bundle.umd.js +41 -23
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/services/BlockRouter/BlockRouter.d.ts +1 -1
  5. package/bundle/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
  6. package/bundle/utils/normalizeURLPath.d.ts +1 -0
  7. package/bundle/utils/url.d.ts +1 -0
  8. package/dist/ProjectSettings.d.ts +2 -0
  9. package/dist/ProjectSettings.js +5 -0
  10. package/dist/ProjectSettings.js.map +1 -1
  11. package/dist/api/LikeAPI.js +2 -2
  12. package/dist/api/LikeAPI.js.map +1 -1
  13. package/dist/components/Header/Header.js +1 -6
  14. package/dist/components/Header/Header.js.map +1 -1
  15. package/dist/hooks/useLink.js +3 -5
  16. package/dist/hooks/useLink.js.map +1 -1
  17. package/dist/hooks/useLocation.js +11 -5
  18. package/dist/hooks/useLocation.js.map +1 -1
  19. package/dist/services/BlockRouter/BlockRouter.d.ts +1 -1
  20. package/dist/services/BlockRouter/BlockRouter.js.map +1 -1
  21. package/dist/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
  22. package/dist/services/sitemap/checkIsHrefSameOrigin.js +1 -1
  23. package/dist/services/sitemap/checkIsHrefSameOrigin.js.map +1 -1
  24. package/dist/services/sitemap/isHrefActive.js +2 -3
  25. package/dist/services/sitemap/isHrefActive.js.map +1 -1
  26. package/dist/services/sitemap/isTopItemActive.js +3 -1
  27. package/dist/services/sitemap/isTopItemActive.js.map +1 -1
  28. package/dist/setup-fixture.js +3 -3
  29. package/dist/setup-fixture.js.map +1 -1
  30. package/dist/utils/normalizeURLPath.d.ts +1 -0
  31. package/dist/utils/normalizeURLPath.js +12 -0
  32. package/dist/utils/normalizeURLPath.js.map +1 -0
  33. package/dist/utils/url.d.ts +1 -0
  34. package/dist/utils/url.js +9 -1
  35. package/dist/utils/url.js.map +1 -1
  36. package/dist/wlc.json +3 -1
  37. package/lib/ProjectSettings.d.ts +2 -0
  38. package/lib/ProjectSettings.js +5 -0
  39. package/lib/ProjectSettings.js.map +1 -1
  40. package/lib/api/LikeAPI.js +2 -2
  41. package/lib/api/LikeAPI.js.map +1 -1
  42. package/lib/components/Header/Header.js +1 -6
  43. package/lib/components/Header/Header.js.map +1 -1
  44. package/lib/hooks/useLink.js +3 -5
  45. package/lib/hooks/useLink.js.map +1 -1
  46. package/lib/hooks/useLocation.js +11 -5
  47. package/lib/hooks/useLocation.js.map +1 -1
  48. package/lib/services/BlockRouter/BlockRouter.d.ts +1 -1
  49. package/lib/services/BlockRouter/BlockRouter.js.map +1 -1
  50. package/lib/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
  51. package/lib/services/sitemap/checkIsHrefSameOrigin.js +1 -1
  52. package/lib/services/sitemap/checkIsHrefSameOrigin.js.map +1 -1
  53. package/lib/services/sitemap/isHrefActive.js +3 -4
  54. package/lib/services/sitemap/isHrefActive.js.map +1 -1
  55. package/lib/services/sitemap/isTopItemActive.js +3 -1
  56. package/lib/services/sitemap/isTopItemActive.js.map +1 -1
  57. package/lib/setup-fixture.js +3 -3
  58. package/lib/setup-fixture.js.map +1 -1
  59. package/lib/utils/normalizeURLPath.d.ts +1 -0
  60. package/lib/utils/normalizeURLPath.js +9 -0
  61. package/lib/utils/normalizeURLPath.js.map +1 -0
  62. package/lib/utils/url.d.ts +1 -0
  63. package/lib/utils/url.js +7 -0
  64. package/lib/utils/url.js.map +1 -1
  65. package/lib/wlc.json +3 -1
  66. package/mobile/bundle/ProjectSettings.d.ts +2 -0
  67. package/mobile/bundle/bundle.umd.js +40 -17
  68. package/mobile/bundle/bundle.umd.min.js +1 -1
  69. package/mobile/bundle/services/BlockRouter/BlockRouter.d.ts +1 -1
  70. package/mobile/bundle/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
  71. package/mobile/bundle/utils/normalizeURLPath.d.ts +1 -0
  72. package/mobile/bundle/utils/url.d.ts +1 -0
  73. package/mobile/dist/ProjectSettings.d.ts +2 -0
  74. package/mobile/dist/ProjectSettings.js +5 -0
  75. package/mobile/dist/ProjectSettings.js.map +1 -1
  76. package/mobile/dist/api/LikeAPI.js +2 -2
  77. package/mobile/dist/api/LikeAPI.js.map +1 -1
  78. package/mobile/dist/hooks/useLink.js +3 -5
  79. package/mobile/dist/hooks/useLink.js.map +1 -1
  80. package/mobile/dist/hooks/useLocation.js +11 -5
  81. package/mobile/dist/hooks/useLocation.js.map +1 -1
  82. package/mobile/dist/services/BlockRouter/BlockRouter.d.ts +1 -1
  83. package/mobile/dist/services/BlockRouter/BlockRouter.js.map +1 -1
  84. package/mobile/dist/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
  85. package/mobile/dist/services/sitemap/checkIsHrefSameOrigin.js +1 -1
  86. package/mobile/dist/services/sitemap/checkIsHrefSameOrigin.js.map +1 -1
  87. package/mobile/dist/services/sitemap/isHrefActive.js +2 -3
  88. package/mobile/dist/services/sitemap/isHrefActive.js.map +1 -1
  89. package/mobile/dist/services/sitemap/isTopItemActive.js +3 -1
  90. package/mobile/dist/services/sitemap/isTopItemActive.js.map +1 -1
  91. package/mobile/dist/setup-fixture.js +3 -3
  92. package/mobile/dist/setup-fixture.js.map +1 -1
  93. package/mobile/dist/utils/normalizeURLPath.d.ts +1 -0
  94. package/mobile/dist/utils/normalizeURLPath.js +12 -0
  95. package/mobile/dist/utils/normalizeURLPath.js.map +1 -0
  96. package/mobile/dist/utils/url.d.ts +1 -0
  97. package/mobile/dist/utils/url.js +9 -1
  98. package/mobile/dist/utils/url.js.map +1 -1
  99. package/mobile/dist/wlc.json +3 -1
  100. package/mobile/lib/ProjectSettings.d.ts +2 -0
  101. package/mobile/lib/ProjectSettings.js +5 -0
  102. package/mobile/lib/ProjectSettings.js.map +1 -1
  103. package/mobile/lib/api/LikeAPI.js +2 -2
  104. package/mobile/lib/api/LikeAPI.js.map +1 -1
  105. package/mobile/lib/hooks/useLink.js +3 -5
  106. package/mobile/lib/hooks/useLink.js.map +1 -1
  107. package/mobile/lib/hooks/useLocation.js +11 -5
  108. package/mobile/lib/hooks/useLocation.js.map +1 -1
  109. package/mobile/lib/services/BlockRouter/BlockRouter.d.ts +1 -1
  110. package/mobile/lib/services/BlockRouter/BlockRouter.js.map +1 -1
  111. package/mobile/lib/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
  112. package/mobile/lib/services/sitemap/checkIsHrefSameOrigin.js +1 -1
  113. package/mobile/lib/services/sitemap/checkIsHrefSameOrigin.js.map +1 -1
  114. package/mobile/lib/services/sitemap/isHrefActive.js +3 -4
  115. package/mobile/lib/services/sitemap/isHrefActive.js.map +1 -1
  116. package/mobile/lib/services/sitemap/isTopItemActive.js +3 -1
  117. package/mobile/lib/services/sitemap/isTopItemActive.js.map +1 -1
  118. package/mobile/lib/setup-fixture.js +3 -3
  119. package/mobile/lib/setup-fixture.js.map +1 -1
  120. package/mobile/lib/utils/normalizeURLPath.d.ts +1 -0
  121. package/mobile/lib/utils/normalizeURLPath.js +9 -0
  122. package/mobile/lib/utils/normalizeURLPath.js.map +1 -0
  123. package/mobile/lib/utils/url.d.ts +1 -0
  124. package/mobile/lib/utils/url.js +7 -0
  125. package/mobile/lib/utils/url.js.map +1 -1
  126. package/mobile/lib/wlc.json +3 -1
  127. package/mobile/src/ProjectSettings.ts +6 -0
  128. package/mobile/src/api/LikeAPI.ts +2 -2
  129. package/mobile/src/hooks/useLink.ts +6 -7
  130. package/mobile/src/hooks/useLocation.ts +12 -6
  131. package/mobile/src/services/BlockRouter/BlockRouter.ts +1 -1
  132. package/mobile/src/services/sitemap/checkIsHrefSameOrigin.ts +5 -4
  133. package/mobile/src/services/sitemap/isHrefActive.ts +7 -4
  134. package/mobile/src/services/sitemap/isTopItemActive.ts +3 -1
  135. package/mobile/src/setup-fixture.ts +3 -3
  136. package/mobile/src/utils/normalizeURLPath.ts +10 -0
  137. package/mobile/src/utils/url.ts +10 -0
  138. package/mobile/src/wlc.json +3 -1
  139. package/package.json +1 -1
  140. package/src/ProjectSettings.ts +6 -0
  141. package/src/api/LikeAPI.ts +2 -2
  142. package/src/components/Header/Header.tsx +2 -10
  143. package/src/hooks/useLink.ts +6 -7
  144. package/src/hooks/useLocation.ts +12 -6
  145. package/src/services/BlockRouter/BlockRouter.ts +1 -1
  146. package/src/services/sitemap/checkIsHrefSameOrigin.ts +5 -4
  147. package/src/services/sitemap/isHrefActive.ts +7 -4
  148. package/src/services/sitemap/isTopItemActive.ts +3 -1
  149. package/src/setup-fixture.ts +3 -3
  150. package/src/utils/normalizeURLPath.ts +10 -0
  151. package/src/utils/url.ts +10 -0
  152. 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,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAS,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEnE,OAAO;QACL,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE;YACpB,UAAU,CAAC,OAAO,CAAC,SAAS,CA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,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;
@@ -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,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;AAE7D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAa,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AAEnF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAa,EAAE,EAAE;IACz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,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"}
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "PROD_BRANCH": "master",
3
3
  "FORCED_DRAFT_FLOW": false,
4
- "YANDEX_MAP_API_KEY": "f4b40c1e-1891-45f2-b307-90c481af210b"
4
+ "YANDEX_MAP_API_KEY": "f4b40c1e-1891-45f2-b307-90c481af210b",
5
+ "BASE_PATH": "/natural/",
6
+ "SITEMAP": "sayt-rshb"
5
7
  }
@@ -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.getItem(STORAGE_KEY) || '');
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.setItem(STORAGE_KEY, JSON.stringify({ token, name }));
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
- const isLocalHref = href && !isURL(href);
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?.localStorage.setItem('location', JSON.stringify({ manual: true, region }));
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
+ };
@@ -29,7 +29,7 @@ export class BlockRouter {
29
29
  }
30
30
  }
31
31
 
32
- goto(rawAnchor: string) {
32
+ goto(rawAnchor?: string) {
33
33
  const anchor = normalizeAnchor(rawAnchor);
34
34
  if (anchor) {
35
35
  this.push(anchor);
@@ -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: string | undefined,
5
- router: { pathname?: string; href?: string },
6
- ) => getOrigin(href) === getOrigin(router.href);
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 { isURL, withoutQuery } from '../../utils/url';
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
- return cmp(withoutQuery(href), withoutQuery(isURL(href) ? router.href : router.pathname));
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 [href, setHref] = useState<string>(globalThis.location.href);
11
+ const [, setHref] = useState<string>(globalThis.location.href);
12
12
 
13
13
  return {
14
- href: href,
15
- pathname: '/credits',
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
+ };
@@ -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;
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "PROD_BRANCH": "master",
3
3
  "FORCED_DRAFT_FLOW": false,
4
- "YANDEX_MAP_API_KEY": "f4b40c1e-1891-45f2-b307-90c481af210b"
4
+ "YANDEX_MAP_API_KEY": "f4b40c1e-1891-45f2-b307-90c481af210b",
5
+ "BASE_PATH": "/natural/",
6
+ "SITEMAP": "sayt-rshb"
5
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.6.43",
3
+ "version": "0.6.45",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -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.getItem(STORAGE_KEY) || '');
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.setItem(STORAGE_KEY, JSON.stringify({ token, name }));
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 { Router, useRouter } from '../../hooks/useRouter';
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 = showSubMenu ? getActiveItem(topItems, router) : null;
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
- };
@@ -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
- const isLocalHref = href && !isURL(href);
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?.localStorage.setItem('location', JSON.stringify({ manual: true, region }));
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
+ };
@@ -29,7 +29,7 @@ export class BlockRouter {
29
29
  }
30
30
  }
31
31
 
32
- goto(rawAnchor: string) {
32
+ goto(rawAnchor?: string) {
33
33
  const anchor = normalizeAnchor(rawAnchor);
34
34
  if (anchor) {
35
35
  this.push(anchor);
@@ -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: string | undefined,
5
- router: { pathname?: string; href?: string },
6
- ) => getOrigin(href) === getOrigin(router.href);
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 { isURL, withoutQuery } from '../../utils/url';
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
- return cmp(withoutQuery(href), withoutQuery(isURL(href) ? router.href : router.pathname));
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 [href, setHref] = useState<string>(globalThis.location.href);
11
+ const [, setHref] = useState<string>(globalThis.location.href);
12
12
 
13
13
  return {
14
- href: href,
15
- pathname: '/credits',
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
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "PROD_BRANCH": "master",
3
3
  "FORCED_DRAFT_FLOW": false,
4
- "YANDEX_MAP_API_KEY": "f4b40c1e-1891-45f2-b307-90c481af210b"
4
+ "YANDEX_MAP_API_KEY": "f4b40c1e-1891-45f2-b307-90c481af210b",
5
+ "BASE_PATH": "/natural/",
6
+ "SITEMAP": "sayt-rshb"
5
7
  }