@redneckz/wildless-cms-uni-blocks 0.14.795 → 0.14.797
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 +5 -6
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/Header/HeaderChatBotButton.d.ts +1 -0
- package/bundle/components/Header/HeaderSecondaryMenuButton.d.ts +1 -1
- package/dist/components/Header/HeaderChatBotButton.d.ts +1 -0
- 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 -1
- package/dist/components/Header/HeaderSecondaryMenuButton.js +1 -0
- package/dist/components/Header/HeaderSecondaryMenuButton.js.map +1 -1
- package/dist/components/Header/HeaderTop.js +4 -1
- package/dist/components/Header/HeaderTop.js.map +1 -1
- package/dist/components/Header/useChatBot.js +1 -3
- package/dist/components/Header/useChatBot.js.map +1 -1
- package/lib/common.css +1 -1
- package/lib/components/Header/HeaderChatBotButton.d.ts +1 -0
- 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 -1
- package/lib/components/Header/HeaderSecondaryMenuButton.js +1 -0
- package/lib/components/Header/HeaderSecondaryMenuButton.js.map +1 -1
- package/lib/components/Header/HeaderTop.js +4 -1
- package/lib/components/Header/HeaderTop.js.map +1 -1
- package/lib/components/Header/useChatBot.js +1 -3
- package/lib/components/Header/useChatBot.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +90 -2
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/Header/HeaderChatBotButton.d.ts +1 -0
- package/mobile/bundle/components/Header/HeaderSecondaryMenuButton.d.ts +1 -1
- package/mobile/dist/components/Header/HeaderChatBotButton.d.ts +1 -0
- 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 -1
- package/mobile/dist/components/Header/HeaderSecondaryMenuButton.js +1 -0
- package/mobile/dist/components/Header/HeaderSecondaryMenuButton.js.map +1 -1
- package/mobile/dist/components/Header/HeaderTop.js +4 -1
- package/mobile/dist/components/Header/HeaderTop.js.map +1 -1
- package/mobile/dist/components/Header/useChatBot.js +1 -3
- package/mobile/dist/components/Header/useChatBot.js.map +1 -1
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/Header/HeaderChatBotButton.d.ts +1 -0
- 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 -1
- package/mobile/lib/components/Header/HeaderSecondaryMenuButton.js +1 -0
- package/mobile/lib/components/Header/HeaderSecondaryMenuButton.js.map +1 -1
- package/mobile/lib/components/Header/HeaderTop.js +4 -1
- package/mobile/lib/components/Header/HeaderTop.js.map +1 -1
- package/mobile/lib/components/Header/useChatBot.js +1 -3
- package/mobile/lib/components/Header/useChatBot.js.map +1 -1
- package/mobile/src/components/Header/HeaderChatBotButton.tsx +10 -2
- package/mobile/src/components/Header/HeaderSecondaryMenuButton.tsx +2 -1
- package/mobile/src/components/Header/HeaderTop.tsx +15 -1
- package/mobile/src/components/Header/useChatBot.ts +1 -3
- package/package.json +1 -1
- package/src/components/Header/HeaderChatBotButton.tsx +10 -2
- package/src/components/Header/HeaderSecondaryMenuButton.tsx +2 -1
- package/src/components/Header/HeaderTop.tsx +15 -1
- package/src/components/Header/useChatBot.ts +1 -3
|
@@ -3422,6 +3422,16 @@
|
|
|
3422
3422
|
});
|
|
3423
3423
|
}
|
|
3424
3424
|
};
|
|
3425
|
+
const initializeExternalStylesheet = (url = '') => {
|
|
3426
|
+
const link = globalThis.document.getElementById(url);
|
|
3427
|
+
if (!link) {
|
|
3428
|
+
const newLink = globalThis.document.createElement('link');
|
|
3429
|
+
newLink.href = url;
|
|
3430
|
+
newLink.id = url;
|
|
3431
|
+
newLink.rel = 'stylesheet';
|
|
3432
|
+
globalThis.document.head.appendChild(newLink);
|
|
3433
|
+
}
|
|
3434
|
+
};
|
|
3425
3435
|
function useExternalNS(namespaceName, url, unmountNS = true) {
|
|
3426
3436
|
const [externalNS, setExternalNS] = useState(undefined);
|
|
3427
3437
|
useEffect(() => {
|
|
@@ -9108,6 +9118,83 @@
|
|
|
9108
9118
|
return (jsx(BlockWrapper, { className: className, defaultPadding: "p-6xl", ...rest, children: jsxs("div", { className: "container space-y-m", children: [title ? jsx(Heading, { headingType: "h3", title: title, className: "@xl:text-center" }) : null, regions ? (jsx(SelectControl, { label: "\u0412\u0430\u0448 \u0440\u0435\u0433\u0438\u043E\u043D", placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0440\u0435\u0433\u0438\u043E\u043D", isSearch: true, options: regions.map(({ name = '' }) => ({ key: name, text: name })), value: region, onChange: setRegion })) : null, regionHref ? (jsx("div", { className: "text-center", children: jsx(Link, { className: style('w-full @xl:w-auto'), href: regionHref, target: "_blank", version: button?.version ?? 'primary', data: getAspectsWithInclude(data, region?.key), children: button?.text ? button.text : 'Перейти' }) })) : null] }) }));
|
|
9109
9119
|
});
|
|
9110
9120
|
|
|
9121
|
+
const BUTTON_SIZE_STYLE = {
|
|
9122
|
+
default: 'w-6 h-6',
|
|
9123
|
+
medium: 'w-10 h-10',
|
|
9124
|
+
large: 'w-12 h-12',
|
|
9125
|
+
};
|
|
9126
|
+
const HeaderSecondaryMenuButton = JSX(({ className, isRounded, buttonSize = 'default', isGrayBg = false, disabled, ariaLabel = 'Меню второго уровня', image, data, onClick, version, isLoading, dataTestId = '', }) => {
|
|
9127
|
+
const grayBg = isGrayBg && !isRounded ? 'bg-main-divider' : '';
|
|
9128
|
+
const bgColor = version === 'transparent' ? 'backdrop-opacity-30 bg-white/30' : grayBg;
|
|
9129
|
+
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
|
|
9130
|
+
? 'w-8 h-8 text-secondary-light hover:text-secondary-hove'
|
|
9131
|
+
: `${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, ...getDataTestIdAttribute(dataTestId), ...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', {
|
|
9132
|
+
'bg-main-divider/20 rounded-full': isRounded,
|
|
9133
|
+
}), imageClassName: "group-hover/btn:text-primary-hover group-hover/btn:invert-0" })) }));
|
|
9134
|
+
});
|
|
9135
|
+
const getDataTestIdAttribute = (dataTestId) => dataTestId ? { 'data-test-id': dataTestId } : null;
|
|
9136
|
+
|
|
9137
|
+
const CHAT_NAMESPACE = 'chatbot';
|
|
9138
|
+
const CHAT_BUTTON_EXTERNAL_NAME = 'text-page__btn-chat';
|
|
9139
|
+
const CHAT_FRAME_ID = 'webchat-js-container:webchat_rshb';
|
|
9140
|
+
const CHAT_STORAGE_NAME = 'webchat-keep-open';
|
|
9141
|
+
const BUSINESS_CHAT_PREFIX = '/webchat-api';
|
|
9142
|
+
const CHATBOT_URL = {
|
|
9143
|
+
personal: '//chat.mes.rshb.ru/assets/js/webchat_rshb',
|
|
9144
|
+
business: '/webchat',
|
|
9145
|
+
};
|
|
9146
|
+
const useChatBot = (chat) => {
|
|
9147
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
9148
|
+
useEffect(() => globalThis.localStorage?.setItem(CHAT_STORAGE_NAME, String(Date.now())), []);
|
|
9149
|
+
const chatUrl = CHATBOT_URL[chat ?? ''];
|
|
9150
|
+
const load = useCallback((ev) => {
|
|
9151
|
+
if (!chatUrl) {
|
|
9152
|
+
return;
|
|
9153
|
+
}
|
|
9154
|
+
setIsLoading(true);
|
|
9155
|
+
if (chat === 'business') {
|
|
9156
|
+
renderBusinessChatBot(chatUrl).finally(() => setIsLoading(false));
|
|
9157
|
+
}
|
|
9158
|
+
else {
|
|
9159
|
+
renderPersonalChatBot(ev, chatUrl).finally(() => setIsLoading(false));
|
|
9160
|
+
}
|
|
9161
|
+
}, [chatUrl, chat]);
|
|
9162
|
+
return { load, isLoading };
|
|
9163
|
+
};
|
|
9164
|
+
const renderPersonalChatBot = async (ev, chatUrl) => {
|
|
9165
|
+
const target = ev.target;
|
|
9166
|
+
if (!target?.classList.contains(CHAT_BUTTON_EXTERNAL_NAME)) {
|
|
9167
|
+
target?.classList.add(CHAT_BUTTON_EXTERNAL_NAME);
|
|
9168
|
+
}
|
|
9169
|
+
const chatFrame = globalThis.document.getElementById(CHAT_FRAME_ID);
|
|
9170
|
+
if (!chatFrame) {
|
|
9171
|
+
await initializeExternalNS(CHAT_NAMESPACE, chatUrl);
|
|
9172
|
+
}
|
|
9173
|
+
};
|
|
9174
|
+
const renderBusinessChatBot = async (chatUrl) => {
|
|
9175
|
+
const businessChat = (await initializeExternalNS(CHAT_NAMESPACE, `${chatUrl}/bundle.js`, true));
|
|
9176
|
+
initializeExternalStylesheet(`${chatUrl}/bundle.css`);
|
|
9177
|
+
const chatFrame = globalThis.document.getElementById(CHAT_FRAME_ID);
|
|
9178
|
+
if (chatFrame) {
|
|
9179
|
+
businessChat?.chatOpen?.();
|
|
9180
|
+
}
|
|
9181
|
+
else {
|
|
9182
|
+
createChatFrame();
|
|
9183
|
+
businessChat?.render?.(CHAT_FRAME_ID, true, BUSINESS_CHAT_PREFIX);
|
|
9184
|
+
}
|
|
9185
|
+
};
|
|
9186
|
+
const createChatFrame = () => {
|
|
9187
|
+
const chatFrame = globalThis.document.createElement('div');
|
|
9188
|
+
chatFrame.id = CHAT_FRAME_ID;
|
|
9189
|
+
chatFrame.className = 'fixed right-0 bottom-0 h-full w-full z-10 @3xl:w-auto h-fit';
|
|
9190
|
+
globalThis.document.body.appendChild(chatFrame);
|
|
9191
|
+
};
|
|
9192
|
+
|
|
9193
|
+
const HeaderChatBotButton = JSX(({ chat = 'personal', iconVersion, className, ariaLabel = 'Чат', version, buttonSize = 'large', }) => {
|
|
9194
|
+
const { load, isLoading } = useChatBot(chat);
|
|
9195
|
+
return (jsx(HeaderSecondaryMenuButton, { className: className, image: { icon: 'HeadphonesIcon', iconVersion }, ariaLabel: ariaLabel, onClick: load, buttonSize: buttonSize, isGrayBg: true, version: version, isLoading: isLoading, dataTestId: "chat icon" }));
|
|
9196
|
+
});
|
|
9197
|
+
|
|
9111
9198
|
const BUTTON_STYLE = {
|
|
9112
9199
|
default: 'bg-main-divider text-primary-main rounded hover:text-primary-main',
|
|
9113
9200
|
transparent: 'backdrop-opacity-30 bg-white/30 hover:text-primary-hover text-white',
|
|
@@ -9121,12 +9208,13 @@
|
|
|
9121
9208
|
const HeaderTop = JSX(({ bgColor, logo, alwaysShowLogo, internetBankButton, version, backwardButton }) => {
|
|
9122
9209
|
const router = useRouter();
|
|
9123
9210
|
const isRootLocation = router.pathname === '/';
|
|
9211
|
+
const iconVersion = version === 'transparent' ? 'white' : 'black';
|
|
9124
9212
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9125
9213
|
const { dataFooter, dataHeader, ...logoProps } = logo ?? {};
|
|
9126
9214
|
const onClick = useCallback(() => {
|
|
9127
9215
|
router.back();
|
|
9128
9216
|
}, [router]);
|
|
9129
|
-
return (jsxs("div", { className: "flex items-center justify-between w-full", children: [alwaysShowLogo || isRootLocation ? (jsx("div", { children: jsx(Logo, { className: "my-2xs", bgColor: bgColor, logo: logoProps, data: dataHeader, showTitle: false }) })) : (renderBackButton(onClick, backwardButton)), jsx(InternetBankButton, { version: version, ...internetBankButton })] }));
|
|
9217
|
+
return (jsxs("div", { className: "flex items-center justify-between w-full", children: [alwaysShowLogo || isRootLocation ? (jsx("div", { children: jsx(Logo, { className: "my-2xs", bgColor: bgColor, logo: logoProps, data: dataHeader, showTitle: false }) })) : (renderBackButton(onClick, backwardButton)), jsxs("div", { className: "flex gap-lg items-center", children: [projectSettings.CHAT_BOT ? (jsx(HeaderChatBotButton, { version: version, iconVersion: iconVersion, chat: projectSettings.CHAT_BOT, buttonSize: "medium" })) : null, jsx(InternetBankButton, { version: version, ...internetBankButton })] })] }));
|
|
9130
9218
|
});
|
|
9131
9219
|
const renderBackButton = (onClick, text) => text ? (jsxs("button", { className: "flex items-center text-l my-2xs", onClick: onClick, type: "button", "aria-label": "\u041A\u043D\u043E\u043F\u043A\u0430 \u043D\u0430\u0437\u0430\u0434", children: [jsx(Icon, { name: "ChevronLeftIcon", iconVersion: "black", width: "24", height: "24" }), text] })) : null;
|
|
9132
9220
|
|
|
@@ -10520,7 +10608,7 @@
|
|
|
10520
10608
|
slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
|
|
10521
10609
|
});
|
|
10522
10610
|
|
|
10523
|
-
const packageVersion = "0.14.
|
|
10611
|
+
const packageVersion = "0.14.796";
|
|
10524
10612
|
|
|
10525
10613
|
exports.Blocks = Blocks;
|
|
10526
10614
|
exports.ContentPage = ContentPage;
|