@redneckz/wildless-cms-uni-blocks 0.14.249 → 0.14.251
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 +96 -46
- 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/Select/Select.js +1 -1
- package/dist/ui-kit/Select/Select.js.map +1 -1
- package/dist/ui-kit/Select/SelectPopup.js +1 -1
- package/dist/ui-kit/Select/SelectPopup.js.map +1 -1
- 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/Select/Select.js +1 -1
- package/lib/ui-kit/Select/Select.js.map +1 -1
- package/lib/ui-kit/Select/SelectPopup.js +1 -1
- package/lib/ui-kit/Select/SelectPopup.js.map +1 -1
- 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 +100 -34
- 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/Select/Select.js +1 -1
- package/mobile/dist/ui-kit/Select/Select.js.map +1 -1
- package/mobile/dist/ui-kit/Select/SelectPopup.js +1 -1
- package/mobile/dist/ui-kit/Select/SelectPopup.js.map +1 -1
- 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/Select/Select.js +1 -1
- package/mobile/lib/ui-kit/Select/Select.js.map +1 -1
- package/mobile/lib/ui-kit/Select/SelectPopup.js +1 -1
- package/mobile/lib/ui-kit/Select/SelectPopup.js.map +1 -1
- 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/Select/Select.tsx +1 -1
- package/mobile/src/ui-kit/Select/SelectPopup.tsx +1 -1
- 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/Select/Select.tsx +1 -1
- package/src/ui-kit/Select/SelectPopup.tsx +1 -1
- package/src/ui-kit/YandexMap/useYandexMaps.ts +1 -1
package/bundle/bundle.umd.js
CHANGED
|
@@ -1000,7 +1000,7 @@
|
|
|
1000
1000
|
return options.filter((_) => _.text?.toLocaleLowerCase().includes(query?.trim().toLocaleLowerCase()));
|
|
1001
1001
|
};
|
|
1002
1002
|
|
|
1003
|
-
const SelectPopup = JSX(({ popupRef, options, value, query, onChange, iconVersion }) => options?.length ? (jsx("div", { className: "bg-white text-l max-h-64 overflow-y-auto overflow-x-hidden rounded-md", role: "list", ref: popupRef, children: filterOptions(options, query).map((option) => (jsxs("div", { className: "flex px-m py-s cursor-pointer hover:bg-main-divider pr-5xl relative", role: "listitem", "aria-selected": option.key === value?.key, onClick: (e) => {
|
|
1003
|
+
const SelectPopup = JSX(({ popupRef, options, value, query, onChange, iconVersion }) => options?.length ? (jsx("div", { className: "bg-white text-l max-h-64 overflow-y-auto overflow-x-hidden rounded-md shadow-2xl", role: "list", ref: popupRef, children: filterOptions(options, query).map((option) => (jsxs("div", { className: "flex px-m py-s cursor-pointer hover:bg-main-divider pr-5xl relative", role: "listitem", "aria-selected": option.key === value?.key, onClick: (e) => {
|
|
1004
1004
|
e.stopPropagation();
|
|
1005
1005
|
if (onChange) {
|
|
1006
1006
|
onChange(option);
|
|
@@ -1036,7 +1036,7 @@
|
|
|
1036
1036
|
|
|
1037
1037
|
const Select = JSX(
|
|
1038
1038
|
// eslint-disable-next-line complexity
|
|
1039
|
-
({ className, label, options = [], value, valid = true, isBorder = true, placeholder = '', isSearch = false, iconVersion, onChange, disabled, }) => {
|
|
1039
|
+
({ className, label, options = [], value, valid = true, isBorder = true, placeholder = '', isSearch = false, iconVersion = 'black', onChange, disabled, }) => {
|
|
1040
1040
|
const [isOpen, { setFalse: close, setTrue: open }] = useBool();
|
|
1041
1041
|
const [query, setQuery] = useState('');
|
|
1042
1042
|
const isDisabled = disabled || options.length === 0;
|
|
@@ -4259,59 +4259,99 @@
|
|
|
4259
4259
|
};
|
|
4260
4260
|
|
|
4261
4261
|
const getNS = (_) => globalThis[_];
|
|
4262
|
-
|
|
4263
|
-
const
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
if (getNS(namespaceName)) {
|
|
4269
|
-
setNS();
|
|
4270
|
-
}
|
|
4271
|
-
else {
|
|
4272
|
-
script.addEventListener('load', setNS);
|
|
4273
|
-
return () => {
|
|
4274
|
-
script.removeEventListener('load', setNS);
|
|
4275
|
-
};
|
|
4276
|
-
}
|
|
4262
|
+
const initializeExternalNS = (namespaceName, url) => {
|
|
4263
|
+
const script = document.getElementById(url);
|
|
4264
|
+
if (script) {
|
|
4265
|
+
const ns = getNS(namespaceName);
|
|
4266
|
+
if (ns) {
|
|
4267
|
+
return Promise.resolve(ns);
|
|
4277
4268
|
}
|
|
4278
4269
|
else {
|
|
4270
|
+
return new Promise((resolve) => {
|
|
4271
|
+
script.addEventListener('load', () => {
|
|
4272
|
+
resolve(getNS(namespaceName));
|
|
4273
|
+
});
|
|
4274
|
+
});
|
|
4275
|
+
}
|
|
4276
|
+
}
|
|
4277
|
+
else {
|
|
4278
|
+
return new Promise((resolve, reject) => {
|
|
4279
4279
|
const newScript = document.createElement('script');
|
|
4280
4280
|
newScript.src = url;
|
|
4281
4281
|
newScript.async = true;
|
|
4282
4282
|
newScript.id = url;
|
|
4283
|
-
newScript.addEventListener('load',
|
|
4283
|
+
newScript.addEventListener('load', () => {
|
|
4284
|
+
resolve(getNS(namespaceName));
|
|
4285
|
+
});
|
|
4286
|
+
newScript.addEventListener('error', (error) => {
|
|
4287
|
+
reject(error);
|
|
4288
|
+
});
|
|
4284
4289
|
document.head.appendChild(newScript);
|
|
4285
|
-
|
|
4286
|
-
|
|
4290
|
+
});
|
|
4291
|
+
}
|
|
4292
|
+
};
|
|
4293
|
+
function useExternalNS(namespaceName, url, unmountNS = true) {
|
|
4294
|
+
const [externalNS, setExternalNS] = useState(undefined);
|
|
4295
|
+
useEffect(() => {
|
|
4296
|
+
let isMounted = true;
|
|
4297
|
+
initializeExternalNS(namespaceName, url)
|
|
4298
|
+
.then((ns) => {
|
|
4299
|
+
if (isMounted) {
|
|
4300
|
+
setExternalNS(ns);
|
|
4301
|
+
}
|
|
4302
|
+
})
|
|
4303
|
+
.catch((error) => {
|
|
4304
|
+
console.error(`Failed to initialize external namespace: ${error}`);
|
|
4305
|
+
});
|
|
4306
|
+
return () => {
|
|
4307
|
+
isMounted = false;
|
|
4308
|
+
if (unmountNS) {
|
|
4309
|
+
const script = document.getElementById(url);
|
|
4310
|
+
if (script) {
|
|
4311
|
+
document.head.removeChild(script);
|
|
4312
|
+
}
|
|
4287
4313
|
setExternalNS(undefined);
|
|
4288
|
-
}
|
|
4289
|
-
}
|
|
4290
|
-
|
|
4291
|
-
}, [namespaceName, url]);
|
|
4314
|
+
}
|
|
4315
|
+
};
|
|
4316
|
+
}, [namespaceName, url, unmountNS]);
|
|
4292
4317
|
return externalNS;
|
|
4293
4318
|
}
|
|
4294
4319
|
|
|
4295
|
-
const
|
|
4320
|
+
const CHAT_NAMESPACE = 'chatbot';
|
|
4321
|
+
const CHAT_BUTTON_EXTERNAL_NAME = 'text-page__btn-chat';
|
|
4322
|
+
const CHAT_FRAME_ID = 'webchat-js-container:webchat_rshb';
|
|
4323
|
+
const CHAT_STORAGE_NAME = 'webchat-keep-open';
|
|
4296
4324
|
const CHATBOT_URL = {
|
|
4297
4325
|
personal: '//chat.mes.rshb.ru/assets/js/webchat_rshb',
|
|
4298
4326
|
business: '', //TODO: add url business chat
|
|
4299
4327
|
};
|
|
4300
4328
|
const useChatBot = (chat) => {
|
|
4301
|
-
useEffect(() => globalThis.localStorage?.setItem(
|
|
4302
|
-
|
|
4329
|
+
useEffect(() => globalThis.localStorage?.setItem(CHAT_STORAGE_NAME, String(Date.now())), []);
|
|
4330
|
+
const chatUrl = CHATBOT_URL[chat ?? ''];
|
|
4331
|
+
return (ev) => {
|
|
4332
|
+
if (!chatUrl) {
|
|
4333
|
+
return;
|
|
4334
|
+
}
|
|
4335
|
+
if (chat !== 'personal') {
|
|
4336
|
+
initializeExternalNS(CHAT_NAMESPACE, chatUrl);
|
|
4337
|
+
}
|
|
4338
|
+
else {
|
|
4339
|
+
const target = ev.target;
|
|
4340
|
+
if (!target?.classList.contains(CHAT_BUTTON_EXTERNAL_NAME)) {
|
|
4341
|
+
target?.classList.add(CHAT_BUTTON_EXTERNAL_NAME);
|
|
4342
|
+
}
|
|
4343
|
+
const chatFrame = document.getElementById(CHAT_FRAME_ID);
|
|
4344
|
+
if (!chatFrame) {
|
|
4345
|
+
initializeExternalNS(CHAT_NAMESPACE, chatUrl);
|
|
4346
|
+
}
|
|
4347
|
+
}
|
|
4348
|
+
};
|
|
4303
4349
|
};
|
|
4304
4350
|
|
|
4305
|
-
const
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
return loadRequested ? (jsx(HeaderChatBotButtonWithLoader, { ...props })) : (renderChatBotButton({ ...props, onClick: load }));
|
|
4351
|
+
const HeaderChatBotButton = JSX(({ chat = 'personal', iconVersion, className }) => {
|
|
4352
|
+
const load = useChatBot(chat);
|
|
4353
|
+
return (jsx(HeaderSecondaryMenuButton, { className: className, image: { icon: 'HeadphonesIcon', iconVersion }, ariaLabel: "\u0427\u0430\u0442", onClick: load, buttonSize: "large", isGrayBg: true }));
|
|
4309
4354
|
});
|
|
4310
|
-
const HeaderChatBotButtonWithLoader = JSX(({ chat = 'personal', ...rest }) => {
|
|
4311
|
-
useChatBot(chat);
|
|
4312
|
-
return renderChatBotButton(rest);
|
|
4313
|
-
});
|
|
4314
|
-
const renderChatBotButton = ({ className, iconVersion, onClick }) => (jsx(HeaderSecondaryMenuButton, { className: style(CHAT_BUTTON_EXTERNAL_NAME, className), image: { icon: 'HeadphonesIcon', iconVersion }, ariaLabel: "\u0427\u0430\u0442", onClick: onClick, buttonSize: "large", isGrayBg: true }));
|
|
4315
4355
|
|
|
4316
4356
|
const HeaderItem = JSX(({ className = '', active, dataItemName, children, ...rest }) => {
|
|
4317
4357
|
const link = useLink();
|
|
@@ -4743,7 +4783,7 @@
|
|
|
4743
4783
|
const YMAPS_NAMESPACE = 'ymaps';
|
|
4744
4784
|
const useYandexMaps = () => {
|
|
4745
4785
|
const url = `https://api-maps.yandex.ru/2.1/?apikey=${projectSettings.YANDEX_MAP_API_KEY || ''}&lang=ru_RU`;
|
|
4746
|
-
return useExternalNS(YMAPS_NAMESPACE, url);
|
|
4786
|
+
return useExternalNS(YMAPS_NAMESPACE, url, false);
|
|
4747
4787
|
};
|
|
4748
4788
|
|
|
4749
4789
|
const styles = {
|
|
@@ -5900,21 +5940,27 @@
|
|
|
5900
5940
|
useEffect(() => {
|
|
5901
5941
|
getSessionQuery(); //? Call first time for save query in sessionStorage
|
|
5902
5942
|
}, []);
|
|
5903
|
-
|
|
5943
|
+
const loadBot = useChatBot(projectSettings.CHAT_BOT);
|
|
5944
|
+
const reachGoalYM = (targetName) => {
|
|
5945
|
+
const [ymID] = projectSettings.YANDEX_METRIKA_ID?.split(',').reverse() ?? [];
|
|
5946
|
+
if ([ymID, targetName, globalThis.ym].every(Boolean)) {
|
|
5947
|
+
globalThis.ym(ymID, 'reachGoal', targetName);
|
|
5948
|
+
}
|
|
5949
|
+
};
|
|
5950
|
+
useEventListener(globalThis, 'click', navigationHandler({ loadBot, reachGoalYM }));
|
|
5904
5951
|
});
|
|
5905
|
-
const navigationHandler = (ev) => {
|
|
5952
|
+
const navigationHandler = (methods) => (ev) => {
|
|
5906
5953
|
const element = getAnchorElement(ev.target);
|
|
5907
|
-
const
|
|
5908
|
-
|
|
5909
|
-
if ([ymID, targetName, globalThis.ym].every(Boolean)) {
|
|
5910
|
-
globalThis.ym(ymID, 'reachGoal', targetName);
|
|
5954
|
+
for (const key in element?.dataset) {
|
|
5955
|
+
getScenario(key)?.(element, methods);
|
|
5911
5956
|
}
|
|
5912
5957
|
if (isURL(element?.href) && !element?.href?.startsWith(globalThis.location?.origin)) {
|
|
5913
5958
|
ev.preventDefault();
|
|
5914
5959
|
ev.stopPropagation();
|
|
5915
5960
|
const url = adjustSessionQuery(element?.href) || element?.href;
|
|
5916
5961
|
if (url) {
|
|
5917
|
-
|
|
5962
|
+
const transition = getTransition(element?.target);
|
|
5963
|
+
transition?.(url);
|
|
5918
5964
|
}
|
|
5919
5965
|
}
|
|
5920
5966
|
};
|
|
@@ -5925,7 +5971,7 @@
|
|
|
5925
5971
|
}
|
|
5926
5972
|
return _target;
|
|
5927
5973
|
};
|
|
5928
|
-
const
|
|
5974
|
+
const getTransition = tableFunc([
|
|
5929
5975
|
[(_) => _ === '_blank', (url) => globalThis.open(url, '_blank')],
|
|
5930
5976
|
[(_) => _ === '_parent', (url) => globalThis.parent && (globalThis.parent.location.href = url)],
|
|
5931
5977
|
[
|
|
@@ -5936,6 +5982,10 @@
|
|
|
5936
5982
|
],
|
|
5937
5983
|
[() => true, (url) => globalThis.location && (globalThis.location.href = url)],
|
|
5938
5984
|
]);
|
|
5985
|
+
const getScenario = tableFunc([
|
|
5986
|
+
[(_) => _ === 'ymtarget', (target, methods) => methods?.reachGoalYM(target?.dataset?.ymtarget)],
|
|
5987
|
+
[(_) => _ === 'chatbot', (target, methods) => methods?.loadBot({ target })],
|
|
5988
|
+
]);
|
|
5939
5989
|
|
|
5940
5990
|
const COOKIE_DIALOG_ID = 'cookie';
|
|
5941
5991
|
const DIALOG_INITIAL_DELAY = 3 * 1000;
|
|
@@ -6087,7 +6137,7 @@
|
|
|
6087
6137
|
slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
|
|
6088
6138
|
});
|
|
6089
6139
|
|
|
6090
|
-
const packageVersion = "0.14.
|
|
6140
|
+
const packageVersion = "0.14.250";
|
|
6091
6141
|
|
|
6092
6142
|
exports.Blocks = Blocks;
|
|
6093
6143
|
exports.ContentPage = ContentPage;
|