@redneckz/wildless-cms-uni-blocks 0.6.43 → 0.6.44
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 +39 -22
- 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/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/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 +38 -16
- 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/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/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/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/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
|
@@ -7,6 +7,7 @@ export interface ProjectSettings {
|
|
|
7
7
|
SITEMAP?: string;
|
|
8
8
|
FOOTER?: string;
|
|
9
9
|
CDN?: string;
|
|
10
|
+
BASE_PATH?: string;
|
|
10
11
|
YANDEX_MAP_API_KEY?: string;
|
|
11
12
|
YANDEX_METRIKA_ID?: string;
|
|
12
13
|
}
|
|
@@ -21,6 +22,7 @@ export declare const projectSettings: {
|
|
|
21
22
|
readonly SITEMAP: string | undefined;
|
|
22
23
|
readonly FOOTER: string | undefined;
|
|
23
24
|
readonly CDN: string | undefined;
|
|
25
|
+
readonly BASE_PATH: string | undefined;
|
|
24
26
|
readonly YANDEX_MAP_API_KEY: string | undefined;
|
|
25
27
|
readonly YANDEX_METRIKA_ID: string | undefined;
|
|
26
28
|
};
|
package/bundle/bundle.umd.js
CHANGED
|
@@ -85,6 +85,11 @@
|
|
|
85
85
|
get CDN() {
|
|
86
86
|
return this._.CDN;
|
|
87
87
|
}
|
|
88
|
+
get BASE_PATH() {
|
|
89
|
+
return this._.BASE_PATH && !this._.BASE_PATH.endsWith('/')
|
|
90
|
+
? `${this._.BASE_PATH}/`
|
|
91
|
+
: this._.BASE_PATH;
|
|
92
|
+
}
|
|
88
93
|
get YANDEX_MAP_API_KEY() {
|
|
89
94
|
return this._.YANDEX_MAP_API_KEY;
|
|
90
95
|
}
|
|
@@ -175,7 +180,7 @@
|
|
|
175
180
|
}
|
|
176
181
|
async function auth() {
|
|
177
182
|
try {
|
|
178
|
-
const userData = JSON.parse(globalThis.localStorage
|
|
183
|
+
const userData = JSON.parse(globalThis.localStorage?.getItem(STORAGE_KEY) || '');
|
|
179
184
|
if (userData?.token) {
|
|
180
185
|
return userData;
|
|
181
186
|
}
|
|
@@ -195,7 +200,7 @@
|
|
|
195
200
|
}),
|
|
196
201
|
});
|
|
197
202
|
const { token, name } = await response.json();
|
|
198
|
-
globalThis.localStorage
|
|
203
|
+
globalThis.localStorage?.setItem(STORAGE_KEY, JSON.stringify({ token, name }));
|
|
199
204
|
return { token, name };
|
|
200
205
|
}
|
|
201
206
|
catch (e) {
|
|
@@ -585,6 +590,13 @@
|
|
|
585
590
|
const endOfOrigin = url.indexOf('/', endOfProto + protoSeparator.length);
|
|
586
591
|
return endOfOrigin !== -1 ? url.substring(0, endOfOrigin) : url;
|
|
587
592
|
};
|
|
593
|
+
const getPathname = (href) => {
|
|
594
|
+
if (!href || !isURL(href)) {
|
|
595
|
+
return undefined;
|
|
596
|
+
}
|
|
597
|
+
const url = new URL(href);
|
|
598
|
+
return url.pathname;
|
|
599
|
+
};
|
|
588
600
|
const getHash = (href) => {
|
|
589
601
|
if (!href || !isURL(href)) {
|
|
590
602
|
return undefined;
|
|
@@ -599,6 +611,7 @@
|
|
|
599
611
|
isURL: isURL,
|
|
600
612
|
withoutQuery: withoutQuery,
|
|
601
613
|
getOrigin: getOrigin,
|
|
614
|
+
getPathname: getPathname,
|
|
602
615
|
getHash: getHash,
|
|
603
616
|
isHash: isHash
|
|
604
617
|
});
|
|
@@ -650,10 +663,7 @@
|
|
|
650
663
|
'aria-label': props.text,
|
|
651
664
|
onClick: handlerDecorator((ev) => {
|
|
652
665
|
props.onClick && props.onClick(ev);
|
|
653
|
-
|
|
654
|
-
const isLocalTarget = !props.target || props.target === '_self';
|
|
655
|
-
if (!isLocalHref || !isLocalTarget) {
|
|
656
|
-
// Default handle
|
|
666
|
+
if (isRemoteHref(href, props.target)) {
|
|
657
667
|
return;
|
|
658
668
|
}
|
|
659
669
|
ev?.preventDefault();
|
|
@@ -661,12 +671,13 @@
|
|
|
661
671
|
blockRouter.goto(href);
|
|
662
672
|
}
|
|
663
673
|
else {
|
|
664
|
-
router.push(href);
|
|
674
|
+
href && router.push(href);
|
|
665
675
|
}
|
|
666
676
|
}, props),
|
|
667
677
|
};
|
|
668
678
|
};
|
|
669
679
|
}
|
|
680
|
+
const isRemoteHref = (href, target) => isURL(href) || (target && target !== '_self') || href?.startsWith('/');
|
|
670
681
|
|
|
671
682
|
const buttonStyleMap = {
|
|
672
683
|
primary: 'text-white bg-primary-main hover:bg-primary-hover active:bg-primary-active',
|
|
@@ -2248,12 +2259,17 @@
|
|
|
2248
2259
|
const renderMonthNames = (item, colSize) => item.month?.map((_, i) => (jsx("div", { style: { flexBasis: `${colSize}%` }, children: _.text }, `monthName-${i}`)));
|
|
2249
2260
|
const renderMonthImages = (item) => item.month?.map((_) => _.image?.src ? (jsx("div", { className: "h-[207px] border-r pr-3 mr-3 border-main-divider last:border-r-0 last:pr-0 last:mr-0", children: jsx(ImgInner, { image: _.image, className: "flex" }) }, `monthImage-${_.image.src}`)) : null);
|
|
2250
2261
|
|
|
2251
|
-
const checkIsHrefSameOrigin = (href, router) => getOrigin(href)
|
|
2262
|
+
const checkIsHrefSameOrigin = (href, router) => [getOrigin(href), getOrigin(router.href)].every((link, _, arr) => Boolean(link) && link === arr[0]);
|
|
2252
2263
|
|
|
2253
|
-
const
|
|
2254
|
-
|
|
2264
|
+
const normalizeURLPath = (href) => {
|
|
2265
|
+
if (isURL(href) || href?.startsWith('/')) {
|
|
2266
|
+
return href;
|
|
2267
|
+
}
|
|
2268
|
+
return `${projectSettings.BASE_PATH || ''}${href}`;
|
|
2255
2269
|
};
|
|
2256
2270
|
|
|
2271
|
+
const isHrefActive = (href, router, cmp = (targetHref, baseHref) => baseHref.startsWith(targetHref)) => cmp(withoutQuery(normalizeURLPath(href)), withoutQuery(isURL(href) ? router.href : getPathname(router.href)));
|
|
2272
|
+
|
|
2257
2273
|
const isSubItemActive = (router) => (subItem) => isHrefActive(subItem.href, router);
|
|
2258
2274
|
|
|
2259
2275
|
const isTopItemActive = (router) => (topItem) => topItem.items?.some(isSubItemActive(router)) ||
|
|
@@ -2303,11 +2319,8 @@
|
|
|
2303
2319
|
}
|
|
2304
2320
|
|
|
2305
2321
|
const REGION_URL = '/api/v1/region';
|
|
2306
|
-
const localStorageLocation = globalThis?.localStorage.getItem('location');
|
|
2307
|
-
const currentLocation = localStorageLocation
|
|
2308
|
-
? JSON.parse(localStorageLocation)
|
|
2309
|
-
: null;
|
|
2310
2322
|
function useLocation(defaultLocation) {
|
|
2323
|
+
const currentLocation = getLocalStorageLocation();
|
|
2311
2324
|
const [location, setLocation] = useState(currentLocation?.region ?? { name: defaultLocation });
|
|
2312
2325
|
const { data } = useCachedAsyncData(REGION_URL, fetchJSONUnsafe);
|
|
2313
2326
|
useEffect(() => {
|
|
@@ -2316,11 +2329,20 @@
|
|
|
2316
2329
|
: data || { name: defaultLocation });
|
|
2317
2330
|
}, [data]);
|
|
2318
2331
|
const onChangeLocation = useCallback((region) => {
|
|
2319
|
-
globalThis?.
|
|
2332
|
+
globalThis.localStorage?.setItem('location', JSON.stringify({ manual: true, region }));
|
|
2320
2333
|
setLocation(region);
|
|
2321
2334
|
}, [setLocation]);
|
|
2322
2335
|
return [location, onChangeLocation];
|
|
2323
2336
|
}
|
|
2337
|
+
const getLocalStorageLocation = () => {
|
|
2338
|
+
const localStorageLocation = globalThis.localStorage?.getItem('location');
|
|
2339
|
+
try {
|
|
2340
|
+
return localStorageLocation ? JSON.parse(localStorageLocation) : null;
|
|
2341
|
+
}
|
|
2342
|
+
catch (_) {
|
|
2343
|
+
return null;
|
|
2344
|
+
}
|
|
2345
|
+
};
|
|
2324
2346
|
|
|
2325
2347
|
const REGIONS_URL$1 = '/api/v1/regions';
|
|
2326
2348
|
function useRegions() {
|
|
@@ -2480,15 +2502,10 @@
|
|
|
2480
2502
|
const Header = JSX(({ bgColor = 'bg-white', className = '', showSubMenu = true, ...rest }) => {
|
|
2481
2503
|
const router = useRouter();
|
|
2482
2504
|
const { topItems, logo, defaultLocation, foreignOffices, officesLink } = useSWRResource(projectSettings.SITEMAP || 'sitemap', rest.options?.page?.fallback);
|
|
2483
|
-
const activeTopItem =
|
|
2505
|
+
const activeTopItem = topItems?.find(isTopItemActive(router));
|
|
2484
2506
|
const topMenu = topItems?.map((_, i) => (jsx(TopItem, { active: _ === activeTopItem, "aria-label": _.text, bgColor: bgColor, ..._ }, String(i))));
|
|
2485
2507
|
return (jsx(BlockWrapper, { tag: "header", className: `pt-6 px-20 ${bgColor} ${className} ${showSubMenu && activeTopItem?.items?.length ? 'pb-4' : 'pb-5'}`, ...rest, children: jsxs("div", { className: "container", children: [jsxs("div", { className: "flex items-center", children: [jsx(Logo, { className: "mr-8", bgColor: bgColor, logo: logo }), topMenu, jsx(HeaderSecondaryMenu, { className: "ml-auto", foreignOffices: foreignOffices, defaultLocation: defaultLocation, officesLink: officesLink, bgColor: bgColor })] }), jsx("div", { className: `mt-6 h-px ${BORDER_COLORS[bgColor]}` }), showSubMenu && activeTopItem?.items?.length ? (jsx(HeaderSubMenu, { subItems: activeTopItem.items, bgColor: bgColor })) : null] }) }));
|
|
2486
2508
|
});
|
|
2487
|
-
const getActiveItem = (topItems, router) => {
|
|
2488
|
-
const [firstPortal] = topItems || [];
|
|
2489
|
-
// Если по слагу невозможно понять к какому подпорталу этот слаг относиться, то выбираем первый подпортал.
|
|
2490
|
-
return topItems?.find(isTopItemActive(router)) || firstPortal;
|
|
2491
|
-
};
|
|
2492
2509
|
|
|
2493
2510
|
const ImgBlock = JSX((props) => {
|
|
2494
2511
|
const { className, image, ...rest } = props;
|
|
@@ -4107,7 +4124,7 @@
|
|
|
4107
4124
|
return (jsx("div", { className: "flex items-end absolute bottom-0 right-0 h-full pointer-events-none", children: jsx(LikeControl, { className: "rounded-tl-lg sticky bottom-0 pointer-events-auto" }) }));
|
|
4108
4125
|
}
|
|
4109
4126
|
|
|
4110
|
-
const packageVersion = "0.6.
|
|
4127
|
+
const packageVersion = "0.6.44";
|
|
4111
4128
|
|
|
4112
4129
|
exports.Blocks = Blocks;
|
|
4113
4130
|
exports.ContentPage = ContentPage;
|