ublo-lib 1.19.22 → 1.19.24

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.
Files changed (24) hide show
  1. package/es/common/components/editable-map/icons/index.js +2 -1
  2. package/es/common/components/editable-map/icons/viarmonia.js +45 -0
  3. package/es/common/components/plausible/hooks/use-plausible.d.ts +12 -0
  4. package/es/common/components/plausible/hooks/use-plausible.d.ts.map +1 -0
  5. package/es/common/components/plausible/hooks/use-plausible.js +19 -23
  6. package/es/common/components/plausible/index.d.ts +8 -0
  7. package/es/common/components/plausible/index.d.ts.map +1 -0
  8. package/es/common/components/plausible/index.js +1 -1
  9. package/es/common/components/plausible/plausible.d.ts +7 -0
  10. package/es/common/components/plausible/plausible.d.ts.map +1 -0
  11. package/es/common/components/plausible/plausible.js +14 -23
  12. package/es/common/components/plausible/services/callback.d.ts +24 -0
  13. package/es/common/components/plausible/services/callback.d.ts.map +1 -0
  14. package/es/common/components/plausible/services/callback.js +109 -146
  15. package/es/common/components/plausible/services/load.d.ts +2 -0
  16. package/es/common/components/plausible/services/load.d.ts.map +1 -0
  17. package/es/common/components/plausible/services/load.js +7 -6
  18. package/es/common/components/plausible/services/send-goal.d.ts +7 -0
  19. package/es/common/components/plausible/services/send-goal.d.ts.map +1 -0
  20. package/es/common/components/plausible/services/send-goal.js +4 -7
  21. package/es/common/components/scroll-spy.d.ts +14 -0
  22. package/es/common/components/scroll-spy.d.ts.map +1 -0
  23. package/es/common/components/scroll-spy.js +43 -57
  24. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
1
  export * as esf from "./esf";
2
2
  export * as lavovelo from "./lavovelo";
3
3
  export * as sataHuez from "./sata-huez";
4
- export * as sedevVars from "./sedev-vars";
4
+ export * as sedevVars from "./sedev-vars";
5
+ export * as viarmonia from "./viarmonia";
@@ -0,0 +1,45 @@
1
+ import * as React from "react";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { jsxs as _jsxs } from "react/jsx-runtime";
4
+ export function Location(props) {
5
+ return _jsxs(Icon, {
6
+ ...props,
7
+ children: [_jsx("path", {
8
+ d: "M2 12a10 10 0 1 1 20 0 10 10 0 0 1-20 0Z"
9
+ }), _jsx("path", {
10
+ fillRule: "evenodd",
11
+ clipRule: "evenodd",
12
+ d: "M0 12a12 12 0 1 1 24 0 12 12 0 0 1-24 0ZM12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Z",
13
+ fill: "#fff"
14
+ })]
15
+ }, "1");
16
+ }
17
+ export function Pebbles(props) {
18
+ return _jsxs(Icon, {
19
+ ...props,
20
+ children: [_jsx("path", {
21
+ d: "M2 12a10 10 0 1 1 20 0 10 10 0 0 1-20 0Z"
22
+ }), _jsx("path", {
23
+ fillRule: "evenodd",
24
+ clipRule: "evenodd",
25
+ d: "M0 12a12 12 0 1 1 24 0 12 12 0 0 1-24 0ZM12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Z",
26
+ fill: "#fff"
27
+ }), _jsx("path", {
28
+ d: "M19.84 17.57h-3.6c.3-.13.6-.24.9-.38.64-.26 1.2-.7 1.6-1.25.25-.38.36-.79.28-1.24-.1-.5-.38-.94-.79-1.24-.6-.5-1.3-.86-2.06-1.07-.33-.1-.67-.17-1.01-.25.28-.1.55-.18.81-.29a3.1 3.1 0 0 0 1.05-.68c.26-.27.41-.58.38-.97-.04-.42-.28-.72-.58-.97a4.57 4.57 0 0 0-1.85-.8c-.07-.03-.15-.03-.23-.08l.18-.07c.26-.11.5-.26.7-.45.51-.46.52-1.1.02-1.6-.23-.2-.5-.38-.8-.5-.19-.08-.4-.13-.62-.2l.14-.1c.28-.25.33-.62.12-.88-.1-.13-.24-.24-.39-.32a2.57 2.57 0 0 0-1.44-.21c-.35.03-.68.13-.96.35-.37.28-.41.7-.08 1.02.04.05.11.08.15.15l-.14.04c-.4.1-.76.26-1.09.5-.34.27-.6.59-.53 1.06.04.38.29.64.58.86.2.15.43.25.7.36l-.58.15c-.63.15-1.22.46-1.7.9-.54.53-.54 1.25 0 1.78.32.33.72.54 1.15.71.22.1.46.15.72.24-.55.1-1.05.23-1.53.42-.7.24-1.33.64-1.85 1.16a1.77 1.77 0 0 0 0 2.52c.4.42.87.72 1.4.96l.86.37H6.23c-.23 0-.23 0-.23.23 0 .2 0 .2.21.2h13.52c.27 0 .26 0 .28-.28 0-.13-.05-.15-.17-.15Zm-2.5-3.04h.1c.26 0 .22-.04.23.22v.11c0 .08-.03.1-.1.1h-.09c-.29 0-.28 0-.29-.3 0-.1.04-.15.16-.13Zm-6.32-.73a3.1 3.1 0 0 0-1.74.64c-.19.15-.34.33-.46.54-.04.08-.08.1-.15.04l-.04-.01c-.27-.14-.27-.14-.1-.4.39-.53.95-.92 1.58-1.08.26-.08.52-.13.79-.16.24-.03.24-.03.24.2v.1c.02.1-.03.12-.12.13Zm1.67-7.02c-.43.04-.82.2-1.1.55-.03.04-.06.04-.09.01l-.17-.11c-.15-.1-.15-.1-.03-.24.35-.39.84-.62 1.37-.66.07 0 .1.03.1.1v.25c0 .06-.01.08-.08.1Zm4.05 8.45c.23 0 .23 0 .23.2 0 .23 0 .23-.24.23-.23 0-.23 0-.23-.23 0-.2 0-.2.23-.2Zm-.7 1.14c-.27 0-.23.04-.23-.24-.01-.2 0-.2.23-.2s.23 0 .23.22c0 .26.03.22-.23.22Z",
29
+ fill: "#fff"
30
+ })]
31
+ }, "2");
32
+ }
33
+ function Icon({
34
+ width = 24,
35
+ height = 24,
36
+ ...props
37
+ }) {
38
+ return _jsx("svg", {
39
+ viewBox: `0 0 ${width} ${height}`,
40
+ width: width,
41
+ height: height,
42
+ ...props,
43
+ children: props.children
44
+ });
45
+ }
@@ -0,0 +1,12 @@
1
+ type Revenue = {
2
+ currency: string;
3
+ amount: number;
4
+ };
5
+ export default function useGoal(goal: string, props: Record<string, any>, revenue?: Revenue, overridenDomain?: string): void;
6
+ declare global {
7
+ interface Window {
8
+ plausible: any;
9
+ }
10
+ }
11
+ export {};
12
+ //# sourceMappingURL=use-plausible.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-plausible.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/plausible/hooks/use-plausible.ts"],"names":[],"mappings":"AAQA,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,OAAO,CAC7B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,OAAO,CAAC,EAAE,OAAO,EACjB,eAAe,CAAC,EAAE,MAAM,QAQzB;AAcD,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,MAAM;QACd,SAAS,EAAE,GAAG,CAAC;KAChB;CACF"}
@@ -2,28 +2,24 @@ import * as React from "react";
2
2
  import getConfig from "next/config";
3
3
  import load from "../services/load";
4
4
  import sendGoal from "../services/send-goal";
5
- const {
6
- publicRuntimeConfig
7
- } = getConfig();
8
- const {
9
- plausibleDomain
10
- } = publicRuntimeConfig;
11
- export default function useGoal(goal, props, overridenDomain) {
12
- const [loaded] = usePlausible(overridenDomain);
13
- React.useEffect(() => {
14
- if (!loaded || !window.plausible) return;
15
- const defaultProps = {
16
- path: document.location.pathname
17
- };
18
- sendGoal(goal, props || defaultProps);
19
- }, [goal, loaded, props]);
5
+ const { publicRuntimeConfig } = getConfig();
6
+ const { plausibleDomain } = publicRuntimeConfig;
7
+ export default function useGoal(goal, props, revenue, overridenDomain) {
8
+ const [loaded] = usePlausible(overridenDomain);
9
+ React.useEffect(() => {
10
+ if (!loaded || !window.plausible)
11
+ return;
12
+ const defaultProps = { path: document.location.pathname };
13
+ sendGoal(goal, props || defaultProps, revenue);
14
+ }, [goal, loaded, props]);
20
15
  }
21
16
  function usePlausible(overridenDomain) {
22
- const [loaded, setLoaded] = React.useState(false);
23
- React.useEffect(() => {
24
- if (!overridenDomain && !plausibleDomain) return;
25
- load();
26
- setLoaded(true);
27
- }, [overridenDomain]);
28
- return [loaded, setLoaded];
29
- }
17
+ const [loaded, setLoaded] = React.useState(false);
18
+ React.useEffect(() => {
19
+ if (!overridenDomain && !plausibleDomain)
20
+ return;
21
+ load();
22
+ setLoaded(true);
23
+ }, [overridenDomain]);
24
+ return [loaded, setLoaded];
25
+ }
@@ -0,0 +1,8 @@
1
+ import Script from "./plausible";
2
+ import * as Callback from "./services/callback";
3
+ declare const callback: typeof Callback.MseM;
4
+ export { default as load } from "./services/load";
5
+ export { default as sendGoal } from "./services/send-goal";
6
+ export { default as useGoal } from "./hooks/use-plausible";
7
+ export { callback, Script };
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/components/plausible/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAEhD,QAAA,MAAM,QAAQ,sBAAgB,CAAC;AAE/B,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC"}
@@ -4,4 +4,4 @@ const callback = Callback.MseM;
4
4
  export { default as load } from "./services/load";
5
5
  export { default as sendGoal } from "./services/send-goal";
6
6
  export { default as useGoal } from "./hooks/use-plausible";
7
- export { callback, Script };
7
+ export { callback, Script };
@@ -0,0 +1,7 @@
1
+ type Props = {
2
+ lang?: string;
3
+ source?: string;
4
+ };
5
+ export default function PlausibleScript({ lang, source, }: Props): import("react/jsx-runtime").JSX.Element | null;
6
+ export {};
7
+ //# sourceMappingURL=plausible.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plausible.d.ts","sourceRoot":"","sources":["../../../../src/common/components/plausible/plausible.tsx"],"names":[],"mappings":"AAOA,KAAK,KAAK,GAAG;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAKF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,IAAI,EACJ,MAAuB,GACxB,EAAE,KAAK,kDAeP"}
@@ -1,26 +1,17 @@
1
- import * as React from "react";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Script from "next/script";
3
3
  import getConfig from "next/config";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- const {
6
- publicRuntimeConfig
7
- } = getConfig();
8
- const {
9
- plausibleDomain
10
- } = publicRuntimeConfig;
4
+ const { publicRuntimeConfig } = getConfig();
5
+ const { plausibleDomain } = publicRuntimeConfig;
11
6
  const DEFAULT_SOURCE = "https://plausible.io/js/script.file-downloads.outbound-links.js";
12
- export default function PlausibleScript({
13
- lang,
14
- source = DEFAULT_SOURCE
15
- }) {
16
- const hasI18n = typeof plausibleDomain === "object";
17
- if (hasI18n && !lang) {
18
- console.warn("PlausibleScript: the lang props is mandatory if you want to use a specific domain for each lang");
19
- }
20
- const domain = hasI18n ? plausibleDomain[lang] : plausibleDomain;
21
- if (!domain) return null;
22
- return _jsx(Script, {
23
- "data-domain": domain,
24
- src: source
25
- });
26
- }
7
+ export default function PlausibleScript({ lang, source = DEFAULT_SOURCE, }) {
8
+ const hasI18n = typeof plausibleDomain === "object";
9
+ if (hasI18n && !lang) {
10
+ // eslint-disable-next-line no-console
11
+ console.warn("PlausibleScript: the lang props is mandatory if you want to use a specific domain for each lang");
12
+ }
13
+ const domain = hasI18n && lang ? plausibleDomain[lang] : plausibleDomain;
14
+ if (!domain)
15
+ return null;
16
+ return _jsx(Script, { "data-domain": domain, src: source });
17
+ }
@@ -0,0 +1,24 @@
1
+ type Item = {
2
+ gtmData: {
3
+ item_name: string;
4
+ item_brand: string;
5
+ item_category: string;
6
+ item_category2: string;
7
+ item_category3: string;
8
+ item_variant: string;
9
+ price: number;
10
+ quantity: number;
11
+ };
12
+ };
13
+ type Props = {
14
+ event: string;
15
+ payment_type?: string;
16
+ execcode?: string;
17
+ items?: Item[];
18
+ orderId?: string;
19
+ cartId?: string;
20
+ currency?: string;
21
+ };
22
+ export declare function MseM({ event, payment_type: paymentType, execcode, items, orderId, cartId, currency, }: Props): void;
23
+ export {};
24
+ //# sourceMappingURL=callback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/plausible/services/callback.ts"],"names":[],"mappings":"AAEA,KAAK,IAAI,GAAG;IACV,OAAO,EAAE;QACP,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAiBF,wBAAgB,IAAI,CAAC,EACnB,KAAK,EACL,YAAY,EAAE,WAAW,EACzB,QAAQ,EACR,KAAU,EACV,OAAO,EACP,MAAM,EACN,QAAgB,GACjB,EAAE,KAAK,QA8EP"}
@@ -1,158 +1,121 @@
1
1
  import sendGoal from "./send-goal";
2
+ // TODO lors de la mise en prod de la nouvelle version PeekPerformances
3
+ // rename events "MseM:" > "PeekPerformances:"
4
+ // Retirer les anciennes props :
5
+ // Name, Brand, Kind, Activity, Code, Product, cartId,
6
+ // orderId, Code, Payment type
2
7
  const EVENT_NAMES = {
3
- view_item: "MseM: View item",
4
- add_to_cart: "MseM: Add to cart",
5
- checkout: "MseM: Begin checkout",
6
- add_payment_info: "MseM: Checkout process",
7
- purchase: "MseM: Payment success",
8
- payment_failure: "MseM: Payment failure"
8
+ view_item: "MseM: View item",
9
+ add_to_cart: "MseM: Add to cart",
10
+ checkout: "MseM: Begin checkout",
11
+ add_payment_info: "MseM: Checkout process",
12
+ purchase: "MseM: Payment success",
13
+ payment_failure: "MseM: Payment failure",
9
14
  };
10
- export const MseM = ({
11
- event,
12
- payment_type,
13
- execcode,
14
- items = [],
15
- orderId,
16
- cartId
17
- }) => {
18
- const hoteId = getBusinessProvider();
19
- let name = EVENT_NAMES[event];
20
- switch (event) {
21
- case "view_item":
22
- {
23
- const formatedItems = formatPeekPerformancesItem(items);
24
- const rawData = JSON.stringify({
25
- products: formatedItems,
26
- hoteId
27
- });
28
- sendGoal(name, {
29
- Name: items[0]?.gtmData.item_name,
30
- Brand: items[0]?.gtmData.item_brand,
31
- Kind: items[0]?.gtmData.item_category,
32
- Activity: items[0]?.gtmData.item_category2,
33
- Code: items[0]?.gtmData.item_category3,
34
- Product: items[0]?.gtmData.item_variant,
35
- rawData
36
- });
37
- break;
38
- }
39
- case "add_to_cart":
40
- {
41
- const formatedItems = formatPeekPerformancesItem(items);
42
- const rawData = JSON.stringify({
43
- products: formatedItems,
44
- hoteId
45
- });
46
- sendGoal(name, {
47
- Name: items[0]?.gtmData.item_name,
48
- Brand: items[0]?.gtmData.item_brand,
49
- Kind: items[0]?.gtmData.item_category,
50
- Activity: items[0]?.gtmData.item_category2,
51
- Code: items[0]?.gtmData.item_category3,
52
- Product: items[0]?.gtmData.item_variant,
53
- rawData
54
- });
55
- break;
56
- }
57
- case "checkout":
58
- {
59
- const formatedItems = formatPeekPerformancesItem(items);
60
- const rawData = JSON.stringify({
61
- products: formatedItems,
62
- hoteId
63
- });
64
- sendGoal(name, {
65
- cartId,
66
- rawData
67
- });
68
- break;
69
- }
70
- case "add_payment_info":
71
- {
72
- const formatedItems = formatPeekPerformancesItem(items);
73
- const rawData = JSON.stringify({
74
- products: formatedItems,
75
- hoteId,
76
- paymentMethod: payment_type
77
- });
78
- sendGoal(name, {
79
- cartId,
80
- "Payment type": payment_type,
81
- rawData
82
- });
83
- break;
84
- }
85
- case "purchase":
86
- {
87
- const isFailure = execcode !== "0000";
88
- const formatedItems = formatPeekPerformancesItem(items);
89
- const attempts = getPurchaseAttempts()[cartId] || 0;
90
- const rawData = JSON.stringify({
91
- products: formatedItems,
92
- hoteId,
93
- attempts,
94
- paymentMethod: payment_type,
95
- execCode: execcode
96
- });
97
- if (isFailure) {
98
- name = EVENT_NAMES.payment_failure;
99
- sendGoal(name, {
100
- cartId,
101
- orderId,
102
- Code: execcode,
103
- rawData
104
- });
105
- setPurchaseAttempts(cartId, attempts + 1);
106
- } else {
107
- sendGoal(name, {
108
- cartId,
109
- orderId,
110
- Code: execcode,
111
- rawData
112
- });
15
+ export function MseM({ event, payment_type: paymentType, execcode, items = [], orderId, cartId, currency = "EUR", }) {
16
+ const hoteId = getBusinessProvider();
17
+ const amount = items.reduce((acc, item) => {
18
+ return acc + item.gtmData.price * item.gtmData.quantity;
19
+ }, 0);
20
+ const revenue = { currency, amount };
21
+ let name = EVENT_NAMES[event];
22
+ const firstProductProps = {
23
+ Name: items[0]?.gtmData.item_name,
24
+ Brand: items[0]?.gtmData.item_brand,
25
+ Kind: items[0]?.gtmData.item_category,
26
+ Activity: items[0]?.gtmData.item_category2,
27
+ Code: items[0]?.gtmData.item_category3,
28
+ Product: items[0]?.gtmData.item_variant,
29
+ };
30
+ switch (event) {
31
+ case "view_item": {
32
+ const formatedItems = formatPeekPerformancesItem(items);
33
+ const rawData = JSON.stringify({ products: formatedItems, hoteId });
34
+ sendGoal(name, { ...firstProductProps, rawData });
35
+ break;
113
36
  }
114
- break;
115
- }
116
- }
117
- };
37
+ case "add_to_cart": {
38
+ const formatedItems = formatPeekPerformancesItem(items);
39
+ const rawData = JSON.stringify({ products: formatedItems, hoteId });
40
+ sendGoal(name, { ...firstProductProps, rawData }, revenue);
41
+ break;
42
+ }
43
+ case "checkout": {
44
+ const formatedItems = formatPeekPerformancesItem(items);
45
+ const rawData = JSON.stringify({ products: formatedItems, hoteId });
46
+ sendGoal(name, { cartId, rawData }, revenue);
47
+ break;
48
+ }
49
+ case "add_payment_info": {
50
+ const formatedItems = formatPeekPerformancesItem(items);
51
+ const rawData = JSON.stringify({
52
+ products: formatedItems,
53
+ hoteId,
54
+ paymentMethod: paymentType,
55
+ });
56
+ sendGoal(name, { cartId, "Payment type": paymentType, rawData }, revenue);
57
+ break;
58
+ }
59
+ case "purchase": {
60
+ const isFailure = execcode !== "0000";
61
+ const formatedItems = formatPeekPerformancesItem(items);
62
+ const attempts = (cartId && getPurchaseAttempts()[cartId]) || 0;
63
+ const rawData = JSON.stringify({
64
+ products: formatedItems,
65
+ hoteId,
66
+ attempts,
67
+ paymentMethod: paymentType,
68
+ execCode: execcode,
69
+ });
70
+ if (isFailure) {
71
+ name = EVENT_NAMES.payment_failure;
72
+ sendGoal(name, { cartId, orderId, Code: execcode, rawData }, revenue);
73
+ if (cartId) {
74
+ setPurchaseAttempts(cartId, attempts + 1);
75
+ }
76
+ }
77
+ else {
78
+ sendGoal(name, { cartId, orderId, Code: execcode, rawData }, revenue);
79
+ }
80
+ break;
81
+ }
82
+ }
83
+ }
118
84
  const PURCHASE_ATTEMPTS_STORAGE_KEY = "purchase_attempts";
119
85
  function getPurchaseAttempts() {
120
- try {
121
- return JSON.parse(window.localStorage.getItem(PURCHASE_ATTEMPTS_STORAGE_KEY)) || {};
122
- } catch (e) {
123
- return {};
124
- }
86
+ try {
87
+ const storedAttempts = window.localStorage.getItem(PURCHASE_ATTEMPTS_STORAGE_KEY);
88
+ return storedAttempts !== null ? JSON.parse(storedAttempts) : {};
89
+ }
90
+ catch (e) {
91
+ return {};
92
+ }
125
93
  }
126
94
  function setPurchaseAttempts(cartId, attempts) {
127
- const purchaseAttempts = getPurchaseAttempts();
128
- window.localStorage.setItem(PURCHASE_ATTEMPTS_STORAGE_KEY, JSON.stringify({
129
- ...purchaseAttempts,
130
- [cartId]: attempts
131
- }));
95
+ const purchaseAttempts = getPurchaseAttempts();
96
+ window.localStorage.setItem(PURCHASE_ATTEMPTS_STORAGE_KEY, JSON.stringify({ ...purchaseAttempts, [cartId]: attempts }));
132
97
  }
133
98
  function formatPeekPerformancesItem(items) {
134
- if (!items || !items.length) return;
135
- return items.map(({
136
- gtmData
137
- }) => {
138
- return {
139
- category: gtmData.item_category,
140
- subCategory: gtmData.item_category2,
141
- merchant: gtmData.item_brand,
142
- price: gtmData.price
143
- };
144
- });
99
+ if (!items || !items.length)
100
+ return;
101
+ return items.map(({ gtmData }) => {
102
+ return {
103
+ category: gtmData.item_category,
104
+ subCategory: gtmData.item_category2,
105
+ merchant: gtmData.item_brand,
106
+ price: gtmData.price,
107
+ };
108
+ });
145
109
  }
146
110
  function getBusinessProvider() {
147
- const businessProvider = window.localStorage.getItem("businessProvider");
148
- if (businessProvider) {
149
- try {
150
- const {
151
- id
152
- } = JSON.parse(businessProvider);
153
- if (id !== -1) {
154
- return id;
155
- }
156
- } catch (e) {}
157
- }
158
- }
111
+ const businessProvider = window.localStorage.getItem("businessProvider");
112
+ if (businessProvider) {
113
+ try {
114
+ const { id } = JSON.parse(businessProvider);
115
+ if (id !== -1) {
116
+ return id;
117
+ }
118
+ }
119
+ catch (e) { }
120
+ }
121
+ }
@@ -0,0 +1,2 @@
1
+ export default function load(): void;
2
+ //# sourceMappingURL=load.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/plausible/services/load.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,IAAI,SAM3B"}
@@ -1,6 +1,7 @@
1
- const load = () => {
2
- window.plausible = window.plausible || function () {
3
- (window.plausible.q = window.plausible.q || []).push(arguments);
4
- };
5
- };
6
- export default load;
1
+ export default function load() {
2
+ window.plausible =
3
+ window.plausible ||
4
+ function () {
5
+ (window.plausible.q = window.plausible.q || []).push(arguments);
6
+ };
7
+ }
@@ -0,0 +1,7 @@
1
+ type Revenue = {
2
+ currency: string;
3
+ amount: number;
4
+ };
5
+ export default function sendGoal(goal: string, props: Record<string, any>, revenue?: Revenue): void;
6
+ export {};
7
+ //# sourceMappingURL=send-goal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-goal.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/plausible/services/send-goal.ts"],"names":[],"mappings":"AAEA,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,OAAO,CAAC,EAAE,OAAO,QAIlB"}
@@ -1,8 +1,5 @@
1
1
  import load from "./load";
2
- const sendGoal = (goal, props) => {
3
- load();
4
- window.plausible(goal, {
5
- props
6
- });
7
- };
8
- export default sendGoal;
2
+ export default function sendGoal(goal, props, revenue) {
3
+ load();
4
+ window.plausible(goal, { props, revenue });
5
+ }
@@ -0,0 +1,14 @@
1
+ import * as React from "react";
2
+ type Props = {
3
+ className?: string;
4
+ items: string[];
5
+ Tag?: React.ElementType;
6
+ currentClassName: string;
7
+ onUpdate?: (target: Element | HTMLElement | undefined) => void;
8
+ rootMargin?: string;
9
+ container?: HTMLElement;
10
+ children: React.ReactNode;
11
+ };
12
+ export default function ScrollSpy({ className, items, Tag, currentClassName, onUpdate, rootMargin, container, children, }: Props): import("react/jsx-runtime").JSX.Element;
13
+ export {};
14
+ //# sourceMappingURL=scroll-spy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll-spy.d.ts","sourceRoot":"","sources":["../../../src/common/components/scroll-spy.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,SAAS,EACT,KAAK,EACL,GAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,UAAuB,EACvB,SAAS,EACT,QAAQ,GACT,EAAE,KAAK,2CAmDP"}
@@ -1,60 +1,46 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import * as React from "react";
2
3
  import classNames from "classnames";
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- const ScrollSpy = ({
5
- className,
6
- items,
7
- Tag = "div",
8
- currentClassName,
9
- onUpdate,
10
- rootMargin = "-50% 0px",
11
- container,
12
- children
13
- }) => {
14
- const [current, setCurrent] = React.useState();
15
- const callback = React.useCallback(entries => {
16
- for (const entry of entries) {
17
- if (container === entry.target) {
18
- if (!entry.isIntersecting) {
19
- setCurrent(undefined);
20
- onUpdate?.(undefined);
4
+ export default function ScrollSpy({ className, items, Tag = "div", currentClassName, onUpdate, rootMargin = "-50% 0px", container, children, }) {
5
+ const [current, setCurrent] = React.useState();
6
+ const callback = React.useCallback((entries) => {
7
+ for (const entry of entries) {
8
+ if (container === entry.target) {
9
+ if (!entry.isIntersecting) {
10
+ setCurrent(undefined);
11
+ onUpdate?.(undefined);
12
+ }
13
+ }
14
+ else if (entry.isIntersecting) {
15
+ const index = items.indexOf(entry.target.id);
16
+ setCurrent(index);
17
+ onUpdate?.(entry.target);
18
+ }
21
19
  }
22
- } else if (entry.isIntersecting) {
23
- const index = items.indexOf(entry.target.id);
24
- setCurrent(index);
25
- onUpdate?.(entry.target);
26
- }
27
- }
28
- }, [container, items, onUpdate]);
29
- React.useEffect(() => {
30
- const defaultTargets = container ? [container] : [];
31
- const targets = items.length ? items.reduce((acc, item) => {
32
- const element = document.getElementById(item);
33
- return element ? [...acc, element] : acc;
34
- }, defaultTargets) : defaultTargets;
35
- const observer = new window.IntersectionObserver(callback, {
36
- rootMargin
37
- });
38
- targets.forEach(observer.observe, observer);
39
- return () => {
40
- observer.disconnect();
41
- };
42
- }, [callback, container, items, rootMargin]);
43
- return _jsx(Tag, {
44
- className: className,
45
- children: children.map(({
46
- props,
47
- ...child
48
- }, i) => {
49
- const className = classNames({
50
- [props.className]: props.className,
51
- [currentClassName]: current === i
52
- });
53
- return React.cloneElement(child, {
54
- ...props,
55
- className
56
- });
57
- })
58
- });
59
- };
60
- export default ScrollSpy;
20
+ }, [container, items, onUpdate]);
21
+ React.useEffect(() => {
22
+ const defaultTargets = container ? [container] : [];
23
+ const targets = items.length
24
+ ? items.reduce((acc, item) => {
25
+ const element = document.getElementById(item);
26
+ return element ? [...acc, element] : acc;
27
+ }, defaultTargets)
28
+ : defaultTargets;
29
+ const observer = new window.IntersectionObserver(callback, { rootMargin });
30
+ targets.forEach(observer.observe, observer);
31
+ return () => {
32
+ observer.disconnect();
33
+ };
34
+ }, [callback, container, items, rootMargin]);
35
+ return (_jsx(Tag, { className: className, children: children &&
36
+ children.map(({ props, ...child }, i) => {
37
+ const className = classNames({
38
+ [props.className]: props.className,
39
+ [currentClassName]: current === i,
40
+ });
41
+ return React.cloneElement(child, {
42
+ ...props,
43
+ className,
44
+ });
45
+ }) }));
46
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.19.22",
3
+ "version": "1.19.24",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^3.1.5",
6
6
  "leaflet": "^1.9.1",