@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
2
|
import { useEventListener } from '@redneckz/uni-jsx/lib/hooks/useEventListener';
|
|
3
|
+
import { useChatBot } from '../components/Header/useChatBot';
|
|
3
4
|
import { type Target } from '../model/LinkProps';
|
|
4
5
|
import { projectSettings } from '../ProjectSettings';
|
|
5
6
|
import { type PreventableEvent } from '../ui-kit/PreventableEvent';
|
|
@@ -10,35 +11,45 @@ import { isURL } from '../utils/url';
|
|
|
10
11
|
import { handlerDecorator } from './handlerDecorator';
|
|
11
12
|
|
|
12
13
|
export type NavigateElement = Element | null;
|
|
14
|
+
export type MethodsMap = Record<string, (params: any) => any>;
|
|
13
15
|
|
|
14
16
|
export const useNavigateHandler = handlerDecorator(() => {
|
|
15
17
|
useEffect(() => {
|
|
16
18
|
getSessionQuery(); //? Call first time for save query in sessionStorage
|
|
17
19
|
}, []);
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
+
const loadBot = useChatBot(projectSettings.CHAT_BOT);
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
-
|
|
23
|
+
const reachGoalYM = (targetName?: string) => {
|
|
24
|
+
const [ymID] = projectSettings.YANDEX_METRIKA_ID?.split(',').reverse() ?? [];
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
if ([ymID, targetName, globalThis.ym].every(Boolean)) {
|
|
27
|
+
globalThis.ym(ymID, 'reachGoal', targetName);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
+
useEventListener(globalThis, 'click', navigationHandler({ loadBot, reachGoalYM }));
|
|
32
|
+
});
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
ev.
|
|
34
|
+
const navigationHandler =
|
|
35
|
+
(methods: MethodsMap) => (ev: PreventableEvent & { target: EventTarget | null }) => {
|
|
36
|
+
const element = getAnchorElement(ev.target as NavigateElement);
|
|
35
37
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
goTransition(element?.target as Target)?.(url);
|
|
38
|
+
for (const key in element?.dataset) {
|
|
39
|
+
getScenario(key)?.(element as HTMLElement, methods);
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
|
|
42
|
+
if (isURL(element?.href) && !element?.href?.startsWith(globalThis.location?.origin)) {
|
|
43
|
+
ev.preventDefault();
|
|
44
|
+
ev.stopPropagation();
|
|
45
|
+
|
|
46
|
+
const url = adjustSessionQuery(element?.href) || element?.href;
|
|
47
|
+
if (url) {
|
|
48
|
+
const transition = getTransition(element?.target as Target);
|
|
49
|
+
transition?.(url);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
42
53
|
|
|
43
54
|
const getAnchorElement = (target: NavigateElement) => {
|
|
44
55
|
let _target = target;
|
|
@@ -49,7 +60,7 @@ const getAnchorElement = (target: NavigateElement) => {
|
|
|
49
60
|
return _target as HTMLAnchorElement | null;
|
|
50
61
|
};
|
|
51
62
|
|
|
52
|
-
const
|
|
63
|
+
const getTransition = tableFunc<Target, (url: string) => void>([
|
|
53
64
|
[(_) => _ === '_blank', (url) => globalThis.open(url, '_blank')],
|
|
54
65
|
[(_) => _ === '_parent', (url) => globalThis.parent && (globalThis.parent.location.href = url)],
|
|
55
66
|
[
|
|
@@ -60,3 +71,8 @@ const goTransition = tableFunc<Target, (url: string) => void>([
|
|
|
60
71
|
],
|
|
61
72
|
[() => true, (url) => globalThis.location && (globalThis.location.href = url)],
|
|
62
73
|
]);
|
|
74
|
+
|
|
75
|
+
const getScenario = tableFunc<string, (target: HTMLElement | null, methods: MethodsMap) => void>([
|
|
76
|
+
[(_) => _ === 'ymtarget', (target, methods) => methods?.reachGoalYM(target?.dataset?.ymtarget)],
|
|
77
|
+
[(_) => _ === 'chatbot', (target, methods) => methods?.loadBot({ target })],
|
|
78
|
+
]);
|
package/src/model/LinkProps.ts
CHANGED
|
@@ -14,6 +14,8 @@ export type Target = '' | '_self' | '_blank' | '_parent' | '_top';
|
|
|
14
14
|
export type DataAttributes = {
|
|
15
15
|
/** @title Имя цели для Яндекс Метрики */
|
|
16
16
|
ymTarget?: string;
|
|
17
|
+
/** @title Открыть чат бот */
|
|
18
|
+
chatbot?: boolean;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
export interface LinkCommonProps {
|
|
@@ -19,7 +19,7 @@ export const SelectPopup = JSX<SelectPopupProps>(
|
|
|
19
19
|
({ popupRef, options, value, query, onChange, iconVersion }) =>
|
|
20
20
|
options?.length ? (
|
|
21
21
|
<div
|
|
22
|
-
className="bg-white text-l max-h-64 overflow-y-auto overflow-x-hidden rounded-md"
|
|
22
|
+
className="bg-white text-l max-h-64 overflow-y-auto overflow-x-hidden rounded-md shadow-2xl"
|
|
23
23
|
role="list"
|
|
24
24
|
ref={popupRef}
|
|
25
25
|
>
|