@redneckz/wildless-cms-uni-blocks 0.14.249 → 0.14.250
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/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +94 -44
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/Header/HeaderChatBotButton.d.ts +4 -1
- package/bundle/components/Header/HeaderSecondaryMenuButton.d.ts +4 -1
- package/bundle/components/Header/useChatBot.d.ts +4 -1
- package/bundle/hooks/useExternalNS.d.ts +2 -1
- package/bundle/hooks/useNavigateHandler.d.ts +1 -0
- package/bundle/model/LinkProps.d.ts +2 -0
- package/dist/components/Header/HeaderChatBotButton.d.ts +4 -1
- package/dist/components/Header/HeaderChatBotButton.js +3 -11
- package/dist/components/Header/HeaderChatBotButton.js.map +1 -1
- package/dist/components/Header/HeaderSecondaryMenuButton.d.ts +4 -1
- package/dist/components/Header/HeaderSecondaryMenuButton.js.map +1 -1
- package/dist/components/Header/useChatBot.d.ts +4 -1
- package/dist/components/Header/useChatBot.js +24 -3
- package/dist/components/Header/useChatBot.js.map +1 -1
- package/dist/hooks/useExternalNS.d.ts +2 -1
- package/dist/hooks/useExternalNS.js +49 -23
- package/dist/hooks/useExternalNS.js.map +1 -1
- package/dist/hooks/useNavigateHandler.d.ts +1 -0
- package/dist/hooks/useNavigateHandler.js +19 -8
- package/dist/hooks/useNavigateHandler.js.map +1 -1
- package/dist/model/LinkProps.d.ts +2 -0
- package/dist/ui-kit/YandexMap/useYandexMaps.js +1 -1
- package/dist/ui-kit/YandexMap/useYandexMaps.js.map +1 -1
- package/lib/common.css +1 -1
- package/lib/components/Header/HeaderChatBotButton.d.ts +4 -1
- package/lib/components/Header/HeaderChatBotButton.js +3 -11
- package/lib/components/Header/HeaderChatBotButton.js.map +1 -1
- package/lib/components/Header/HeaderSecondaryMenuButton.d.ts +4 -1
- package/lib/components/Header/HeaderSecondaryMenuButton.js.map +1 -1
- package/lib/components/Header/useChatBot.d.ts +4 -1
- package/lib/components/Header/useChatBot.js +25 -4
- package/lib/components/Header/useChatBot.js.map +1 -1
- package/lib/hooks/useExternalNS.d.ts +2 -1
- package/lib/hooks/useExternalNS.js +48 -23
- package/lib/hooks/useExternalNS.js.map +1 -1
- package/lib/hooks/useNavigateHandler.d.ts +1 -0
- package/lib/hooks/useNavigateHandler.js +19 -8
- package/lib/hooks/useNavigateHandler.js.map +1 -1
- package/lib/model/LinkProps.d.ts +2 -0
- package/lib/ui-kit/YandexMap/useYandexMaps.js +1 -1
- package/lib/ui-kit/YandexMap/useYandexMaps.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +98 -32
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/Header/HeaderChatBotButton.d.ts +4 -1
- package/mobile/bundle/components/Header/HeaderSecondaryMenuButton.d.ts +4 -1
- package/mobile/bundle/components/Header/useChatBot.d.ts +4 -1
- package/mobile/bundle/hooks/useExternalNS.d.ts +2 -1
- package/mobile/bundle/hooks/useNavigateHandler.d.ts +1 -0
- package/mobile/bundle/model/LinkProps.d.ts +2 -0
- package/mobile/dist/components/Header/HeaderChatBotButton.d.ts +4 -1
- package/mobile/dist/components/Header/HeaderChatBotButton.js +3 -11
- package/mobile/dist/components/Header/HeaderChatBotButton.js.map +1 -1
- package/mobile/dist/components/Header/HeaderSecondaryMenuButton.d.ts +4 -1
- package/mobile/dist/components/Header/HeaderSecondaryMenuButton.js.map +1 -1
- package/mobile/dist/components/Header/useChatBot.d.ts +4 -1
- package/mobile/dist/components/Header/useChatBot.js +24 -3
- package/mobile/dist/components/Header/useChatBot.js.map +1 -1
- package/mobile/dist/hooks/useExternalNS.d.ts +2 -1
- package/mobile/dist/hooks/useExternalNS.js +49 -23
- package/mobile/dist/hooks/useExternalNS.js.map +1 -1
- package/mobile/dist/hooks/useNavigateHandler.d.ts +1 -0
- package/mobile/dist/hooks/useNavigateHandler.js +19 -8
- package/mobile/dist/hooks/useNavigateHandler.js.map +1 -1
- package/mobile/dist/model/LinkProps.d.ts +2 -0
- package/mobile/dist/ui-kit/YandexMap/useYandexMaps.js +1 -1
- package/mobile/dist/ui-kit/YandexMap/useYandexMaps.js.map +1 -1
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/Header/HeaderChatBotButton.d.ts +4 -1
- package/mobile/lib/components/Header/HeaderChatBotButton.js +3 -11
- package/mobile/lib/components/Header/HeaderChatBotButton.js.map +1 -1
- package/mobile/lib/components/Header/HeaderSecondaryMenuButton.d.ts +4 -1
- package/mobile/lib/components/Header/HeaderSecondaryMenuButton.js.map +1 -1
- package/mobile/lib/components/Header/useChatBot.d.ts +4 -1
- package/mobile/lib/components/Header/useChatBot.js +25 -4
- package/mobile/lib/components/Header/useChatBot.js.map +1 -1
- package/mobile/lib/hooks/useExternalNS.d.ts +2 -1
- package/mobile/lib/hooks/useExternalNS.js +48 -23
- package/mobile/lib/hooks/useExternalNS.js.map +1 -1
- package/mobile/lib/hooks/useNavigateHandler.d.ts +1 -0
- package/mobile/lib/hooks/useNavigateHandler.js +19 -8
- package/mobile/lib/hooks/useNavigateHandler.js.map +1 -1
- package/mobile/lib/model/LinkProps.d.ts +2 -0
- package/mobile/lib/ui-kit/YandexMap/useYandexMaps.js +1 -1
- package/mobile/lib/ui-kit/YandexMap/useYandexMaps.js.map +1 -1
- package/mobile/src/components/Header/HeaderChatBotButton.tsx +15 -30
- package/mobile/src/components/Header/HeaderSecondaryMenuButton.tsx +2 -1
- package/mobile/src/components/Header/useChatBot.ts +29 -5
- package/mobile/src/hooks/useExternalNS.ts +55 -25
- package/mobile/src/hooks/useNavigateHandler.ts +34 -18
- package/mobile/src/model/LinkProps.ts +2 -0
- package/mobile/src/ui-kit/YandexMap/useYandexMaps.ts +1 -1
- package/package.json +1 -1
- package/src/components/Header/HeaderChatBotButton.tsx +15 -30
- package/src/components/Header/HeaderSecondaryMenuButton.tsx +2 -1
- package/src/components/Header/useChatBot.ts +29 -5
- package/src/hooks/useExternalNS.ts +55 -25
- package/src/hooks/useNavigateHandler.ts +34 -18
- package/src/model/LinkProps.ts +2 -0
- package/src/ui-kit/YandexMap/useYandexMaps.ts +1 -1
|
@@ -4030,43 +4030,68 @@
|
|
|
4030
4030
|
};
|
|
4031
4031
|
|
|
4032
4032
|
const getNS = (_) => globalThis[_];
|
|
4033
|
-
|
|
4034
|
-
const
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
if (getNS(namespaceName)) {
|
|
4040
|
-
setNS();
|
|
4041
|
-
}
|
|
4042
|
-
else {
|
|
4043
|
-
script.addEventListener('load', setNS);
|
|
4044
|
-
return () => {
|
|
4045
|
-
script.removeEventListener('load', setNS);
|
|
4046
|
-
};
|
|
4047
|
-
}
|
|
4033
|
+
const initializeExternalNS = (namespaceName, url) => {
|
|
4034
|
+
const script = document.getElementById(url);
|
|
4035
|
+
if (script) {
|
|
4036
|
+
const ns = getNS(namespaceName);
|
|
4037
|
+
if (ns) {
|
|
4038
|
+
return Promise.resolve(ns);
|
|
4048
4039
|
}
|
|
4049
4040
|
else {
|
|
4041
|
+
return new Promise((resolve) => {
|
|
4042
|
+
script.addEventListener('load', () => {
|
|
4043
|
+
resolve(getNS(namespaceName));
|
|
4044
|
+
});
|
|
4045
|
+
});
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
else {
|
|
4049
|
+
return new Promise((resolve, reject) => {
|
|
4050
4050
|
const newScript = document.createElement('script');
|
|
4051
4051
|
newScript.src = url;
|
|
4052
4052
|
newScript.async = true;
|
|
4053
4053
|
newScript.id = url;
|
|
4054
|
-
newScript.addEventListener('load',
|
|
4054
|
+
newScript.addEventListener('load', () => {
|
|
4055
|
+
resolve(getNS(namespaceName));
|
|
4056
|
+
});
|
|
4057
|
+
newScript.addEventListener('error', (error) => {
|
|
4058
|
+
reject(error);
|
|
4059
|
+
});
|
|
4055
4060
|
document.head.appendChild(newScript);
|
|
4056
|
-
|
|
4057
|
-
|
|
4061
|
+
});
|
|
4062
|
+
}
|
|
4063
|
+
};
|
|
4064
|
+
function useExternalNS(namespaceName, url, unmountNS = true) {
|
|
4065
|
+
const [externalNS, setExternalNS] = useState(undefined);
|
|
4066
|
+
useEffect(() => {
|
|
4067
|
+
let isMounted = true;
|
|
4068
|
+
initializeExternalNS(namespaceName, url)
|
|
4069
|
+
.then((ns) => {
|
|
4070
|
+
if (isMounted) {
|
|
4071
|
+
setExternalNS(ns);
|
|
4072
|
+
}
|
|
4073
|
+
})
|
|
4074
|
+
.catch((error) => {
|
|
4075
|
+
console.error(`Failed to initialize external namespace: ${error}`);
|
|
4076
|
+
});
|
|
4077
|
+
return () => {
|
|
4078
|
+
isMounted = false;
|
|
4079
|
+
if (unmountNS) {
|
|
4080
|
+
const script = document.getElementById(url);
|
|
4081
|
+
if (script) {
|
|
4082
|
+
document.head.removeChild(script);
|
|
4083
|
+
}
|
|
4058
4084
|
setExternalNS(undefined);
|
|
4059
|
-
}
|
|
4060
|
-
}
|
|
4061
|
-
|
|
4062
|
-
}, [namespaceName, url]);
|
|
4085
|
+
}
|
|
4086
|
+
};
|
|
4087
|
+
}, [namespaceName, url, unmountNS]);
|
|
4063
4088
|
return externalNS;
|
|
4064
4089
|
}
|
|
4065
4090
|
|
|
4066
4091
|
const YMAPS_NAMESPACE = 'ymaps';
|
|
4067
4092
|
const useYandexMaps = () => {
|
|
4068
4093
|
const url = `https://api-maps.yandex.ru/2.1/?apikey=${projectSettings.YANDEX_MAP_API_KEY || ''}&lang=ru_RU`;
|
|
4069
|
-
return useExternalNS(YMAPS_NAMESPACE, url);
|
|
4094
|
+
return useExternalNS(YMAPS_NAMESPACE, url, false);
|
|
4070
4095
|
};
|
|
4071
4096
|
|
|
4072
4097
|
const styles = {
|
|
@@ -5505,6 +5530,37 @@
|
|
|
5505
5530
|
VerticalLayout,
|
|
5506
5531
|
};
|
|
5507
5532
|
|
|
5533
|
+
const CHAT_NAMESPACE = 'chatbot';
|
|
5534
|
+
const CHAT_BUTTON_EXTERNAL_NAME = 'text-page__btn-chat';
|
|
5535
|
+
const CHAT_FRAME_ID = 'webchat-js-container:webchat_rshb';
|
|
5536
|
+
const CHAT_STORAGE_NAME = 'webchat-keep-open';
|
|
5537
|
+
const CHATBOT_URL = {
|
|
5538
|
+
personal: '//chat.mes.rshb.ru/assets/js/webchat_rshb',
|
|
5539
|
+
business: '', //TODO: add url business chat
|
|
5540
|
+
};
|
|
5541
|
+
const useChatBot = (chat) => {
|
|
5542
|
+
useEffect(() => globalThis.localStorage?.setItem(CHAT_STORAGE_NAME, String(Date.now())), []);
|
|
5543
|
+
const chatUrl = CHATBOT_URL[chat ?? ''];
|
|
5544
|
+
return (ev) => {
|
|
5545
|
+
if (!chatUrl) {
|
|
5546
|
+
return;
|
|
5547
|
+
}
|
|
5548
|
+
if (chat !== 'personal') {
|
|
5549
|
+
initializeExternalNS(CHAT_NAMESPACE, chatUrl);
|
|
5550
|
+
}
|
|
5551
|
+
else {
|
|
5552
|
+
const target = ev.target;
|
|
5553
|
+
if (!target?.classList.contains(CHAT_BUTTON_EXTERNAL_NAME)) {
|
|
5554
|
+
target?.classList.add(CHAT_BUTTON_EXTERNAL_NAME);
|
|
5555
|
+
}
|
|
5556
|
+
const chatFrame = document.getElementById(CHAT_FRAME_ID);
|
|
5557
|
+
if (!chatFrame) {
|
|
5558
|
+
initializeExternalNS(CHAT_NAMESPACE, chatUrl);
|
|
5559
|
+
}
|
|
5560
|
+
}
|
|
5561
|
+
};
|
|
5562
|
+
};
|
|
5563
|
+
|
|
5508
5564
|
const QUERY_STORAGE_KEY = 'rshb-query-params';
|
|
5509
5565
|
function getSessionQuery() {
|
|
5510
5566
|
const result = globalThis.location?.search || globalThis.sessionStorage?.getItem(QUERY_STORAGE_KEY) || '';
|
|
@@ -5530,21 +5586,27 @@
|
|
|
5530
5586
|
useEffect(() => {
|
|
5531
5587
|
getSessionQuery(); //? Call first time for save query in sessionStorage
|
|
5532
5588
|
}, []);
|
|
5533
|
-
|
|
5589
|
+
const loadBot = useChatBot(projectSettings.CHAT_BOT);
|
|
5590
|
+
const reachGoalYM = (targetName) => {
|
|
5591
|
+
const [ymID] = projectSettings.YANDEX_METRIKA_ID?.split(',').reverse() ?? [];
|
|
5592
|
+
if ([ymID, targetName, globalThis.ym].every(Boolean)) {
|
|
5593
|
+
globalThis.ym(ymID, 'reachGoal', targetName);
|
|
5594
|
+
}
|
|
5595
|
+
};
|
|
5596
|
+
useEventListener(globalThis, 'click', navigationHandler({ loadBot, reachGoalYM }));
|
|
5534
5597
|
});
|
|
5535
|
-
const navigationHandler = (ev) => {
|
|
5598
|
+
const navigationHandler = (methods) => (ev) => {
|
|
5536
5599
|
const element = getAnchorElement(ev.target);
|
|
5537
|
-
const
|
|
5538
|
-
|
|
5539
|
-
if ([ymID, targetName, globalThis.ym].every(Boolean)) {
|
|
5540
|
-
globalThis.ym(ymID, 'reachGoal', targetName);
|
|
5600
|
+
for (const key in element?.dataset) {
|
|
5601
|
+
getScenario(key)?.(element, methods);
|
|
5541
5602
|
}
|
|
5542
5603
|
if (isURL(element?.href) && !element?.href?.startsWith(globalThis.location?.origin)) {
|
|
5543
5604
|
ev.preventDefault();
|
|
5544
5605
|
ev.stopPropagation();
|
|
5545
5606
|
const url = adjustSessionQuery(element?.href) || element?.href;
|
|
5546
5607
|
if (url) {
|
|
5547
|
-
|
|
5608
|
+
const transition = getTransition(element?.target);
|
|
5609
|
+
transition?.(url);
|
|
5548
5610
|
}
|
|
5549
5611
|
}
|
|
5550
5612
|
};
|
|
@@ -5555,7 +5617,7 @@
|
|
|
5555
5617
|
}
|
|
5556
5618
|
return _target;
|
|
5557
5619
|
};
|
|
5558
|
-
const
|
|
5620
|
+
const getTransition = tableFunc([
|
|
5559
5621
|
[(_) => _ === '_blank', (url) => globalThis.open(url, '_blank')],
|
|
5560
5622
|
[(_) => _ === '_parent', (url) => globalThis.parent && (globalThis.parent.location.href = url)],
|
|
5561
5623
|
[
|
|
@@ -5566,6 +5628,10 @@
|
|
|
5566
5628
|
],
|
|
5567
5629
|
[() => true, (url) => globalThis.location && (globalThis.location.href = url)],
|
|
5568
5630
|
]);
|
|
5631
|
+
const getScenario = tableFunc([
|
|
5632
|
+
[(_) => _ === 'ymtarget', (target, methods) => methods?.reachGoalYM(target?.dataset?.ymtarget)],
|
|
5633
|
+
[(_) => _ === 'chatbot', (target, methods) => methods?.loadBot({ target })],
|
|
5634
|
+
]);
|
|
5569
5635
|
|
|
5570
5636
|
const COOKIE_DIALOG_ID = 'cookie';
|
|
5571
5637
|
const DIALOG_INITIAL_DELAY = 3 * 1000;
|
|
@@ -5674,7 +5740,7 @@
|
|
|
5674
5740
|
slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
|
|
5675
5741
|
});
|
|
5676
5742
|
|
|
5677
|
-
const packageVersion = "0.14.
|
|
5743
|
+
const packageVersion = "0.14.249";
|
|
5678
5744
|
|
|
5679
5745
|
exports.Blocks = Blocks;
|
|
5680
5746
|
exports.ContentPage = ContentPage;
|