@redneckz/wildless-cms-uni-blocks 0.14.774 → 0.14.775
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/bundle.umd.js +47 -24
- package/bundle/bundle.umd.min.js +1 -1
- package/dist/components/Header/useChatBot.js +33 -14
- package/dist/components/Header/useChatBot.js.map +1 -1
- package/dist/hooks/useExternalNS.js +13 -9
- package/dist/hooks/useExternalNS.js.map +1 -1
- package/lib/components/Header/useChatBot.js +33 -14
- package/lib/components/Header/useChatBot.js.map +1 -1
- package/lib/hooks/useExternalNS.js +13 -9
- package/lib/hooks/useExternalNS.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +6 -6
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/dist/components/Header/useChatBot.js +33 -14
- package/mobile/dist/components/Header/useChatBot.js.map +1 -1
- package/mobile/dist/hooks/useExternalNS.js +13 -9
- package/mobile/dist/hooks/useExternalNS.js.map +1 -1
- package/mobile/lib/components/Header/useChatBot.js +33 -14
- package/mobile/lib/components/Header/useChatBot.js.map +1 -1
- package/mobile/lib/hooks/useExternalNS.js +13 -9
- package/mobile/lib/hooks/useExternalNS.js.map +1 -1
- package/mobile/src/components/Header/useChatBot.ts +45 -22
- package/mobile/src/hooks/useExternalNS.ts +14 -9
- package/package.json +1 -1
- package/src/components/Header/useChatBot.ts +45 -22
- package/src/hooks/useExternalNS.ts +14 -9
package/bundle/bundle.umd.js
CHANGED
|
@@ -5029,7 +5029,7 @@
|
|
|
5029
5029
|
|
|
5030
5030
|
const getNS = (_) => globalThis[_];
|
|
5031
5031
|
const initializeExternalNS = (namespaceName, url, isModule = false) => {
|
|
5032
|
-
const script = document.getElementById(url);
|
|
5032
|
+
const script = globalThis.document.getElementById(url);
|
|
5033
5033
|
if (script) {
|
|
5034
5034
|
const ns = getNS(namespaceName);
|
|
5035
5035
|
if (ns) {
|
|
@@ -5045,7 +5045,7 @@
|
|
|
5045
5045
|
}
|
|
5046
5046
|
else {
|
|
5047
5047
|
return new Promise((resolve, reject) => {
|
|
5048
|
-
const newScript = document.createElement('script');
|
|
5048
|
+
const newScript = globalThis.document.createElement('script');
|
|
5049
5049
|
newScript.src = url;
|
|
5050
5050
|
newScript.async = true;
|
|
5051
5051
|
newScript.id = url;
|
|
@@ -5058,15 +5058,19 @@
|
|
|
5058
5058
|
newScript.addEventListener('error', (error) => {
|
|
5059
5059
|
reject(error);
|
|
5060
5060
|
});
|
|
5061
|
-
document.head.appendChild(newScript);
|
|
5061
|
+
globalThis.document.head.appendChild(newScript);
|
|
5062
5062
|
});
|
|
5063
5063
|
}
|
|
5064
5064
|
};
|
|
5065
5065
|
const initializeExternalStylesheet = (url = '') => {
|
|
5066
|
-
const link = document.
|
|
5067
|
-
link
|
|
5068
|
-
|
|
5069
|
-
|
|
5066
|
+
const link = globalThis.document.getElementById(url);
|
|
5067
|
+
if (!link) {
|
|
5068
|
+
const newLink = globalThis.document.createElement('link');
|
|
5069
|
+
newLink.href = url;
|
|
5070
|
+
newLink.id = url;
|
|
5071
|
+
newLink.rel = 'stylesheet';
|
|
5072
|
+
globalThis.document.head.appendChild(newLink);
|
|
5073
|
+
}
|
|
5070
5074
|
};
|
|
5071
5075
|
function useExternalNS(namespaceName, url, unmountNS = true) {
|
|
5072
5076
|
const [externalNS, setExternalNS] = useState(undefined);
|
|
@@ -5084,9 +5088,9 @@
|
|
|
5084
5088
|
return () => {
|
|
5085
5089
|
isMounted = false;
|
|
5086
5090
|
if (unmountNS) {
|
|
5087
|
-
const script = document.getElementById(url);
|
|
5091
|
+
const script = globalThis.document.getElementById(url);
|
|
5088
5092
|
if (script) {
|
|
5089
|
-
document.head.removeChild(script);
|
|
5093
|
+
globalThis.document.head.removeChild(script);
|
|
5090
5094
|
}
|
|
5091
5095
|
setExternalNS(undefined);
|
|
5092
5096
|
}
|
|
@@ -5110,25 +5114,44 @@
|
|
|
5110
5114
|
if (!chatUrl) {
|
|
5111
5115
|
return;
|
|
5112
5116
|
}
|
|
5113
|
-
if (chat
|
|
5114
|
-
|
|
5115
|
-
const businessChat = (await initializeExternalNS(CHAT_NAMESPACE, `${chatUrl}/bundle.js`, true));
|
|
5116
|
-
if (businessChat?.render) {
|
|
5117
|
-
businessChat.render(CHAT_FRAME_ID, true);
|
|
5118
|
-
}
|
|
5117
|
+
if (chat === 'business') {
|
|
5118
|
+
await renderBusinessChatBot(chatUrl);
|
|
5119
5119
|
}
|
|
5120
5120
|
else {
|
|
5121
|
-
|
|
5122
|
-
if (!target?.classList.contains(CHAT_BUTTON_EXTERNAL_NAME)) {
|
|
5123
|
-
target?.classList.add(CHAT_BUTTON_EXTERNAL_NAME);
|
|
5124
|
-
}
|
|
5125
|
-
const chatFrame = document.getElementById(CHAT_FRAME_ID);
|
|
5126
|
-
if (!chatFrame) {
|
|
5127
|
-
initializeExternalNS(CHAT_NAMESPACE, chatUrl);
|
|
5128
|
-
}
|
|
5121
|
+
renderPersonalChatBot(ev, chatUrl);
|
|
5129
5122
|
}
|
|
5130
5123
|
};
|
|
5131
5124
|
};
|
|
5125
|
+
const renderPersonalChatBot = (ev, chatUrl) => {
|
|
5126
|
+
const target = ev.target;
|
|
5127
|
+
if (!target?.classList.contains(CHAT_BUTTON_EXTERNAL_NAME)) {
|
|
5128
|
+
target?.classList.add(CHAT_BUTTON_EXTERNAL_NAME);
|
|
5129
|
+
}
|
|
5130
|
+
const chatFrame = globalThis.document.getElementById(CHAT_FRAME_ID);
|
|
5131
|
+
if (!chatFrame) {
|
|
5132
|
+
initializeExternalNS(CHAT_NAMESPACE, chatUrl);
|
|
5133
|
+
}
|
|
5134
|
+
};
|
|
5135
|
+
const renderBusinessChatBot = async (chatUrl) => {
|
|
5136
|
+
const businessChat = (await initializeExternalNS(CHAT_NAMESPACE, `${chatUrl}/bundle.js`, true));
|
|
5137
|
+
initializeExternalStylesheet(`${chatUrl}/bundle.css`);
|
|
5138
|
+
const chatFrame = globalThis.document.getElementById(CHAT_FRAME_ID);
|
|
5139
|
+
if (chatFrame) {
|
|
5140
|
+
businessChat?.chatOpen?.();
|
|
5141
|
+
}
|
|
5142
|
+
else {
|
|
5143
|
+
createChatFrame();
|
|
5144
|
+
businessChat?.render?.(CHAT_FRAME_ID, true);
|
|
5145
|
+
}
|
|
5146
|
+
};
|
|
5147
|
+
const createChatFrame = () => {
|
|
5148
|
+
const chatFrame = globalThis.document.createElement('div');
|
|
5149
|
+
chatFrame.id = CHAT_FRAME_ID;
|
|
5150
|
+
chatFrame.style.position = 'fixed';
|
|
5151
|
+
chatFrame.style.right = '0';
|
|
5152
|
+
chatFrame.style.bottom = '0';
|
|
5153
|
+
globalThis.document.body.appendChild(chatFrame);
|
|
5154
|
+
};
|
|
5132
5155
|
|
|
5133
5156
|
const HeaderChatBotButton = JSX(({ chat = 'personal', iconVersion, className, ariaLabel = 'Чат', version }) => {
|
|
5134
5157
|
const load = useChatBot(chat);
|
|
@@ -7012,7 +7035,7 @@
|
|
|
7012
7035
|
slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
|
|
7013
7036
|
});
|
|
7014
7037
|
|
|
7015
|
-
const packageVersion = "0.14.
|
|
7038
|
+
const packageVersion = "0.14.774";
|
|
7016
7039
|
|
|
7017
7040
|
exports.Blocks = Blocks;
|
|
7018
7041
|
exports.ContentPage = ContentPage;
|