@useinsider/guido 3.20.1-beta.24b6c72 → 3.20.1-beta.2c8da49

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 (66) hide show
  1. package/dist/composables/useActionsApi.js +80 -63
  2. package/dist/composables/useGuidoStateBridge.js +3 -3
  3. package/dist/composables/useLegacyStrategyConversion.js +16 -16
  4. package/dist/composables/useStripo.js +11 -10
  5. package/dist/extensions/Blocks/Items/block.js +43 -42
  6. package/dist/extensions/Blocks/Recommendation/block.js +33 -29
  7. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +78 -83
  8. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +1 -2
  9. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +2 -12
  10. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +104 -86
  11. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +348 -263
  12. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +48 -50
  13. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +16 -21
  14. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +44 -40
  15. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +14 -19
  16. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +104 -102
  17. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +18 -23
  18. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +312 -286
  19. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +24 -20
  20. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +6 -7
  21. package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +8 -8
  22. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +113 -151
  23. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +219 -205
  24. package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +28 -0
  25. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +1 -1
  26. package/dist/extensions/Blocks/Recommendation/utils/currencySettings.js +25 -0
  27. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +111 -40
  28. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +31 -35
  29. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +271 -192
  30. package/dist/package.json.js +1 -1
  31. package/dist/src/composables/useActionsApi.d.ts +5 -1
  32. package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +1 -0
  33. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +8 -0
  34. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +40 -0
  35. package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +1 -0
  36. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
  37. package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +1 -0
  38. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +11 -0
  39. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -6
  40. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +7 -0
  41. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +2 -0
  42. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +5 -5
  43. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +21 -12
  44. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +6 -3
  45. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +6 -5
  46. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -3
  47. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +21 -9
  48. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +19 -13
  49. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +7 -0
  50. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +7 -0
  51. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +7 -0
  52. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +7 -0
  53. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +7 -0
  54. package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +10 -8
  55. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +9 -5
  56. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +7 -0
  57. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +8 -1
  58. package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +17 -0
  59. package/dist/src/extensions/Blocks/Recommendation/utils/currencySettings.d.ts +6 -0
  60. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +18 -11
  61. package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +1 -0
  62. package/dist/src/extensions/Blocks/controlFactories.d.ts +22 -0
  63. package/dist/src/stores/editor.d.ts +3 -1
  64. package/dist/static/styles/components/button.css.js +5 -0
  65. package/dist/stores/editor.js +5 -0
  66. package/package.json +4 -4
@@ -0,0 +1,28 @@
1
+ import { useRecommendationExtensionStore as l } from "../store/recommendation.js";
2
+ import { registerPendingConfigFlush as d, commitBlockChangeOutsidePanel as g, writeBlockConfigOutsidePanel as h } from "./nodeConfigWriter.js";
3
+ async function S(e, { pickUpdates: s, description: r, fetch: f = !0 }) {
4
+ const t = l(), i = t.blockStates[e];
5
+ if (!i)
6
+ return !1;
7
+ const { configVersion: a, adoptedSizeVersion: u } = i, c = s(i.recommendationConfigs);
8
+ if (f) {
9
+ const m = d(
10
+ () => {
11
+ var n;
12
+ return ((n = t.blockStates[e]) == null ? void 0 : n.configVersion) === a && h(e, c, r) === "applied";
13
+ }
14
+ );
15
+ try {
16
+ await t.fetchRecommendationProductsForBlock(e);
17
+ } catch (n) {
18
+ console.error("[recommendation] product refetch outside the panel failed", n);
19
+ } finally {
20
+ m();
21
+ }
22
+ }
23
+ const o = t.blockStates[e];
24
+ return o ? o.configVersion !== a || o.adoptedSizeVersion !== u ? S(e, { pickUpdates: s, description: r }) : g(e, c, o.recommendationProducts, r) : !1;
25
+ }
26
+ export {
27
+ S as refreshBlockOutsidePanel
28
+ };
@@ -1,6 +1,6 @@
1
1
  import { extractWrapperTags as A } from "../../../../utils/preserveTextStyles.js";
2
2
  import { RecommendationBlockId as c } from "../constants/blockIds.js";
3
- import { DESKTOP_CONTAINER_SELECTOR as b, ATTR_PRODUCT_NAME as k, ATTR_PRODUCT_PRICE as y, ATTR_PRODUCT_OLD_PRICE as p, ATTR_PRODUCT_OMNIBUS_PRICE as R, ATTR_PRODUCT_OMNIBUS_DISCOUNT as _, ATTR_PRODUCT_BUTTON as x, ATTR_PRODUCT_IMAGE as q, ATTR_PRODUCT_ATTR as v } from "../constants/selectors.js";
3
+ import { ATTR_PRODUCT_NAME as k, ATTR_PRODUCT_PRICE as y, ATTR_PRODUCT_OLD_PRICE as p, ATTR_PRODUCT_OMNIBUS_PRICE as R, ATTR_PRODUCT_OMNIBUS_DISCOUNT as _, ATTR_PRODUCT_BUTTON as x, ATTR_PRODUCT_IMAGE as q, DESKTOP_CONTAINER_SELECTOR as b, ATTR_PRODUCT_ATTR as v } from "../constants/selectors.js";
4
4
  import { CSS_CLASS_TEXT_TRIM as B } from "../controls/shared/textTrimCssRules.js";
5
5
  import { toCustomCompositionKey as U } from "../templates/utils.js";
6
6
  import { resolveRowVisibilityKeys as N, isMergedInlinePriceRow as C } from "./compositionKeys.js";
@@ -0,0 +1,25 @@
1
+ function o(a) {
2
+ return {
3
+ name: a.code,
4
+ value: a.code,
5
+ symbol: a.symbol,
6
+ alignment: a.alignment === "before" ? "0" : "1",
7
+ decimalCount: a.decimalCount.toString(),
8
+ decimalSeparator: a.decimalSeparator,
9
+ thousandSeparator: a.thousandSeparator
10
+ };
11
+ }
12
+ function e(a) {
13
+ return {
14
+ code: a.value,
15
+ symbol: a.symbol,
16
+ alignment: a.alignment === "0" ? "before" : "after",
17
+ decimalCount: Number(a.decimalCount),
18
+ decimalSeparator: a.decimalSeparator,
19
+ thousandSeparator: a.thousandSeparator
20
+ };
21
+ }
22
+ export {
23
+ e as toCurrencyConfig,
24
+ o as toCurrencySettings
25
+ };
@@ -1,53 +1,124 @@
1
- import { ModificationDescription as s } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { RECOMMENDATION_ID_ATTR as a } from "../constants/selectors.js";
3
- import { isPartnerManagedBlock as C, updateProductContentInPlace as p, regenerateProductRowsWithStyles as y } from "../controls/main/utils.js";
4
- import { RecommendationConfigService as m } from "../services/configService.js";
5
- import { useRecommendationExtensionStore as N } from "../store/recommendation.js";
6
- let n = null;
7
- function B(e) {
8
- n = e;
9
- }
10
- function S(e, t) {
11
- const o = N(), i = o.currentRecommendationId;
12
- if (i === e || !o.blockStates[e]) {
13
- t();
1
+ import { ModificationDescription as g } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { RECOMMENDATION_ID_ATTR as m } from "../constants/selectors.js";
3
+ import { setCurrencyAttributes as h, isPartnerManagedBlock as p, updateProductContentInPlace as O, regenerateProductRowsWithStyles as N } from "../controls/main/utils.js";
4
+ import { RecommendationConfigService as u } from "../services/configService.js";
5
+ import { useRecommendationExtensionStore as S } from "../store/recommendation.js";
6
+ const D = "Update recommendation filters", E = [
7
+ ["strategyId", () => "Updated recommendation strategy"],
8
+ ["strategy", (e) => `Changed algorithm to ${e.strategy}`],
9
+ ["productIds", () => "Updated product IDs"],
10
+ ["size", (e) => `Changed product count to ${e.size}`],
11
+ ["language", (e) => `Changed language to ${e.language}`],
12
+ ["shuffleProducts", (e) => `${e.shuffleProducts ? "Enabled" : "Disabled"} product shuffle`],
13
+ ["currency", (e) => {
14
+ var n;
15
+ return `Changed currency to ${(n = e.currency) == null ? void 0 : n.code}`;
16
+ }],
17
+ ["filters", () => D]
18
+ ];
19
+ let i = null;
20
+ const a = /* @__PURE__ */ new Set();
21
+ function _(e) {
22
+ i = e;
23
+ }
24
+ function w(e) {
25
+ return a.add(e), () => {
26
+ a.delete(e);
27
+ };
28
+ }
29
+ function A() {
30
+ let e = 0;
31
+ return [...a].forEach((n) => {
32
+ try {
33
+ n() && (e += 1);
34
+ } catch (t) {
35
+ console.error("[recommendation] pending config flush failed", t);
36
+ }
37
+ }), e;
38
+ }
39
+ function C(e) {
40
+ const n = i == null ? void 0 : i.getDocumentRootHtmlNode();
41
+ return !n || !("querySelector" in n) ? null : n.querySelector(`[${m}="${e}"]`) ?? null;
42
+ }
43
+ function d(e) {
44
+ return JSON.stringify(e, (n, t) => t && typeof t == "object" && !Array.isArray(t) ? Object.fromEntries(Object.entries(t).sort(([r], [o]) => r.localeCompare(o))) : t);
45
+ }
46
+ function l(e, n, t) {
47
+ return t in n && d(e[t]) !== d(n[t]);
48
+ }
49
+ function I(e, n) {
50
+ const t = u.getConfig(e);
51
+ return Object.keys(n).some((r) => l(t, n, r));
52
+ }
53
+ function P(e, n) {
54
+ const t = E.find(([r]) => l(e, n, r));
55
+ return t ? t[1](n) : null;
56
+ }
57
+ function y(e, n, t) {
58
+ u.stageConfig(e, n, t), t.currency && l(u.getConfig(n), t, "currency") && h({ currentNode: n, documentModifier: e, currency: t.currency, stageOnly: !0 });
59
+ }
60
+ function k(e, n, t) {
61
+ const r = C(e);
62
+ if (!i || !r)
63
+ return "missing";
64
+ const o = P(u.getConfig(r), n);
65
+ if (o === null)
66
+ return "unchanged";
67
+ const c = i.getDocumentModifier();
68
+ return y(c, r, n), c.apply(new g(t ?? o)), "applied";
69
+ }
70
+ function R(e, n) {
71
+ const t = S(), r = t.currentRecommendationId;
72
+ if (r === e || !t.blockStates[e]) {
73
+ n();
14
74
  return;
15
75
  }
16
- o.setCurrentBlock(e);
76
+ t.setCurrentBlock(e);
17
77
  try {
18
- t();
78
+ n();
19
79
  } finally {
20
- o.$patch({ currentRecommendationId: i });
80
+ t.$patch({ currentRecommendationId: r });
21
81
  }
22
82
  }
23
- function P(e) {
24
- const t = n == null ? void 0 : n.getDocumentRootHtmlNode();
25
- return !t || !("querySelectorAll" in t) ? [] : t.querySelectorAll(`[${a}="${e}"]`).map((o) => m.getConfig(o));
83
+ function F(e) {
84
+ const n = i == null ? void 0 : i.getDocumentRootHtmlNode();
85
+ return !n || !("querySelectorAll" in n) ? [] : n.querySelectorAll(`[${m}="${e}"]`).map((t) => u.getConfig(t));
26
86
  }
27
- function $(e, t, o, i) {
28
- const f = n == null ? void 0 : n.getDocumentRootHtmlNode();
29
- if (!n || !f || !("querySelector" in f))
30
- return !1;
31
- const r = f.querySelector(`[${a}="${e}"]`);
32
- if (!r)
87
+ function j(e, n, t, r) {
88
+ const o = C(e);
89
+ if (!i || !o)
33
90
  return !1;
34
- const c = n.getDocumentModifier(), d = m.getConfig(r), g = Object.keys(t).some((l) => JSON.stringify(d[l]) !== JSON.stringify(t[l]));
35
- if (m.stageConfig(c, r, t), C(r))
36
- return c.apply(new s(i)), !0;
37
- let u = !1;
38
- return S(e, () => {
39
- p({
40
- currentNode: r,
91
+ const c = i.getDocumentModifier(), s = I(o, n);
92
+ if (y(c, o, n), p(o))
93
+ return s && c.apply(new g(r)), !0;
94
+ let f = !1;
95
+ return R(e, () => {
96
+ O({
97
+ currentNode: o,
41
98
  documentModifier: c,
42
- products: o,
43
- onApplied: () => {
44
- u = !0;
99
+ products: t,
100
+ stageOnly: !0,
101
+ configOverrides: n,
102
+ onChanged: () => {
103
+ f = !0;
45
104
  }
46
- }) || (u = y({ currentNode: r, documentModifier: c, products: o }));
47
- }), !u && g && c.apply(new s(i)), !0;
105
+ }) || (f = N({
106
+ currentNode: o,
107
+ documentModifier: c,
108
+ products: t,
109
+ stageOnly: !0,
110
+ configOverrides: n
111
+ }));
112
+ }), (s || f) && c.apply(new g(r)), !0;
48
113
  }
49
114
  export {
50
- $ as commitBlockChangeOutsidePanel,
51
- P as readBlockNodeConfigs,
52
- B as registerNodeConfigWriter
115
+ D as UPDATE_FILTERS_DESCRIPTION,
116
+ j as commitBlockChangeOutsidePanel,
117
+ P as describeConfigChange,
118
+ A as flushPendingNodeConfigWrites,
119
+ F as readBlockNodeConfigs,
120
+ _ as registerNodeConfigWriter,
121
+ w as registerPendingConfigFlush,
122
+ y as stageConfigChange,
123
+ k as writeBlockConfigOutsidePanel
53
124
  };
@@ -1,47 +1,43 @@
1
1
  import { useRecommendationExtensionStore as g } from "../store/recommendation.js";
2
- import { toBlockUrlConfig as m } from "./blockUrlConfig.js";
3
- import { commitBlockChangeOutsidePanel as d, readBlockNodeConfigs as y } from "./nodeConfigWriter.js";
4
- function l(t, o) {
5
- const r = JSON.stringify(m(o));
6
- return y(t).find((e) => JSON.stringify(m(e)) !== r) ?? o;
2
+ import { refreshBlockOutsidePanel as y } from "./blockRefresh.js";
3
+ import { toBlockUrlConfig as a } from "./blockUrlConfig.js";
4
+ import { commitBlockChangeOutsidePanel as l, readBlockNodeConfigs as S } from "./nodeConfigWriter.js";
5
+ function d(e, t) {
6
+ const r = JSON.stringify(a(t));
7
+ return S(e).find((o) => JSON.stringify(a(o)) !== r) ?? t;
7
8
  }
8
- async function C(t, o, r) {
9
- const e = g(), c = [t, o];
10
- (/* @__PURE__ */ new Map([[t, l(t, r)], [o, r]])).forEach((n, s) => {
11
- var a;
12
- (!!n.strategyId || s === o) && ((a = e.blockStates[s]) == null ? void 0 : a.recommendationConfigs.strategyId) !== n.strategyId && e.seedBlockUrlConfig(s, m(n));
13
- }), e.resetArrivedBlock(o), await Promise.all(c.map(async (n) => {
14
- if (!await e.refreshStrategyBlock(n))
9
+ async function p(e, t, r) {
10
+ const o = g(), s = [e, t];
11
+ (/* @__PURE__ */ new Map([[e, d(e, r)], [t, r]])).forEach((n, i) => {
12
+ var m;
13
+ (!!n.strategyId || i === t) && ((m = o.blockStates[i]) == null ? void 0 : m.recommendationConfigs.strategyId) !== n.strategyId && o.seedBlockUrlConfig(i, a(n));
14
+ }), o.resetArrivedBlock(t), await Promise.all(s.map(async (n) => {
15
+ if (!await o.refreshStrategyBlock(n))
15
16
  return;
16
- const { recommendationConfigs: s, recommendationProducts: i } = e.blockStates[n];
17
- d(
17
+ const { recommendationConfigs: i, recommendationProducts: f } = o.blockStates[n];
18
+ l(
18
19
  n,
19
- { size: s.size },
20
- i,
20
+ { size: i.size },
21
+ f,
21
22
  "Refresh duplicated recommendation strategy"
22
23
  );
23
24
  }));
24
25
  }
25
- async function B(t, o) {
26
- const r = g(), e = r.blockStates[t];
27
- if (!e)
26
+ async function k(e, t) {
27
+ if (!g().blockStates[e])
28
28
  return !1;
29
- const { strategyId: c, strategy: f, size: n, nodeConfigVersion: s } = e.recommendationConfigs;
30
- if (r.currentRecommendationId === t)
31
- try {
32
- await r.fetchRecommendationProducts();
33
- } catch (a) {
34
- console.error("[recommendation] product refetch after a strategy change failed", a);
35
- }
36
- const i = d(
37
- t,
38
- { strategyId: c, strategy: f, size: n, configVersion: s },
39
- e.recommendationProducts,
40
- o
41
- );
42
- return i || console.error("[recommendation] strategy change did not reach a node", { blockId: t }), i;
29
+ const r = await y(e, {
30
+ pickUpdates: ({ strategyId: o, strategy: s, size: c, nodeConfigVersion: n }) => ({
31
+ strategyId: o,
32
+ strategy: s,
33
+ size: c,
34
+ configVersion: n
35
+ }),
36
+ description: t
37
+ });
38
+ return r || console.error("[recommendation] strategy change did not reach a node", { blockId: e }), r;
43
39
  }
44
40
  export {
45
- B as commitStrategyChange,
46
- C as refreshDuplicatedStrategyBlocks
41
+ k as commitStrategyChange,
42
+ p as refreshDuplicatedStrategyBlocks
47
43
  };