@redneckz/wildless-cms-uni-blocks 0.14.1057 → 0.14.1058
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/bin/migration-scripts/0.14.1058.js +21 -0
- package/bundle/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +11 -11
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/model/LinkProps.d.ts +0 -2
- package/bundle/ui-kit/LinkButton/LinkButtonContent.d.ts +4 -0
- package/dist/model/LinkProps.d.ts +0 -2
- package/dist/ui-kit/LinkButton/LinkButton.js +9 -9
- package/dist/ui-kit/LinkButton/LinkButton.js.map +1 -1
- package/dist/ui-kit/LinkButton/LinkButtonContent.d.ts +4 -0
- package/dist/ui-kit/UserSurveyDialog/useUserSurveyDialog.js +1 -1
- package/dist/ui-kit/UserSurveyDialog/useUserSurveyDialog.js.map +1 -1
- package/lib/model/LinkProps.d.ts +0 -2
- package/lib/ui-kit/LinkButton/LinkButton.js +9 -9
- package/lib/ui-kit/LinkButton/LinkButton.js.map +1 -1
- package/lib/ui-kit/LinkButton/LinkButtonContent.d.ts +4 -0
- package/lib/ui-kit/UserSurveyDialog/useUserSurveyDialog.js +1 -1
- package/lib/ui-kit/UserSurveyDialog/useUserSurveyDialog.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +11 -11
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/model/LinkProps.d.ts +0 -2
- package/mobile/bundle/ui-kit/LinkButton/LinkButtonContent.d.ts +4 -0
- package/mobile/dist/model/LinkProps.d.ts +0 -2
- package/mobile/dist/ui-kit/LinkButton/LinkButton.js +9 -9
- package/mobile/dist/ui-kit/LinkButton/LinkButton.js.map +1 -1
- package/mobile/dist/ui-kit/LinkButton/LinkButtonContent.d.ts +4 -0
- package/mobile/dist/ui-kit/UserSurveyDialog/useUserSurveyDialog.js +1 -1
- package/mobile/dist/ui-kit/UserSurveyDialog/useUserSurveyDialog.js.map +1 -1
- package/mobile/lib/model/LinkProps.d.ts +0 -2
- package/mobile/lib/ui-kit/LinkButton/LinkButton.js +9 -9
- package/mobile/lib/ui-kit/LinkButton/LinkButton.js.map +1 -1
- package/mobile/lib/ui-kit/LinkButton/LinkButtonContent.d.ts +4 -0
- package/mobile/lib/ui-kit/UserSurveyDialog/useUserSurveyDialog.js +1 -1
- package/mobile/lib/ui-kit/UserSurveyDialog/useUserSurveyDialog.js.map +1 -1
- package/mobile/src/model/LinkProps.ts +0 -2
- package/mobile/src/ui-kit/LinkButton/LinkButton.tsx +11 -10
- package/mobile/src/ui-kit/LinkButton/LinkButtonContent.ts +4 -0
- package/mobile/src/ui-kit/UserSurveyDialog/useUserSurveyDialog.ts +1 -1
- package/package.json +1 -1
- package/src/components/ButtonsBlock/ButtonsBlock.fixture.tsx +2 -1
- package/src/model/LinkProps.ts +0 -2
- package/src/ui-kit/LinkButton/LinkButton.tsx +11 -10
- package/src/ui-kit/LinkButton/LinkButtonContent.ts +4 -0
- package/src/ui-kit/UserSurveyDialog/useUserSurveyDialog.ts +1 -1
|
@@ -14,8 +14,6 @@ export declare type Target = '' | '_self' | '_blank' | '_parent' | '_top';
|
|
|
14
14
|
export declare type HrefProps = {
|
|
15
15
|
/** @title URL (href) */
|
|
16
16
|
href?: string;
|
|
17
|
-
/** @title Дополнительные ссылки для A/B-тестирования */
|
|
18
|
-
additionalHrefs?: string[];
|
|
19
17
|
};
|
|
20
18
|
export declare type LinkCommonProps = HrefProps & {
|
|
21
19
|
/** @default "" */
|
|
@@ -6,6 +6,10 @@ export interface ButtonCommonContent extends LinkProps {
|
|
|
6
6
|
version?: LinkButtonVersion;
|
|
7
7
|
/** @title Метод */
|
|
8
8
|
method?: 'LINK' | 'POST';
|
|
9
|
+
/** @title Дополнительная ссылка для A/B-тестирования */
|
|
10
|
+
additionalHref?: string;
|
|
11
|
+
/** @title Вероятность перехода по дополнительной ссылке в % */
|
|
12
|
+
chance?: 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100;
|
|
9
13
|
}
|
|
10
14
|
/** @deprecated */
|
|
11
15
|
/**
|
|
@@ -14,8 +14,6 @@ export declare type Target = '' | '_self' | '_blank' | '_parent' | '_top';
|
|
|
14
14
|
export declare type HrefProps = {
|
|
15
15
|
/** @title URL (href) */
|
|
16
16
|
href?: string;
|
|
17
|
-
/** @title Дополнительные ссылки для A/B-тестирования */
|
|
18
|
-
additionalHrefs?: string[];
|
|
19
17
|
};
|
|
20
18
|
export declare type LinkCommonProps = HrefProps & {
|
|
21
19
|
/** @default "" */
|
|
@@ -11,15 +11,15 @@ const getDisabledButtonClasses_1 = require("./getDisabledButtonClasses");
|
|
|
11
11
|
const getRegularButtonClasses_1 = require("./getRegularButtonClasses");
|
|
12
12
|
const useFormSubmit_1 = require("./useFormSubmit");
|
|
13
13
|
/** @deprecated */
|
|
14
|
-
exports.LinkButton = (0, uni_jsx_1.JSX)(({ disabled, children, method = 'LINK', href, id,
|
|
14
|
+
exports.LinkButton = (0, uni_jsx_1.JSX)(({ disabled, children, method = 'LINK', href, id, additionalHref, chance, ...rest }) => {
|
|
15
15
|
const [currentLink, setCurrentLink] = (0, hooks_1.useState)();
|
|
16
16
|
const handleFormSubmit = (0, useFormSubmit_1.useFormSubmit)({ method, href });
|
|
17
17
|
const linksStore = (0, useLocalStore_1.useLocalStore)();
|
|
18
18
|
(0, hooks_1.useEffect)(() => {
|
|
19
|
-
|
|
19
|
+
additionalHref && saveLinksToStore({ linksStore, href, id, additionalHref, chance });
|
|
20
20
|
const adjustedHref = (linksStore.links || []).find((store) => store.id === id)?.lastLink;
|
|
21
21
|
setCurrentLink(adjustedHref ?? href);
|
|
22
|
-
}, [
|
|
22
|
+
}, [additionalHref, href]);
|
|
23
23
|
const link = (0, useLink_1.useLink)();
|
|
24
24
|
const adjustedProps = link({ onClick: handleFormSubmit, href: currentLink, ...rest });
|
|
25
25
|
const buttonInner = children ?? (0, jsx_runtime_1.jsx)(ButtonInner_1.ButtonInner, { ...adjustedProps });
|
|
@@ -27,22 +27,22 @@ exports.LinkButton = (0, uni_jsx_1.JSX)(({ disabled, children, method = 'LINK',
|
|
|
27
27
|
});
|
|
28
28
|
const RegularButton = (0, uni_jsx_1.JSX)(({ className = '', href, rel, target, ariaLabel, version, rounded, onClick, type, data, children, text, }) => ((0, jsx_runtime_1.jsx)("a", { className: (0, getRegularButtonClasses_1.getRegularButtonClasses)({ className, version, rounded }), href: href, rel: rel, target: target, "aria-label": ariaLabel || `Ссылка на ${text}`, role: href ? 'link' : 'button', onClick: onClick, type: type, ...(0, dataAttributes_1.getAspectsAttributes)(data), children: children })));
|
|
29
29
|
const DisabledButton = (0, uni_jsx_1.JSX)(({ className, ariaLabel, version, rounded, children }) => ((0, jsx_runtime_1.jsx)("button", { type: "button", "aria-disabled": "true", "aria-label": ariaLabel, tabIndex: -1, className: (0, getDisabledButtonClasses_1.getDisabledButtonClasses)({ className, rounded, version }), children: children })));
|
|
30
|
-
const getRandomHref = (href = '',
|
|
31
|
-
const
|
|
32
|
-
return
|
|
30
|
+
const getRandomHref = (href = '', additionalHref = '', chance = 50) => {
|
|
31
|
+
const randomNumber = Math.random() * 100;
|
|
32
|
+
return randomNumber < chance ? additionalHref : href;
|
|
33
33
|
};
|
|
34
34
|
// Отсчитываем 7 длей с текущей даты
|
|
35
35
|
const getTimeAfter7days = () => Date.now() + 7 * 24 * 60 * 60 * 1000;
|
|
36
36
|
// Сохраняем или заменяем рандомную ссылку в localStorage
|
|
37
|
-
const saveLinksToStore = ({ linksStore, id, href,
|
|
37
|
+
const saveLinksToStore = ({ linksStore, id, href, additionalHref, chance }) => {
|
|
38
38
|
const buttonLinkStore = (linksStore.links || []).find((store) => store.id === id);
|
|
39
39
|
// Если хранилища вообще нет
|
|
40
40
|
if (!linksStore.links) {
|
|
41
41
|
linksStore.links = [];
|
|
42
42
|
}
|
|
43
|
-
if ((!buttonLinkStore || buttonLinkStore.nextDueAt <= Date.now()) &&
|
|
43
|
+
if ((!buttonLinkStore || buttonLinkStore.nextDueAt <= Date.now()) && additionalHref) {
|
|
44
44
|
// Получаем рандомную ссылку
|
|
45
|
-
const randomHref = getRandomHref(href,
|
|
45
|
+
const randomHref = getRandomHref(href, additionalHref, chance);
|
|
46
46
|
// При наличии ссылки для этой кнопки в хранилище удаляем этот элемент из массива ссылок
|
|
47
47
|
const updatedLinks = linksStore.links?.filter((item) => item.id !== id);
|
|
48
48
|
// Добавляем новый элемент
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkButton.js","sourceRoot":"","sources":["../../../src/ui-kit/LinkButton/LinkButton.tsx"],"names":[],"mappings":";;;AAAA,+CAAwC;AACxC,uDAAkE;AAClE,6EAA0E;AAC1E,iDAA8C;AAC9C,+DAAkE;AAClE,+CAA4C;AAC5C,yEAAsE;AACtE,uEAAoE;AAGpE,mDAAgD;
|
|
1
|
+
{"version":3,"file":"LinkButton.js","sourceRoot":"","sources":["../../../src/ui-kit/LinkButton/LinkButton.tsx"],"names":[],"mappings":";;;AAAA,+CAAwC;AACxC,uDAAkE;AAClE,6EAA0E;AAC1E,iDAA8C;AAC9C,+DAAkE;AAClE,+CAA4C;AAC5C,yEAAsE;AACtE,uEAAoE;AAGpE,mDAAgD;AAUhD,kBAAkB;AACL,QAAA,UAAU,GAAG,IAAA,aAAG,EAC3B,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE;IACrF,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,GAAU,CAAC;IACzD,MAAM,gBAAgB,GAAG,IAAA,6BAAa,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,MAAM,UAAU,GAAG,IAAA,6BAAa,GAAkB,CAAC;IAEnD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,cAAc,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E,KAAK,EAAE,CAAC,CAAC;IAElF,4BAA4B;IAC5B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;QACrB,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC;KACvB;IAED,IAAI,CAAC,CAAC,eAAe,IAAI,eAAe,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,cAAc,EAAE;QACnF,4BAA4B;QAC5B,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;QAE/D,wFAAwF;QACxF,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAExE,0BAA0B;QAC1B,YAAY,CAAC,IAAI,CAAC;YAChB,EAAE,EAAE,EAAE,IAAI,EAAE;YACZ,QAAQ,EAAE,UAAU;YACpB,SAAS,EAAE,iBAAiB,EAAE;SAC/B,CAAC,CAAC;QACH,gCAAgC;QAChC,UAAU,CAAC,KAAK,GAAG,YAAY,CAAC;KACjC;AACH,CAAC,CAAC"}
|
|
@@ -6,6 +6,10 @@ export interface ButtonCommonContent extends LinkProps {
|
|
|
6
6
|
version?: LinkButtonVersion;
|
|
7
7
|
/** @title Метод */
|
|
8
8
|
method?: 'LINK' | 'POST';
|
|
9
|
+
/** @title Дополнительная ссылка для A/B-тестирования */
|
|
10
|
+
additionalHref?: string;
|
|
11
|
+
/** @title Вероятность перехода по дополнительной ссылке в % */
|
|
12
|
+
chance?: 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100;
|
|
9
13
|
}
|
|
10
14
|
/** @deprecated */
|
|
11
15
|
/**
|
|
@@ -18,7 +18,7 @@ const useUserSurveyDialog = (withoutTimer = false) => {
|
|
|
18
18
|
? Date.now() - Number.parseInt(sessionStore.surveyTimerStart)
|
|
19
19
|
: 0;
|
|
20
20
|
const isShowSurvey = !isSurveySkipped &&
|
|
21
|
-
!isOtherLanguagePortal &&
|
|
21
|
+
!isOtherLanguagePortal() &&
|
|
22
22
|
(!userSurveyStore.userSurvey || userSurveyStore.userSurvey?.nextDueAt <= Date.now());
|
|
23
23
|
const handleSkipSurvey = (0, hooks_1.useCallback)(() => {
|
|
24
24
|
sessionStore.isSurveySkipped = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUserSurveyDialog.js","sourceRoot":"","sources":["../../../src/ui-kit/UserSurveyDialog/useUserSurveyDialog.ts"],"names":[],"mappings":";;AAAA,uDAAqE;AACrE,6EAA0E;AAC1E,iFAA8E;AAC9E,2CAAwC;AACxC,0DAAuD;AACvD,yDAAsD;AAGtD,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAQ5B,4CAA4C;AACrC,MAAM,mBAAmB,GAAG,CAAC,YAAY,GAAG,KAAK,EAAE,EAAE;IAC1D,MAAM,gBAAgB,GAAG,IAAA,qBAAS,EAAC,mCAAgB,CAAC,CAAC;IACrD,MAAM,eAAe,GAAG,IAAA,6BAAa,GAAwB,CAAC;IAC9D,MAAM,YAAY,GAAG,IAAA,iCAAe,GAAoB,CAAC;IACzD,MAAM,WAAW,GAAG,YAAY,CAAC,aAAa,CAAC;IAC/C,MAAM,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC;IACrD,MAAM,WAAW,GAAG,YAAY,CAAC,gBAAgB;QAC/C,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,gBAAgB,CAAC;QAC7D,CAAC,CAAC,CAAC,CAAC;IACN,MAAM,YAAY,GAChB,CAAC,eAAe;QAChB,CAAC,qBAAqB;
|
|
1
|
+
{"version":3,"file":"useUserSurveyDialog.js","sourceRoot":"","sources":["../../../src/ui-kit/UserSurveyDialog/useUserSurveyDialog.ts"],"names":[],"mappings":";;AAAA,uDAAqE;AACrE,6EAA0E;AAC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B,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC9C,IAAI,YAAY,EAAE;YAChB,WAAW,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC;YACzC,oBAAoB,CAAC,IAAI,CAAC,CAAC;SAC5B;IACH,CAAC,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;IAEhC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,0GAA0G;QAC1G,IAAI,CAAC,YAAY,IAAI,YAAY,EAAE;YACjC,uDAAuD;YACvD,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE;gBAClC,YAAY,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;aACvD;YACD,wDAAwD;YACxD,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC;YACtE,YAAY,CAAC,aAAa,GAAG,OAAO,CAAC;YAErC,OAAO,GAAG,EAAE;gBACV,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtB,YAAY,CAAC,aAAa,GAAG,IAAI,CAAC;YACpC,CAAC,CAAC;SACH;QAED,OAAO,WAAI,CAAC;IACd,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,sBAAsB,CAAC;AAChC,CAAC,CAAC;AAxDW,QAAA,mBAAmB,uBAwD9B;AAEF,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACjC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAE9C,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACnD,CAAC,CAAC"}
|
|
@@ -14,8 +14,6 @@ export declare type Target = '' | '_self' | '_blank' | '_parent' | '_top';
|
|
|
14
14
|
export declare type HrefProps = {
|
|
15
15
|
/** @title URL (href) */
|
|
16
16
|
href?: string;
|
|
17
|
-
/** @title Дополнительные ссылки для A/B-тестирования */
|
|
18
|
-
additionalHrefs?: string[];
|
|
19
17
|
};
|
|
20
18
|
export declare type LinkCommonProps = HrefProps & {
|
|
21
19
|
/** @default "" */
|
|
@@ -9,15 +9,15 @@ import { getDisabledButtonClasses } from './getDisabledButtonClasses.js';
|
|
|
9
9
|
import { getRegularButtonClasses } from './getRegularButtonClasses.js';
|
|
10
10
|
import { useFormSubmit } from './useFormSubmit.js';
|
|
11
11
|
/** @deprecated */
|
|
12
|
-
export const LinkButton = JSX(({ disabled, children, method = 'LINK', href, id,
|
|
12
|
+
export const LinkButton = JSX(({ disabled, children, method = 'LINK', href, id, additionalHref, chance, ...rest }) => {
|
|
13
13
|
const [currentLink, setCurrentLink] = useState();
|
|
14
14
|
const handleFormSubmit = useFormSubmit({ method, href });
|
|
15
15
|
const linksStore = useLocalStore();
|
|
16
16
|
useEffect(() => {
|
|
17
|
-
|
|
17
|
+
additionalHref && saveLinksToStore({ linksStore, href, id, additionalHref, chance });
|
|
18
18
|
const adjustedHref = (linksStore.links || []).find((store) => store.id === id)?.lastLink;
|
|
19
19
|
setCurrentLink(adjustedHref ?? href);
|
|
20
|
-
}, [
|
|
20
|
+
}, [additionalHref, href]);
|
|
21
21
|
const link = useLink();
|
|
22
22
|
const adjustedProps = link({ onClick: handleFormSubmit, href: currentLink, ...rest });
|
|
23
23
|
const buttonInner = children ?? _jsx(ButtonInner, { ...adjustedProps });
|
|
@@ -25,22 +25,22 @@ export const LinkButton = JSX(({ disabled, children, method = 'LINK', href, id,
|
|
|
25
25
|
});
|
|
26
26
|
const RegularButton = JSX(({ className = '', href, rel, target, ariaLabel, version, rounded, onClick, type, data, children, text, }) => (_jsx("a", { className: getRegularButtonClasses({ className, version, rounded }), href: href, rel: rel, target: target, "aria-label": ariaLabel || `Ссылка на ${text}`, role: href ? 'link' : 'button', onClick: onClick, type: type, ...getAspectsAttributes(data), children: children })));
|
|
27
27
|
const DisabledButton = JSX(({ className, ariaLabel, version, rounded, children }) => (_jsx("button", { type: "button", "aria-disabled": "true", "aria-label": ariaLabel, tabIndex: -1, className: getDisabledButtonClasses({ className, rounded, version }), children: children })));
|
|
28
|
-
const getRandomHref = (href = '',
|
|
29
|
-
const
|
|
30
|
-
return
|
|
28
|
+
const getRandomHref = (href = '', additionalHref = '', chance = 50) => {
|
|
29
|
+
const randomNumber = Math.random() * 100;
|
|
30
|
+
return randomNumber < chance ? additionalHref : href;
|
|
31
31
|
};
|
|
32
32
|
// Отсчитываем 7 длей с текущей даты
|
|
33
33
|
const getTimeAfter7days = () => Date.now() + 7 * 24 * 60 * 60 * 1000;
|
|
34
34
|
// Сохраняем или заменяем рандомную ссылку в localStorage
|
|
35
|
-
const saveLinksToStore = ({ linksStore, id, href,
|
|
35
|
+
const saveLinksToStore = ({ linksStore, id, href, additionalHref, chance }) => {
|
|
36
36
|
const buttonLinkStore = (linksStore.links || []).find((store) => store.id === id);
|
|
37
37
|
// Если хранилища вообще нет
|
|
38
38
|
if (!linksStore.links) {
|
|
39
39
|
linksStore.links = [];
|
|
40
40
|
}
|
|
41
|
-
if ((!buttonLinkStore || buttonLinkStore.nextDueAt <= Date.now()) &&
|
|
41
|
+
if ((!buttonLinkStore || buttonLinkStore.nextDueAt <= Date.now()) && additionalHref) {
|
|
42
42
|
// Получаем рандомную ссылку
|
|
43
|
-
const randomHref = getRandomHref(href,
|
|
43
|
+
const randomHref = getRandomHref(href, additionalHref, chance);
|
|
44
44
|
// При наличии ссылки для этой кнопки в хранилище удаляем этот элемент из массива ссылок
|
|
45
45
|
const updatedLinks = linksStore.links?.filter((item) => item.id !== id);
|
|
46
46
|
// Добавляем новый элемент
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkButton.js","sourceRoot":"","sources":["../../../src/ui-kit/LinkButton/LinkButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM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eAAe,GAAG,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAElF,4BAA4B;IAC5B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;QACrB,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC;KACvB;IAED,IAAI,CAAC,CAAC,eAAe,IAAI,eAAe,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,cAAc,EAAE;QACnF,4BAA4B;QAC5B,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;QAE/D,wFAAwF;QACxF,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAExE,0BAA0B;QAC1B,YAAY,CAAC,IAAI,CAAC;YAChB,EAAE,EAAE,EAAE,IAAI,EAAE;YACZ,QAAQ,EAAE,UAAU;YACpB,SAAS,EAAE,iBAAiB,EAAE;SAC/B,CAAC,CAAC;QACH,gCAAgC;QAChC,UAAU,CAAC,KAAK,GAAG,YAAY,CAAC;KACjC;AACH,CAAC,CAAC"}
|
|
@@ -6,6 +6,10 @@ export interface ButtonCommonContent extends LinkProps {
|
|
|
6
6
|
version?: LinkButtonVersion;
|
|
7
7
|
/** @title Метод */
|
|
8
8
|
method?: 'LINK' | 'POST';
|
|
9
|
+
/** @title Дополнительная ссылка для A/B-тестирования */
|
|
10
|
+
additionalHref?: string;
|
|
11
|
+
/** @title Вероятность перехода по дополнительной ссылке в % */
|
|
12
|
+
chance?: 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100;
|
|
9
13
|
}
|
|
10
14
|
/** @deprecated */
|
|
11
15
|
/**
|
|
@@ -16,7 +16,7 @@ export const useUserSurveyDialog = (withoutTimer = false) => {
|
|
|
16
16
|
? Date.now() - Number.parseInt(sessionStore.surveyTimerStart)
|
|
17
17
|
: 0;
|
|
18
18
|
const isShowSurvey = !isSurveySkipped &&
|
|
19
|
-
!isOtherLanguagePortal &&
|
|
19
|
+
!isOtherLanguagePortal() &&
|
|
20
20
|
(!userSurveyStore.userSurvey || userSurveyStore.userSurvey?.nextDueAt <= Date.now());
|
|
21
21
|
const handleSkipSurvey = useCallback(() => {
|
|
22
22
|
sessionStore.isSurveySkipped = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUserSurveyDialog.js","sourceRoot":"","sources":["../../../src/ui-kit/UserSurveyDialog/useUserSurveyDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAQ5B,4CAA4C;AAC5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,YAAY,GAAG,KAAK,EAAE,EAAE;IAC1D,MAAM,gBAAgB,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACrD,MAAM,eAAe,GAAG,aAAa,EAAwB,CAAC;IAC9D,MAAM,YAAY,GAAG,eAAe,EAAoB,CAAC;IACzD,MAAM,WAAW,GAAG,YAAY,CAAC,aAAa,CAAC;IAC/C,MAAM,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC;IACrD,MAAM,WAAW,GAAG,YAAY,CAAC,gBAAgB;QAC/C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,CAAC;SACH;QAED,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,sBAAsB,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACjC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAE9C,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACnD,CAAC,CAAC"}
|
|
@@ -16,8 +16,6 @@ export type Target = '' | '_self' | '_blank' | '_parent' | '_top';
|
|
|
16
16
|
export type HrefProps = {
|
|
17
17
|
/** @title URL (href) */
|
|
18
18
|
href?: string;
|
|
19
|
-
/** @title Дополнительные ссылки для A/B-тестирования */
|
|
20
|
-
additionalHrefs?: string[];
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
export type LinkCommonProps = HrefProps & {
|
|
@@ -14,23 +14,24 @@ type SaveLinksProps = {
|
|
|
14
14
|
linksStore: LinkStoreSlice;
|
|
15
15
|
id?: string;
|
|
16
16
|
href?: string;
|
|
17
|
-
|
|
17
|
+
additionalHref?: string;
|
|
18
|
+
chance: LinkButtonProps['chance'];
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
/** @deprecated */
|
|
21
22
|
export const LinkButton = JSX<LinkButtonProps>(
|
|
22
|
-
({ disabled, children, method = 'LINK', href, id,
|
|
23
|
+
({ disabled, children, method = 'LINK', href, id, additionalHref, chance, ...rest }) => {
|
|
23
24
|
const [currentLink, setCurrentLink] = useState<string>();
|
|
24
25
|
const handleFormSubmit = useFormSubmit({ method, href });
|
|
25
26
|
const linksStore = useLocalStore<LinkStoreSlice>();
|
|
26
27
|
|
|
27
28
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
+
additionalHref && saveLinksToStore({ linksStore, href, id, additionalHref, chance });
|
|
29
30
|
|
|
30
31
|
const adjustedHref = (linksStore.links || []).find((store) => store.id === id)?.lastLink;
|
|
31
32
|
|
|
32
33
|
setCurrentLink(adjustedHref ?? href);
|
|
33
|
-
}, [
|
|
34
|
+
}, [additionalHref, href]);
|
|
34
35
|
|
|
35
36
|
const link = useLink();
|
|
36
37
|
const adjustedProps = link({ onClick: handleFormSubmit, href: currentLink, ...rest });
|
|
@@ -90,17 +91,17 @@ const DisabledButton = JSX<LinkButtonProps>(
|
|
|
90
91
|
),
|
|
91
92
|
);
|
|
92
93
|
|
|
93
|
-
const getRandomHref = (href = '',
|
|
94
|
-
const
|
|
94
|
+
const getRandomHref = (href = '', additionalHref = '', chance = 50) => {
|
|
95
|
+
const randomNumber = Math.random() * 100;
|
|
95
96
|
|
|
96
|
-
return
|
|
97
|
+
return randomNumber < chance ? additionalHref : href;
|
|
97
98
|
};
|
|
98
99
|
|
|
99
100
|
// Отсчитываем 7 длей с текущей даты
|
|
100
101
|
const getTimeAfter7days = () => Date.now() + 7 * 24 * 60 * 60 * 1000;
|
|
101
102
|
|
|
102
103
|
// Сохраняем или заменяем рандомную ссылку в localStorage
|
|
103
|
-
const saveLinksToStore = ({ linksStore, id, href,
|
|
104
|
+
const saveLinksToStore = ({ linksStore, id, href, additionalHref, chance }: SaveLinksProps) => {
|
|
104
105
|
const buttonLinkStore = (linksStore.links || []).find((store) => store.id === id);
|
|
105
106
|
|
|
106
107
|
// Если хранилища вообще нет
|
|
@@ -108,9 +109,9 @@ const saveLinksToStore = ({ linksStore, id, href, additionalHrefs }: SaveLinksPr
|
|
|
108
109
|
linksStore.links = [];
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
if ((!buttonLinkStore || buttonLinkStore.nextDueAt <= Date.now()) &&
|
|
112
|
+
if ((!buttonLinkStore || buttonLinkStore.nextDueAt <= Date.now()) && additionalHref) {
|
|
112
113
|
// Получаем рандомную ссылку
|
|
113
|
-
const randomHref = getRandomHref(href,
|
|
114
|
+
const randomHref = getRandomHref(href, additionalHref, chance);
|
|
114
115
|
|
|
115
116
|
// При наличии ссылки для этой кнопки в хранилище удаляем этот элемент из массива ссылок
|
|
116
117
|
const updatedLinks = linksStore.links?.filter((item) => item.id !== id);
|
|
@@ -7,6 +7,10 @@ export interface ButtonCommonContent extends LinkProps {
|
|
|
7
7
|
version?: LinkButtonVersion;
|
|
8
8
|
/** @title Метод */
|
|
9
9
|
method?: 'LINK' | 'POST';
|
|
10
|
+
/** @title Дополнительная ссылка для A/B-тестирования */
|
|
11
|
+
additionalHref?: string;
|
|
12
|
+
/** @title Вероятность перехода по дополнительной ссылке в % */
|
|
13
|
+
chance?: 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100;
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
/** @deprecated */
|
|
@@ -26,7 +26,7 @@ export const useUserSurveyDialog = (withoutTimer = false) => {
|
|
|
26
26
|
: 0;
|
|
27
27
|
const isShowSurvey =
|
|
28
28
|
!isSurveySkipped &&
|
|
29
|
-
!isOtherLanguagePortal &&
|
|
29
|
+
!isOtherLanguagePortal() &&
|
|
30
30
|
(!userSurveyStore.userSurvey || userSurveyStore.userSurvey?.nextDueAt <= Date.now());
|
|
31
31
|
|
|
32
32
|
const handleSkipSurvey = useCallback(() => {
|
package/package.json
CHANGED
|
@@ -21,7 +21,8 @@ const buttons: LinkButtonContent[] = [
|
|
|
21
21
|
const buttonsForABTesting: LinkButtonContent[] = [
|
|
22
22
|
{
|
|
23
23
|
href: '/premium-cards',
|
|
24
|
-
|
|
24
|
+
additionalHref: '/debit-cards',
|
|
25
|
+
chance: 10,
|
|
25
26
|
text: 'Оформить',
|
|
26
27
|
target: '_blank',
|
|
27
28
|
version: 'primary',
|
package/src/model/LinkProps.ts
CHANGED
|
@@ -16,8 +16,6 @@ export type Target = '' | '_self' | '_blank' | '_parent' | '_top';
|
|
|
16
16
|
export type HrefProps = {
|
|
17
17
|
/** @title URL (href) */
|
|
18
18
|
href?: string;
|
|
19
|
-
/** @title Дополнительные ссылки для A/B-тестирования */
|
|
20
|
-
additionalHrefs?: string[];
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
export type LinkCommonProps = HrefProps & {
|
|
@@ -14,23 +14,24 @@ type SaveLinksProps = {
|
|
|
14
14
|
linksStore: LinkStoreSlice;
|
|
15
15
|
id?: string;
|
|
16
16
|
href?: string;
|
|
17
|
-
|
|
17
|
+
additionalHref?: string;
|
|
18
|
+
chance: LinkButtonProps['chance'];
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
/** @deprecated */
|
|
21
22
|
export const LinkButton = JSX<LinkButtonProps>(
|
|
22
|
-
({ disabled, children, method = 'LINK', href, id,
|
|
23
|
+
({ disabled, children, method = 'LINK', href, id, additionalHref, chance, ...rest }) => {
|
|
23
24
|
const [currentLink, setCurrentLink] = useState<string>();
|
|
24
25
|
const handleFormSubmit = useFormSubmit({ method, href });
|
|
25
26
|
const linksStore = useLocalStore<LinkStoreSlice>();
|
|
26
27
|
|
|
27
28
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
+
additionalHref && saveLinksToStore({ linksStore, href, id, additionalHref, chance });
|
|
29
30
|
|
|
30
31
|
const adjustedHref = (linksStore.links || []).find((store) => store.id === id)?.lastLink;
|
|
31
32
|
|
|
32
33
|
setCurrentLink(adjustedHref ?? href);
|
|
33
|
-
}, [
|
|
34
|
+
}, [additionalHref, href]);
|
|
34
35
|
|
|
35
36
|
const link = useLink();
|
|
36
37
|
const adjustedProps = link({ onClick: handleFormSubmit, href: currentLink, ...rest });
|
|
@@ -90,17 +91,17 @@ const DisabledButton = JSX<LinkButtonProps>(
|
|
|
90
91
|
),
|
|
91
92
|
);
|
|
92
93
|
|
|
93
|
-
const getRandomHref = (href = '',
|
|
94
|
-
const
|
|
94
|
+
const getRandomHref = (href = '', additionalHref = '', chance = 50) => {
|
|
95
|
+
const randomNumber = Math.random() * 100;
|
|
95
96
|
|
|
96
|
-
return
|
|
97
|
+
return randomNumber < chance ? additionalHref : href;
|
|
97
98
|
};
|
|
98
99
|
|
|
99
100
|
// Отсчитываем 7 длей с текущей даты
|
|
100
101
|
const getTimeAfter7days = () => Date.now() + 7 * 24 * 60 * 60 * 1000;
|
|
101
102
|
|
|
102
103
|
// Сохраняем или заменяем рандомную ссылку в localStorage
|
|
103
|
-
const saveLinksToStore = ({ linksStore, id, href,
|
|
104
|
+
const saveLinksToStore = ({ linksStore, id, href, additionalHref, chance }: SaveLinksProps) => {
|
|
104
105
|
const buttonLinkStore = (linksStore.links || []).find((store) => store.id === id);
|
|
105
106
|
|
|
106
107
|
// Если хранилища вообще нет
|
|
@@ -108,9 +109,9 @@ const saveLinksToStore = ({ linksStore, id, href, additionalHrefs }: SaveLinksPr
|
|
|
108
109
|
linksStore.links = [];
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
if ((!buttonLinkStore || buttonLinkStore.nextDueAt <= Date.now()) &&
|
|
112
|
+
if ((!buttonLinkStore || buttonLinkStore.nextDueAt <= Date.now()) && additionalHref) {
|
|
112
113
|
// Получаем рандомную ссылку
|
|
113
|
-
const randomHref = getRandomHref(href,
|
|
114
|
+
const randomHref = getRandomHref(href, additionalHref, chance);
|
|
114
115
|
|
|
115
116
|
// При наличии ссылки для этой кнопки в хранилище удаляем этот элемент из массива ссылок
|
|
116
117
|
const updatedLinks = linksStore.links?.filter((item) => item.id !== id);
|
|
@@ -7,6 +7,10 @@ export interface ButtonCommonContent extends LinkProps {
|
|
|
7
7
|
version?: LinkButtonVersion;
|
|
8
8
|
/** @title Метод */
|
|
9
9
|
method?: 'LINK' | 'POST';
|
|
10
|
+
/** @title Дополнительная ссылка для A/B-тестирования */
|
|
11
|
+
additionalHref?: string;
|
|
12
|
+
/** @title Вероятность перехода по дополнительной ссылке в % */
|
|
13
|
+
chance?: 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100;
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
/** @deprecated */
|
|
@@ -26,7 +26,7 @@ export const useUserSurveyDialog = (withoutTimer = false) => {
|
|
|
26
26
|
: 0;
|
|
27
27
|
const isShowSurvey =
|
|
28
28
|
!isSurveySkipped &&
|
|
29
|
-
!isOtherLanguagePortal &&
|
|
29
|
+
!isOtherLanguagePortal() &&
|
|
30
30
|
(!userSurveyStore.userSurvey || userSurveyStore.userSurvey?.nextDueAt <= Date.now());
|
|
31
31
|
|
|
32
32
|
const handleSkipSurvey = useCallback(() => {
|