@redneckz/wildless-cms-uni-blocks 0.14.249 → 0.14.250
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 +94 -44
- 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/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/YandexMap/useYandexMaps.js +1 -1
- package/lib/ui-kit/YandexMap/useYandexMaps.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +98 -32
- 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/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/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/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/YandexMap/useYandexMaps.ts +1 -1
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { type IconVersion } from '../../model/IconVersion';
|
|
2
|
+
import { type PreventableEvent } from '../../ui-kit/PreventableEvent';
|
|
2
3
|
interface HeaderChatBotButtonProps {
|
|
3
4
|
className?: string;
|
|
4
5
|
iconVersion?: IconVersion;
|
|
5
6
|
chat?: string;
|
|
6
|
-
onClick?: (
|
|
7
|
+
onClick?: (ev: PreventableEvent & {
|
|
8
|
+
target: EventTarget | null;
|
|
9
|
+
}) => void;
|
|
7
10
|
}
|
|
8
11
|
export declare const HeaderChatBotButton: import("@redneckz/uni-jsx").UNIComponent<HeaderChatBotButtonProps, any, any>;
|
|
9
12
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ImageContent } from '../../ui-kit/Img/ImgProps';
|
|
2
|
+
import { type PreventableEvent } from '../../ui-kit/PreventableEvent';
|
|
2
3
|
export interface HeaderSecondaryMenuButtonProps extends ImageContent {
|
|
3
4
|
className?: string;
|
|
4
5
|
isRounded?: boolean;
|
|
@@ -6,6 +7,8 @@ export interface HeaderSecondaryMenuButtonProps extends ImageContent {
|
|
|
6
7
|
isGrayBg?: boolean;
|
|
7
8
|
disabled?: boolean;
|
|
8
9
|
ariaLabel?: string;
|
|
9
|
-
onClick?: (
|
|
10
|
+
onClick?: (ev: PreventableEvent & {
|
|
11
|
+
target: EventTarget | null;
|
|
12
|
+
}) => void;
|
|
10
13
|
}
|
|
11
14
|
export declare const HeaderSecondaryMenuButton: import("@redneckz/uni-jsx").UNIComponent<HeaderSecondaryMenuButtonProps, any, any>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare const getNS: <NS>(_: string) => NS | undefined;
|
|
2
|
-
export declare
|
|
2
|
+
export declare const initializeExternalNS: <NS>(namespaceName: string, url: string) => Promise<NS | undefined>;
|
|
3
|
+
export declare function useExternalNS<NS>(namespaceName: string, url: string, unmountNS?: boolean): NS | undefined;
|
|
@@ -13,6 +13,8 @@ export declare type Target = '' | '_self' | '_blank' | '_parent' | '_top';
|
|
|
13
13
|
export declare type DataAttributes = {
|
|
14
14
|
/** @title Имя цели для Яндекс Метрики */
|
|
15
15
|
ymTarget?: string;
|
|
16
|
+
/** @title Открыть чат бот */
|
|
17
|
+
chatbot?: boolean;
|
|
16
18
|
};
|
|
17
19
|
export interface LinkCommonProps {
|
|
18
20
|
/** @title URL (href) */
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { type IconVersion } from '../../model/IconVersion';
|
|
2
|
+
import { type PreventableEvent } from '../../ui-kit/PreventableEvent';
|
|
2
3
|
interface HeaderChatBotButtonProps {
|
|
3
4
|
className?: string;
|
|
4
5
|
iconVersion?: IconVersion;
|
|
5
6
|
chat?: string;
|
|
6
|
-
onClick?: (
|
|
7
|
+
onClick?: (ev: PreventableEvent & {
|
|
8
|
+
target: EventTarget | null;
|
|
9
|
+
}) => void;
|
|
7
10
|
}
|
|
8
11
|
export declare const HeaderChatBotButton: import("@redneckz/uni-jsx").UNIComponent<HeaderChatBotButtonProps, any, any>;
|
|
9
12
|
export {};
|
|
@@ -2,18 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
2
2
|
exports.HeaderChatBotButton = void 0;
|
|
3
3
|
const jsx_runtime_1 = require("@redneckz/uni-jsx/jsx-runtime");
|
|
4
4
|
const uni_jsx_1 = require("@redneckz/uni-jsx");
|
|
5
|
-
const useBool_1 = require("@redneckz/uni-jsx/lib/hooks/useBool");
|
|
6
|
-
const style_1 = require("../../utils/style");
|
|
7
5
|
const HeaderSecondaryMenuButton_1 = require("./HeaderSecondaryMenuButton");
|
|
8
6
|
const useChatBot_1 = require("./useChatBot");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return loadRequested ? ((0, jsx_runtime_1.jsx)(HeaderChatBotButtonWithLoader, { ...props })) : (renderChatBotButton({ ...props, onClick: load }));
|
|
7
|
+
exports.HeaderChatBotButton = (0, uni_jsx_1.JSX)(({ chat = 'personal', iconVersion, className }) => {
|
|
8
|
+
const load = (0, useChatBot_1.useChatBot)(chat);
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)(HeaderSecondaryMenuButton_1.HeaderSecondaryMenuButton, { className: className, image: { icon: 'HeadphonesIcon', iconVersion }, ariaLabel: "\u0427\u0430\u0442", onClick: load, buttonSize: "large", isGrayBg: true }));
|
|
13
10
|
});
|
|
14
|
-
const HeaderChatBotButtonWithLoader = (0, uni_jsx_1.JSX)(({ chat = 'personal', ...rest }) => {
|
|
15
|
-
(0, useChatBot_1.useChatBot)(chat);
|
|
16
|
-
return renderChatBotButton(rest);
|
|
17
|
-
});
|
|
18
|
-
const renderChatBotButton = ({ className, iconVersion, onClick }) => ((0, jsx_runtime_1.jsx)(HeaderSecondaryMenuButton_1.HeaderSecondaryMenuButton, { className: (0, style_1.style)(CHAT_BUTTON_EXTERNAL_NAME, className), image: { icon: 'HeadphonesIcon', iconVersion }, ariaLabel: "\u0427\u0430\u0442", onClick: onClick, buttonSize: "large", isGrayBg: true }));
|
|
19
11
|
//# sourceMappingURL=HeaderChatBotButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderChatBotButton.js","sourceRoot":"","sources":["../../../src/components/Header/HeaderChatBotButton.tsx"],"names":[],"mappings":";;;AAAA,+CAAwC;
|
|
1
|
+
{"version":3,"file":"HeaderChatBotButton.js","sourceRoot":"","sources":["../../../src/components/Header/HeaderChatBotButton.tsx"],"names":[],"mappings":";;;AAAA,+CAAwC;AAGxC,2EAAwE;AACxE,6CAA0C;AAS7B,QAAA,mBAAmB,GAAG,IAAA,aAAG,EACpC,CAAC,EAAE,IAAI,GAAG,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,EAAE;IAChD,MAAM,IAAI,GAAG,IAAA,uBAAU,EAAC,IAAI,CAAC,CAAC;IAE9B,OAAO,CACL,uBAAC,qDAAyB,IACxB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,WAAW,EAAE,EAC9C,SAAS,EAAC,oBAAK,EACf,OAAO,EAAE,IAAI,EACb,UAAU,EAAC,OAAO,EAClB,QAAQ,EAAE,IAAI,GACd,CACH,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ImageContent } from '../../ui-kit/Img/ImgProps';
|
|
2
|
+
import { type PreventableEvent } from '../../ui-kit/PreventableEvent';
|
|
2
3
|
export interface HeaderSecondaryMenuButtonProps extends ImageContent {
|
|
3
4
|
className?: string;
|
|
4
5
|
isRounded?: boolean;
|
|
@@ -6,6 +7,8 @@ export interface HeaderSecondaryMenuButtonProps extends ImageContent {
|
|
|
6
7
|
isGrayBg?: boolean;
|
|
7
8
|
disabled?: boolean;
|
|
8
9
|
ariaLabel?: string;
|
|
9
|
-
onClick?: (
|
|
10
|
+
onClick?: (ev: PreventableEvent & {
|
|
11
|
+
target: EventTarget | null;
|
|
12
|
+
}) => void;
|
|
10
13
|
}
|
|
11
14
|
export declare const HeaderSecondaryMenuButton: import("@redneckz/uni-jsx").UNIComponent<HeaderSecondaryMenuButtonProps, any, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderSecondaryMenuButton.js","sourceRoot":"","sources":["../../../src/components/Header/HeaderSecondaryMenuButton.tsx"],"names":[],"mappings":";;;AAAA,+CAAwC;AACxC,8CAA2C;
|
|
1
|
+
{"version":3,"file":"HeaderSecondaryMenuButton.js","sourceRoot":"","sources":["../../../src/components/Header/HeaderSecondaryMenuButton.tsx"],"names":[],"mappings":";;;AAAA,+CAAwC;AACxC,8CAA2C;AAG3C,6CAA0C;AAY1C,MAAM,iBAAiB,GAAG;IACxB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,WAAW;CACnB,CAAC;AAEW,QAAA,yBAAyB,GAAG,IAAA,aAAG,EAC1C,CAAC,EACC,SAAS,EACT,SAAS,EACT,UAAU,GAAG,SAAS,EACtB,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,SAAS,EACT,KAAK,EACL,OAAO,GACR,EAAE,EAAE,CAAC,CACJ,mCACE,SAAS,EAAE,IAAA,aAAK,EACd,+CAA+C,EAC/C,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,EAChD,QAAQ,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAC/C,SAAS;QACP,CAAC,CAAC,wDAAwD;QAC1D,CAAC,CAAC,GAAG,iBAAiB,CAAC,UAAU,CAAC,4CAA4C,EAChF,mCAAmC,EACnC,SAAS,CACV,EACD,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,QAAQ,gBACN,SAAS,EACrB,OAAO,EAAE,OAAO,YAEhB,uBAAC,SAAG,IACF,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,IAAA,aAAK,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,EAAE,CAAC,EAC9E,cAAc,EAAC,6DAA6D,GAC5E,GACK,CACV,CACF,CAAC"}
|
|
@@ -2,14 +2,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
2
2
|
exports.useChatBot = void 0;
|
|
3
3
|
const hooks_1 = require("@redneckz/uni-jsx/lib/hooks");
|
|
4
4
|
const useExternalNS_1 = require("../../hooks/useExternalNS");
|
|
5
|
-
const
|
|
5
|
+
const CHAT_NAMESPACE = 'chatbot';
|
|
6
|
+
const CHAT_BUTTON_EXTERNAL_NAME = 'text-page__btn-chat';
|
|
7
|
+
const CHAT_FRAME_ID = 'webchat-js-container:webchat_rshb';
|
|
8
|
+
const CHAT_STORAGE_NAME = 'webchat-keep-open';
|
|
6
9
|
const CHATBOT_URL = {
|
|
7
10
|
personal: '//chat.mes.rshb.ru/assets/js/webchat_rshb',
|
|
8
11
|
business: '', //TODO: add url business chat
|
|
9
12
|
};
|
|
10
13
|
const useChatBot = (chat) => {
|
|
11
|
-
(0, hooks_1.useEffect)(() => globalThis.localStorage?.setItem(
|
|
12
|
-
|
|
14
|
+
(0, hooks_1.useEffect)(() => globalThis.localStorage?.setItem(CHAT_STORAGE_NAME, String(Date.now())), []);
|
|
15
|
+
const chatUrl = CHATBOT_URL[chat ?? ''];
|
|
16
|
+
return (ev) => {
|
|
17
|
+
if (!chatUrl) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (chat !== 'personal') {
|
|
21
|
+
(0, useExternalNS_1.initializeExternalNS)(CHAT_NAMESPACE, chatUrl);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const target = ev.target;
|
|
25
|
+
if (!target?.classList.contains(CHAT_BUTTON_EXTERNAL_NAME)) {
|
|
26
|
+
target?.classList.add(CHAT_BUTTON_EXTERNAL_NAME);
|
|
27
|
+
}
|
|
28
|
+
const chatFrame = document.getElementById(CHAT_FRAME_ID);
|
|
29
|
+
if (!chatFrame) {
|
|
30
|
+
(0, useExternalNS_1.initializeExternalNS)(CHAT_NAMESPACE, chatUrl);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
13
34
|
};
|
|
14
35
|
exports.useChatBot = useChatBot;
|
|
15
36
|
//# sourceMappingURL=useChatBot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatBot.js","sourceRoot":"","sources":["../../../src/components/Header/useChatBot.ts"],"names":[],"mappings":";;AAAA,uDAAwD;AACxD,
|
|
1
|
+
{"version":3,"file":"useChatBot.js","sourceRoot":"","sources":["../../../src/components/Header/useChatBot.ts"],"names":[],"mappings":";;AAAA,uDAAwD;AACxD,6DAAiE;AAGjE,MAAM,cAAc,GAAG,SAAS,CAAC;AACjC,MAA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<NS>(namespaceName: string, url: string) => Promise<NS | undefined>;
|
|
3
|
+
export declare function useExternalNS<NS>(namespaceName: string, url: string, unmountNS?: boolean): NS | undefined;
|
|
@@ -1,38 +1,64 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.useExternalNS = exports.getNS = void 0;
|
|
2
|
+
exports.useExternalNS = exports.initializeExternalNS = exports.getNS = void 0;
|
|
3
3
|
const hooks_1 = require("@redneckz/uni-jsx/lib/hooks");
|
|
4
4
|
const getNS = (_) => globalThis[_];
|
|
5
5
|
exports.getNS = getNS;
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if ((0, exports.getNS)(namespaceName)) {
|
|
13
|
-
setNS();
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
script.addEventListener('load', setNS);
|
|
17
|
-
return () => {
|
|
18
|
-
script.removeEventListener('load', setNS);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
6
|
+
const initializeExternalNS = (namespaceName, url) => {
|
|
7
|
+
const script = document.getElementById(url);
|
|
8
|
+
if (script) {
|
|
9
|
+
const ns = (0, exports.getNS)(namespaceName);
|
|
10
|
+
if (ns) {
|
|
11
|
+
return Promise.resolve(ns);
|
|
21
12
|
}
|
|
22
13
|
else {
|
|
14
|
+
return new Promise((resolve) => {
|
|
15
|
+
script.addEventListener('load', () => {
|
|
16
|
+
resolve((0, exports.getNS)(namespaceName));
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
23
|
const newScript = document.createElement('script');
|
|
24
24
|
newScript.src = url;
|
|
25
25
|
newScript.async = true;
|
|
26
26
|
newScript.id = url;
|
|
27
|
-
newScript.addEventListener('load',
|
|
27
|
+
newScript.addEventListener('load', () => {
|
|
28
|
+
resolve((0, exports.getNS)(namespaceName));
|
|
29
|
+
});
|
|
30
|
+
newScript.addEventListener('error', (error) => {
|
|
31
|
+
reject(error);
|
|
32
|
+
});
|
|
28
33
|
document.head.appendChild(newScript);
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.initializeExternalNS = initializeExternalNS;
|
|
38
|
+
function useExternalNS(namespaceName, url, unmountNS = true) {
|
|
39
|
+
const [externalNS, setExternalNS] = (0, hooks_1.useState)(undefined);
|
|
40
|
+
(0, hooks_1.useEffect)(() => {
|
|
41
|
+
let isMounted = true;
|
|
42
|
+
(0, exports.initializeExternalNS)(namespaceName, url)
|
|
43
|
+
.then((ns) => {
|
|
44
|
+
if (isMounted) {
|
|
45
|
+
setExternalNS(ns);
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
.catch((error) => {
|
|
49
|
+
console.error(`Failed to initialize external namespace: ${error}`);
|
|
50
|
+
});
|
|
51
|
+
return () => {
|
|
52
|
+
isMounted = false;
|
|
53
|
+
if (unmountNS) {
|
|
54
|
+
const script = document.getElementById(url);
|
|
55
|
+
if (script) {
|
|
56
|
+
document.head.removeChild(script);
|
|
57
|
+
}
|
|
31
58
|
setExternalNS(undefined);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}, [namespaceName, url]);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}, [namespaceName, url, unmountNS]);
|
|
36
62
|
return externalNS;
|
|
37
63
|
}
|
|
38
64
|
exports.useExternalNS = useExternalNS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExternalNS.js","sourceRoot":"","sources":["../../src/hooks/useExternalNS.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"useExternalNS.js","sourceRoot":"","sources":["../../src/hooks/useExternalNS.ts"],"names":[],"mappings":";;AAAA,uDAAkE;AAE3D,MAAM,KAAK,GAAG,CAAK,CAAS,EAA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C,CAAC;KACJ;AACH,CAAC,CAAC;AAhCW,QAAA,oBAAoB,wBAgC/B;AAEF,SAAgB,aAAa,CAC3B,aAAqB,EACrB,GAAW,EACX,SAAS,GAAG,IAAI;IAEhB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAiB,SAAS,CAAC,CAAC;IAExE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,IAAI,CAAC;QAErB,IAAA,4BAAoB,EAAK,aAAa,EAAE,GAAG,CAAC;aACzC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE;YACX,IAAI,SAAS,EAAE;gBACb,aAAa,CAAC,EAAE,CAAC,CAAC;aACnB;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,4CAA4C,KAAK,EAAE,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;QAEL,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,KAAK,CAAC;YAElB,IAAI,SAAS,EAAE;gBACb,MAAM,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;gBAC5C,IAAI,MAAM,EAAE;oBACV,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;iBACnC;gBAED,aAAa,CAAC,SAAS,CAAC,CAAC;aAC1B;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;IAEpC,OAAO,UAAU,CAAC;AACpB,CAAC;AAnCD,sCAmCC"}
|
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
2
2
|
exports.useNavigateHandler = void 0;
|
|
3
3
|
const hooks_1 = require("@redneckz/uni-jsx/lib/hooks");
|
|
4
4
|
const useEventListener_1 = require("@redneckz/uni-jsx/lib/hooks/useEventListener");
|
|
5
|
+
const useChatBot_1 = require("../components/Header/useChatBot");
|
|
5
6
|
const ProjectSettings_1 = require("../ProjectSettings");
|
|
6
7
|
const adjustSessionQuery_1 = require("../utils/adjustSessionQuery");
|
|
7
8
|
const getSessionQuery_1 = require("../utils/getSessionQuery");
|
|
@@ -12,21 +13,27 @@ exports.useNavigateHandler = (0, handlerDecorator_1.handlerDecorator)(() => {
|
|
|
12
13
|
(0, hooks_1.useEffect)(() => {
|
|
13
14
|
(0, getSessionQuery_1.getSessionQuery)(); //? Call first time for save query in sessionStorage
|
|
14
15
|
}, []);
|
|
15
|
-
(0,
|
|
16
|
+
const loadBot = (0, useChatBot_1.useChatBot)(ProjectSettings_1.projectSettings.CHAT_BOT);
|
|
17
|
+
const reachGoalYM = (targetName) => {
|
|
18
|
+
const [ymID] = ProjectSettings_1.projectSettings.YANDEX_METRIKA_ID?.split(',').reverse() ?? [];
|
|
19
|
+
if ([ymID, targetName, globalThis.ym].every(Boolean)) {
|
|
20
|
+
globalThis.ym(ymID, 'reachGoal', targetName);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
(0, useEventListener_1.useEventListener)(globalThis, 'click', navigationHandler({ loadBot, reachGoalYM }));
|
|
16
24
|
});
|
|
17
|
-
const navigationHandler = (ev) => {
|
|
25
|
+
const navigationHandler = (methods) => (ev) => {
|
|
18
26
|
const element = getAnchorElement(ev.target);
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
if ([ymID, targetName, globalThis.ym].every(Boolean)) {
|
|
22
|
-
globalThis.ym(ymID, 'reachGoal', targetName);
|
|
27
|
+
for (const key in element?.dataset) {
|
|
28
|
+
getScenario(key)?.(element, methods);
|
|
23
29
|
}
|
|
24
30
|
if ((0, url_1.isURL)(element?.href) && !element?.href?.startsWith(globalThis.location?.origin)) {
|
|
25
31
|
ev.preventDefault();
|
|
26
32
|
ev.stopPropagation();
|
|
27
33
|
const url = (0, adjustSessionQuery_1.adjustSessionQuery)(element?.href) || element?.href;
|
|
28
34
|
if (url) {
|
|
29
|
-
|
|
35
|
+
const transition = getTransition(element?.target);
|
|
36
|
+
transition?.(url);
|
|
30
37
|
}
|
|
31
38
|
}
|
|
32
39
|
};
|
|
@@ -37,7 +44,7 @@ const getAnchorElement = (target) => {
|
|
|
37
44
|
}
|
|
38
45
|
return _target;
|
|
39
46
|
};
|
|
40
|
-
const
|
|
47
|
+
const getTransition = (0, tableFunc_1.tableFunc)([
|
|
41
48
|
[(_) => _ === '_blank', (url) => globalThis.open(url, '_blank')],
|
|
42
49
|
[(_) => _ === '_parent', (url) => globalThis.parent && (globalThis.parent.location.href = url)],
|
|
43
50
|
[
|
|
@@ -48,4 +55,8 @@ const goTransition = (0, tableFunc_1.tableFunc)([
|
|
|
48
55
|
],
|
|
49
56
|
[() => true, (url) => globalThis.location && (globalThis.location.href = url)],
|
|
50
57
|
]);
|
|
58
|
+
const getScenario = (0, tableFunc_1.tableFunc)([
|
|
59
|
+
[(_) => _ === 'ymtarget', (target, methods) => methods?.reachGoalYM(target?.dataset?.ymtarget)],
|
|
60
|
+
[(_) => _ === 'chatbot', (target, methods) => methods?.loadBot({ target })],
|
|
61
|
+
]);
|
|
51
62
|
//# sourceMappingURL=useNavigateHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigateHandler.js","sourceRoot":"","sources":["../../src/hooks/useNavigateHandler.ts"],"names":[],"mappings":";;AAAA,uDAAwD;AACxD,mFAAgF;
|
|
1
|
+
{"version":3,"file":"useNavigateHandler.js","sourceRoot":"","sources":["../../src/hooks/useNavigateHandler.ts"],"names":[],"mappings":";;AAAA,uDAAwD;AACxD,mFAAgF;AAChF,gEAA6D;AAE7D,wDAAqD;AAErD,oEAAiE;AACjE,8DAA2D;AAC3D,kDAA+C;AAC/C,sCAAqC;AACrC,yDAAsD;AAKzC,QAAA,kBAAkB,GAAG,IAAA,mCAAgB,EAAC,GAAG,EAAE;IACtD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAA,iCAA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MAAM,WAAW,GAAG,IAAA,qBAAS,EAAoE;IAC/F,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,UAAU,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC/F,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;CAC5E,CAAC,CAAC"}
|
|
@@ -13,6 +13,8 @@ export declare type Target = '' | '_self' | '_blank' | '_parent' | '_top';
|
|
|
13
13
|
export declare type DataAttributes = {
|
|
14
14
|
/** @title Имя цели для Яндекс Метрики */
|
|
15
15
|
ymTarget?: string;
|
|
16
|
+
/** @title Открыть чат бот */
|
|
17
|
+
chatbot?: boolean;
|
|
16
18
|
};
|
|
17
19
|
export interface LinkCommonProps {
|
|
18
20
|
/** @title URL (href) */
|
|
@@ -5,7 +5,7 @@ const ProjectSettings_1 = require("../../ProjectSettings");
|
|
|
5
5
|
const YMAPS_NAMESPACE = 'ymaps';
|
|
6
6
|
const useYandexMaps = () => {
|
|
7
7
|
const url = `https://api-maps.yandex.ru/2.1/?apikey=${ProjectSettings_1.projectSettings.YANDEX_MAP_API_KEY || ''}&lang=ru_RU`;
|
|
8
|
-
return (0, useExternalNS_1.useExternalNS)(YMAPS_NAMESPACE, url);
|
|
8
|
+
return (0, useExternalNS_1.useExternalNS)(YMAPS_NAMESPACE, url, false);
|
|
9
9
|
};
|
|
10
10
|
exports.useYandexMaps = useYandexMaps;
|
|
11
11
|
//# sourceMappingURL=useYandexMaps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useYandexMaps.js","sourceRoot":"","sources":["../../../src/ui-kit/YandexMap/useYandexMaps.ts"],"names":[],"mappings":";;AACA,6DAA0D;AAC1D,2DAAwD;AAExD,MAAM,eAAe,GAAG,OAAO,CAAC;AAEzB,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,GAAG,GAAG,0CACV,iCAAe,CAAC,kBAAkB,IAAI,EACxC,aAAa,CAAC;IAEd,OAAO,IAAA,6BAAa,EAAe,eAAe,EAAE,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"useYandexMaps.js","sourceRoot":"","sources":["../../../src/ui-kit/YandexMap/useYandexMaps.ts"],"names":[],"mappings":";;AACA,6DAA0D;AAC1D,2DAAwD;AAExD,MAAM,eAAe,GAAG,OAAO,CAAC;AAEzB,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,GAAG,GAAG,0CACV,iCAAe,CAAC,kBAAkB,IAAI,EACxC,aAAa,CAAC;IAEd,OAAO,IAAA,6BAAa,EAAe,eAAe,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAClE,CAAC,CAAC;AANW,QAAA,aAAa,iBAMxB"}
|