@redneckz/wildless-cms-uni-blocks 0.14.774 → 0.14.776
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 +57 -31
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/Header/HeaderSecondaryMenuButton.d.ts +1 -0
- package/bundle/components/Header/useChatBot.d.ts +4 -1
- package/dist/components/Header/HeaderChatBotButton.js +2 -2
- package/dist/components/Header/HeaderChatBotButton.js.map +1 -1
- package/dist/components/Header/HeaderSecondaryMenuButton.d.ts +1 -0
- package/dist/components/Header/HeaderSecondaryMenuButton.js +3 -3
- package/dist/components/Header/HeaderSecondaryMenuButton.js.map +1 -1
- package/dist/components/Header/useChatBot.d.ts +4 -1
- package/dist/components/Header/useChatBot.js +38 -16
- 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/HeaderChatBotButton.js +2 -2
- package/lib/components/Header/HeaderChatBotButton.js.map +1 -1
- package/lib/components/Header/HeaderSecondaryMenuButton.d.ts +1 -0
- package/lib/components/Header/HeaderSecondaryMenuButton.js +3 -3
- package/lib/components/Header/HeaderSecondaryMenuButton.js.map +1 -1
- package/lib/components/Header/useChatBot.d.ts +4 -1
- package/lib/components/Header/useChatBot.js +39 -17
- 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/bundle/components/Header/HeaderSecondaryMenuButton.d.ts +1 -0
- package/mobile/bundle/components/Header/useChatBot.d.ts +4 -1
- package/mobile/dist/components/Header/HeaderChatBotButton.js +2 -2
- package/mobile/dist/components/Header/HeaderChatBotButton.js.map +1 -1
- package/mobile/dist/components/Header/HeaderSecondaryMenuButton.d.ts +1 -0
- package/mobile/dist/components/Header/HeaderSecondaryMenuButton.js +3 -3
- 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 +38 -16
- 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/HeaderChatBotButton.js +2 -2
- package/mobile/lib/components/Header/HeaderChatBotButton.js.map +1 -1
- package/mobile/lib/components/Header/HeaderSecondaryMenuButton.d.ts +1 -0
- package/mobile/lib/components/Header/HeaderSecondaryMenuButton.js +3 -3
- 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 +39 -17
- 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/HeaderChatBotButton.tsx +2 -1
- package/mobile/src/components/Header/HeaderSecondaryMenuButton.tsx +13 -7
- package/mobile/src/components/Header/useChatBot.ts +58 -26
- package/mobile/src/hooks/useExternalNS.ts +14 -9
- package/package.json +1 -1
- package/src/components/Header/HeaderChatBotButton.tsx +2 -1
- package/src/components/Header/HeaderSecondaryMenuButton.tsx +13 -7
- package/src/components/Header/useChatBot.ts +58 -26
- package/src/hooks/useExternalNS.ts +14 -9
package/bundle/bundle.umd.js
CHANGED
|
@@ -5017,19 +5017,19 @@
|
|
|
5017
5017
|
default: 'w-6 h-6',
|
|
5018
5018
|
large: 'w-12 h-12',
|
|
5019
5019
|
};
|
|
5020
|
-
const HeaderSecondaryMenuButton = JSX(({ className, isRounded, buttonSize = 'default', isGrayBg = false, disabled, ariaLabel = 'Меню второго уровня', image, data, onClick, version, }) => {
|
|
5020
|
+
const HeaderSecondaryMenuButton = JSX(({ className, isRounded, buttonSize = 'default', isGrayBg = false, disabled, ariaLabel = 'Меню второго уровня', image, data, onClick, version, isLoading, }) => {
|
|
5021
5021
|
const grayBg = isGrayBg && !isRounded ? 'bg-main-divider' : '';
|
|
5022
5022
|
const bgColor = version === 'transparent' ? 'backdrop-opacity-30 bg-white/30' : grayBg;
|
|
5023
5023
|
return (jsx("button", { className: style('group/btn border-0 flex shrink-0 items-center', isGrayBg ? 'p-s rounded-full' : 'p-0 bg-inherit', bgColor, isRounded
|
|
5024
5024
|
? 'w-8 h-8 text-secondary-light hover:text-secondary-hove'
|
|
5025
|
-
: `${BUTTON_SIZE_STYLE[buttonSize]} text-primary-text hover:text-primary-main`, 'group-data-transparent:text-white', className), type: "button", disabled: disabled, "aria-label": ariaLabel, onClick: onClick, ...getAspectsAttributes(data), children: jsx(Img, { image: image, className: style('h-full', {
|
|
5025
|
+
: `${BUTTON_SIZE_STYLE[buttonSize]} text-primary-text hover:text-primary-main`, 'group-data-transparent:text-white', className), type: "button", disabled: disabled, "aria-label": ariaLabel, onClick: onClick, ...getAspectsAttributes(data), children: isLoading ? (jsx("div", { className: "w-full h-full rounded-full border-4 border-r-transparent animate-spin text-primary-main" })) : (jsx(Img, { image: image, className: style('h-full', {
|
|
5026
5026
|
'bg-main-divider/20 rounded-full': isRounded,
|
|
5027
|
-
}), imageClassName: "group-hover/btn:text-primary-hover group-hover/btn:invert-0" }) }));
|
|
5027
|
+
}), imageClassName: "group-hover/btn:text-primary-hover group-hover/btn:invert-0" })) }));
|
|
5028
5028
|
});
|
|
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
|
}
|
|
@@ -5104,35 +5108,57 @@
|
|
|
5104
5108
|
business: '/webchat',
|
|
5105
5109
|
};
|
|
5106
5110
|
const useChatBot = (chat) => {
|
|
5111
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
5107
5112
|
useEffect(() => globalThis.localStorage?.setItem(CHAT_STORAGE_NAME, String(Date.now())), []);
|
|
5108
5113
|
const chatUrl = CHATBOT_URL[chat ?? ''];
|
|
5109
|
-
|
|
5114
|
+
const load = useCallback((ev) => {
|
|
5110
5115
|
if (!chatUrl) {
|
|
5111
5116
|
return;
|
|
5112
5117
|
}
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
if (businessChat?.render) {
|
|
5117
|
-
businessChat.render(CHAT_FRAME_ID, true);
|
|
5118
|
-
}
|
|
5118
|
+
setIsLoading(true);
|
|
5119
|
+
if (chat === 'business') {
|
|
5120
|
+
renderBusinessChatBot(chatUrl).finally(() => setIsLoading(false));
|
|
5119
5121
|
}
|
|
5120
5122
|
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
|
-
}
|
|
5123
|
+
renderPersonalChatBot(ev, chatUrl).finally(() => setIsLoading(false));
|
|
5129
5124
|
}
|
|
5130
|
-
};
|
|
5125
|
+
}, [chatUrl, chat]);
|
|
5126
|
+
return { load, isLoading };
|
|
5127
|
+
};
|
|
5128
|
+
const renderPersonalChatBot = async (ev, chatUrl) => {
|
|
5129
|
+
const target = ev.target;
|
|
5130
|
+
if (!target?.classList.contains(CHAT_BUTTON_EXTERNAL_NAME)) {
|
|
5131
|
+
target?.classList.add(CHAT_BUTTON_EXTERNAL_NAME);
|
|
5132
|
+
}
|
|
5133
|
+
const chatFrame = globalThis.document.getElementById(CHAT_FRAME_ID);
|
|
5134
|
+
if (!chatFrame) {
|
|
5135
|
+
await initializeExternalNS(CHAT_NAMESPACE, chatUrl);
|
|
5136
|
+
}
|
|
5137
|
+
};
|
|
5138
|
+
const renderBusinessChatBot = async (chatUrl) => {
|
|
5139
|
+
const businessChat = (await initializeExternalNS(CHAT_NAMESPACE, `${chatUrl}/bundle.js`, true));
|
|
5140
|
+
initializeExternalStylesheet(`${chatUrl}/bundle.css`);
|
|
5141
|
+
const chatFrame = globalThis.document.getElementById(CHAT_FRAME_ID);
|
|
5142
|
+
if (chatFrame) {
|
|
5143
|
+
businessChat?.chatOpen?.();
|
|
5144
|
+
}
|
|
5145
|
+
else {
|
|
5146
|
+
createChatFrame();
|
|
5147
|
+
businessChat?.render?.(CHAT_FRAME_ID, true);
|
|
5148
|
+
}
|
|
5149
|
+
};
|
|
5150
|
+
const createChatFrame = () => {
|
|
5151
|
+
const chatFrame = globalThis.document.createElement('div');
|
|
5152
|
+
chatFrame.id = CHAT_FRAME_ID;
|
|
5153
|
+
chatFrame.style.position = 'fixed';
|
|
5154
|
+
chatFrame.style.right = '0';
|
|
5155
|
+
chatFrame.style.bottom = '0';
|
|
5156
|
+
globalThis.document.body.appendChild(chatFrame);
|
|
5131
5157
|
};
|
|
5132
5158
|
|
|
5133
5159
|
const HeaderChatBotButton = JSX(({ chat = 'personal', iconVersion, className, ariaLabel = 'Чат', version }) => {
|
|
5134
|
-
const load = useChatBot(chat);
|
|
5135
|
-
return (jsx(HeaderSecondaryMenuButton, { className: className, image: { icon: 'HeadphonesIcon', iconVersion }, ariaLabel: ariaLabel, onClick: load, buttonSize: "large", isGrayBg: true, version: version }));
|
|
5160
|
+
const { load, isLoading } = useChatBot(chat);
|
|
5161
|
+
return (jsx(HeaderSecondaryMenuButton, { className: className, image: { icon: 'HeadphonesIcon', iconVersion }, ariaLabel: ariaLabel, onClick: load, buttonSize: "large", isGrayBg: true, version: version, isLoading: isLoading }));
|
|
5136
5162
|
});
|
|
5137
5163
|
|
|
5138
5164
|
const HeaderItem = JSX(({ className = '', active, dataItemName, children, data, ...rest }) => {
|
|
@@ -7012,7 +7038,7 @@
|
|
|
7012
7038
|
slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
|
|
7013
7039
|
});
|
|
7014
7040
|
|
|
7015
|
-
const packageVersion = "0.14.
|
|
7041
|
+
const packageVersion = "0.14.775";
|
|
7016
7042
|
|
|
7017
7043
|
exports.Blocks = Blocks;
|
|
7018
7044
|
exports.ContentPage = ContentPage;
|