@redneckz/wildless-cms-uni-blocks 0.14.773 → 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 +53 -21
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/hooks/useExternalNS.d.ts +2 -1
- package/dist/components/Header/useChatBot.js +33 -14
- package/dist/components/Header/useChatBot.js.map +1 -1
- package/dist/hooks/useExternalNS.d.ts +2 -1
- package/dist/hooks/useExternalNS.js +21 -7
- package/dist/hooks/useExternalNS.js.map +1 -1
- package/lib/components/Header/useChatBot.js +34 -15
- package/lib/components/Header/useChatBot.js.map +1 -1
- package/lib/hooks/useExternalNS.d.ts +2 -1
- package/lib/hooks/useExternalNS.js +19 -6
- package/lib/hooks/useExternalNS.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +10 -7
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/hooks/useExternalNS.d.ts +2 -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.d.ts +2 -1
- package/mobile/dist/hooks/useExternalNS.js +21 -7
- package/mobile/dist/hooks/useExternalNS.js.map +1 -1
- package/mobile/lib/components/Header/useChatBot.js +34 -15
- 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 +19 -6
- package/mobile/lib/hooks/useExternalNS.js.map +1 -1
- package/mobile/src/components/Header/useChatBot.ts +45 -21
- package/mobile/src/hooks/useExternalNS.ts +22 -6
- package/package.json +1 -1
- package/src/components/Header/useChatBot.ts +45 -21
- package/src/hooks/useExternalNS.ts +22 -6
package/bundle/bundle.umd.js
CHANGED
|
@@ -5028,8 +5028,8 @@
|
|
|
5028
5028
|
});
|
|
5029
5029
|
|
|
5030
5030
|
const getNS = (_) => globalThis[_];
|
|
5031
|
-
const initializeExternalNS = (namespaceName, url) => {
|
|
5032
|
-
const script = document.getElementById(url);
|
|
5031
|
+
const initializeExternalNS = (namespaceName, url, isModule = false) => {
|
|
5032
|
+
const script = globalThis.document.getElementById(url);
|
|
5033
5033
|
if (script) {
|
|
5034
5034
|
const ns = getNS(namespaceName);
|
|
5035
5035
|
if (ns) {
|
|
@@ -5045,20 +5045,33 @@
|
|
|
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;
|
|
5052
|
+
if (isModule) {
|
|
5053
|
+
newScript.type = 'module';
|
|
5054
|
+
}
|
|
5052
5055
|
newScript.addEventListener('load', () => {
|
|
5053
5056
|
resolve(getNS(namespaceName));
|
|
5054
5057
|
});
|
|
5055
5058
|
newScript.addEventListener('error', (error) => {
|
|
5056
5059
|
reject(error);
|
|
5057
5060
|
});
|
|
5058
|
-
document.head.appendChild(newScript);
|
|
5061
|
+
globalThis.document.head.appendChild(newScript);
|
|
5059
5062
|
});
|
|
5060
5063
|
}
|
|
5061
5064
|
};
|
|
5065
|
+
const initializeExternalStylesheet = (url = '') => {
|
|
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
|
+
}
|
|
5074
|
+
};
|
|
5062
5075
|
function useExternalNS(namespaceName, url, unmountNS = true) {
|
|
5063
5076
|
const [externalNS, setExternalNS] = useState(undefined);
|
|
5064
5077
|
useEffect(() => {
|
|
@@ -5075,9 +5088,9 @@
|
|
|
5075
5088
|
return () => {
|
|
5076
5089
|
isMounted = false;
|
|
5077
5090
|
if (unmountNS) {
|
|
5078
|
-
const script = document.getElementById(url);
|
|
5091
|
+
const script = globalThis.document.getElementById(url);
|
|
5079
5092
|
if (script) {
|
|
5080
|
-
document.head.removeChild(script);
|
|
5093
|
+
globalThis.document.head.removeChild(script);
|
|
5081
5094
|
}
|
|
5082
5095
|
setExternalNS(undefined);
|
|
5083
5096
|
}
|
|
@@ -5101,25 +5114,44 @@
|
|
|
5101
5114
|
if (!chatUrl) {
|
|
5102
5115
|
return;
|
|
5103
5116
|
}
|
|
5104
|
-
if (chat
|
|
5105
|
-
|
|
5106
|
-
const businessChat = (await initializeExternalNS(CHAT_NAMESPACE, `${chatUrl}/bundle.js`));
|
|
5107
|
-
if (businessChat?.render) {
|
|
5108
|
-
businessChat.render(CHAT_FRAME_ID, true);
|
|
5109
|
-
}
|
|
5117
|
+
if (chat === 'business') {
|
|
5118
|
+
await renderBusinessChatBot(chatUrl);
|
|
5110
5119
|
}
|
|
5111
5120
|
else {
|
|
5112
|
-
|
|
5113
|
-
if (!target?.classList.contains(CHAT_BUTTON_EXTERNAL_NAME)) {
|
|
5114
|
-
target?.classList.add(CHAT_BUTTON_EXTERNAL_NAME);
|
|
5115
|
-
}
|
|
5116
|
-
const chatFrame = document.getElementById(CHAT_FRAME_ID);
|
|
5117
|
-
if (!chatFrame) {
|
|
5118
|
-
initializeExternalNS(CHAT_NAMESPACE, chatUrl);
|
|
5119
|
-
}
|
|
5121
|
+
renderPersonalChatBot(ev, chatUrl);
|
|
5120
5122
|
}
|
|
5121
5123
|
};
|
|
5122
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
|
+
};
|
|
5123
5155
|
|
|
5124
5156
|
const HeaderChatBotButton = JSX(({ chat = 'personal', iconVersion, className, ariaLabel = 'Чат', version }) => {
|
|
5125
5157
|
const load = useChatBot(chat);
|
|
@@ -7003,7 +7035,7 @@
|
|
|
7003
7035
|
slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
|
|
7004
7036
|
});
|
|
7005
7037
|
|
|
7006
|
-
const packageVersion = "0.14.
|
|
7038
|
+
const packageVersion = "0.14.774";
|
|
7007
7039
|
|
|
7008
7040
|
exports.Blocks = Blocks;
|
|
7009
7041
|
exports.ContentPage = ContentPage;
|