@useinsider/guido 3.9.0-beta.c84fcd0 → 3.9.0-beta.dd40fcd

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.
@@ -1,24 +1,17 @@
1
1
  import { ModificationDescription as b } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { ItemInCartOptions as p, DefaultConfigValues as i, SETTINGS_ENUMS as c } from "../enums/settingsEnums.js";
2
+ import { DefaultConfigValues as i, SETTINGS_ENUMS as n, ItemInCartOptions as g } from "../enums/settingsEnums.js";
3
3
  function _() {
4
4
  return String(Date.now() + Math.floor(Math.random() * 1e3));
5
5
  }
6
- const S = (r) => r.replace(/\$/g, "$$$$");
7
- function y(r, t) {
8
- const e = p[t], n = e ? e.findIndex((u) => u.value === r) : -1;
9
- if (n >= 0)
10
- return String(n + 1);
11
- const o = typeof r == "string" ? r.match(/\((\d+)\)/) : null;
12
- return (o == null ? void 0 : o[1]) ?? "1";
13
- }
14
- function A() {
6
+ const E = (r) => r.replace(/\$/g, "$$$$");
7
+ function y() {
15
8
  return {
16
9
  initialized: !0,
17
10
  blockInstanceId: _(),
18
- source: c.ITEMS_TYPE.CART_ITEMS,
19
- type: c.ITEMS_TYPE.CART_ITEMS,
11
+ source: n.ITEMS_TYPE.CART_ITEMS,
12
+ type: n.ITEMS_TYPE.CART_ITEMS,
20
13
  itemsSelectValue: i.cartItemsSelectControlValue,
21
- orientation: c.ORIENTATION.VERTICAL,
14
+ orientation: n.ORIENTATION.VERTICAL,
22
15
  nameTrimming: i.productNameTrimmingControlValue === "1",
23
16
  priceHideDiscount: i.productPriceHideDiscountControlValue === "1",
24
17
  priceFormatted: i.productPriceFormattedControlValue === "1",
@@ -40,7 +33,7 @@ function A() {
40
33
  buttonVisible: i.productButtonVisible === "1"
41
34
  };
42
35
  }
43
- function g(r) {
36
+ function p(r) {
44
37
  if (!r)
45
38
  return null;
46
39
  const t = r.closest(".items-block-v2");
@@ -48,14 +41,14 @@ function g(r) {
48
41
  }
49
42
  function m(r) {
50
43
  return r ? {
51
- CartItems: c.ITEMS_TYPE.CART_ITEMS,
52
- BrowsedItems: c.ITEMS_TYPE.BROWSED_ITEMS,
53
- PurchasedItems: c.ITEMS_TYPE.PURCHASED_ITEMS,
44
+ CartItems: n.ITEMS_TYPE.CART_ITEMS,
45
+ BrowsedItems: n.ITEMS_TYPE.BROWSED_ITEMS,
46
+ PurchasedItems: n.ITEMS_TYPE.PURCHASED_ITEMS,
54
47
  // Also handle already correct formats
55
- CART_ITEMS: c.ITEMS_TYPE.CART_ITEMS,
56
- BROWSED_ITEMS: c.ITEMS_TYPE.BROWSED_ITEMS,
57
- PURCHASED_ITEMS: c.ITEMS_TYPE.PURCHASED_ITEMS
58
- }[r] || c.ITEMS_TYPE.CART_ITEMS : c.ITEMS_TYPE.CART_ITEMS;
48
+ CART_ITEMS: n.ITEMS_TYPE.CART_ITEMS,
49
+ BROWSED_ITEMS: n.ITEMS_TYPE.BROWSED_ITEMS,
50
+ PURCHASED_ITEMS: n.ITEMS_TYPE.PURCHASED_ITEMS
51
+ }[r] || n.ITEMS_TYPE.CART_ITEMS : n.ITEMS_TYPE.CART_ITEMS;
59
52
  }
60
53
  function f(r, t) {
61
54
  if (!r)
@@ -63,27 +56,27 @@ function f(r, t) {
63
56
  if (r.includes("{{"))
64
57
  return r;
65
58
  if (/^\d+$/.test(r)) {
66
- const e = parseInt(r) - 1, n = p[t];
67
- if (n && n[e])
68
- return n[e].value;
59
+ const e = parseInt(r) - 1, o = g[t];
60
+ if (o && o[e])
61
+ return o[e].value;
69
62
  }
70
63
  return i.cartItemsSelectControlValue;
71
64
  }
72
- function I(r) {
65
+ function C(r) {
73
66
  const t = r.querySelector("esd-config-block");
74
67
  if (!t)
75
68
  return null;
76
- const e = (a, s) => a == null ? s : a === "1" || a === "true", n = (a, s) => a || s, o = t.getAttribute("data-type"), u = m(o), d = t.getAttribute("data-cart_items_select_control_value"), l = f(d, u);
69
+ const e = (u, s) => u == null ? s : u === "1" || u === "true", o = (u, s) => u || s, c = t.getAttribute("data-type"), a = m(c), d = t.getAttribute("data-cart_items_select_control_value"), l = f(d, a);
77
70
  return {
78
71
  initialized: e(t.getAttribute("data-initialized"), !1),
79
- blockInstanceId: n(
72
+ blockInstanceId: o(
80
73
  t.getAttribute("data-block-instance-id"),
81
74
  _()
82
75
  ),
83
- source: u,
84
- type: u,
76
+ source: a,
77
+ type: a,
85
78
  itemsSelectValue: l,
86
- orientation: t.getAttribute("data-card_orientation_control_value") || c.ORIENTATION.VERTICAL,
79
+ orientation: t.getAttribute("data-card_orientation_control_value") || n.ORIENTATION.VERTICAL,
87
80
  nameTrimming: e(
88
81
  t.getAttribute("data-product_name_control_trim"),
89
82
  !0
@@ -100,11 +93,11 @@ function I(r) {
100
93
  t.getAttribute("data-product_price_control_single_price"),
101
94
  !1
102
95
  ),
103
- priceCurrencySymbol: n(
96
+ priceCurrencySymbol: o(
104
97
  t.getAttribute("data-product_price_control_currency_symbol"),
105
98
  i.productPriceCurrencySymbolControlValue
106
99
  ),
107
- priceCurrencyLocation: n(
100
+ priceCurrencyLocation: o(
108
101
  t.getAttribute("data-product_price_currency_location"),
109
102
  i.productPriceCurrencyLocationControlValue
110
103
  ),
@@ -113,15 +106,15 @@ function I(r) {
113
106
  t.getAttribute("data-product_quantity_control_enabled"),
114
107
  !0
115
108
  ),
116
- buttonLink: n(
109
+ buttonLink: o(
117
110
  t.getAttribute("data-product_button_link"),
118
111
  i.productButtonLinkControlValue
119
112
  ),
120
- imageLink: n(
113
+ imageLink: o(
121
114
  t.getAttribute("data-product_image_link"),
122
115
  i.productImageLinkControlValue
123
116
  ),
124
- buttonLabel: n(
117
+ buttonLabel: o(
125
118
  t.getAttribute("data-product_button_control_label"),
126
119
  "Buy"
127
120
  ),
@@ -156,7 +149,7 @@ function I(r) {
156
149
  )
157
150
  };
158
151
  }
159
- function C(r) {
152
+ function I(r) {
160
153
  if (typeof r.getAttribute != "function")
161
154
  return null;
162
155
  const t = r.getAttribute("esd-ext-config");
@@ -170,32 +163,31 @@ function C(r) {
170
163
  }
171
164
  return null;
172
165
  }
173
- function V(r) {
174
- const t = g(r);
166
+ function A(r) {
167
+ const t = p(r);
175
168
  if (!t)
176
169
  return null;
177
170
  const e = t.getNodeConfig();
178
171
  if (e && e.initialized)
179
172
  return e;
180
- const n = C(t);
181
- if (n)
182
- return n;
183
173
  const o = I(t);
184
- return o || null;
174
+ if (o)
175
+ return o;
176
+ const c = C(t);
177
+ return c || null;
185
178
  }
186
- function M(r, t, e, n) {
187
- const o = g(r);
188
- if (!o)
179
+ function V(r, t, e, o) {
180
+ const c = p(r);
181
+ if (!c)
189
182
  return;
190
- const d = { ...o.getNodeConfig() || {}, ...e }, l = n ?? t.getDocumentModifier();
191
- l.modifyHtml(o).setNodeConfig(d), n || l.apply(new b("Update Items block configuration"));
183
+ const d = { ...c.getNodeConfig() || {}, ...e }, l = o ?? t.getDocumentModifier();
184
+ l.modifyHtml(c).setNodeConfig(d), o || l.apply(new b("Update Items block configuration"));
192
185
  }
193
186
  export {
194
- y as deriveItemNumber,
195
- S as escapeReplacement,
187
+ E as escapeReplacement,
196
188
  _ as generateBlockInstanceId,
197
- A as getDefaultItemsBlockConfig,
198
- V as getItemsBlockConfig,
199
- g as getItemsBlockContainer,
200
- M as setItemsBlockConfig
189
+ y as getDefaultItemsBlockConfig,
190
+ A as getItemsBlockConfig,
191
+ p as getItemsBlockContainer,
192
+ V as setItemsBlockConfig
201
193
  };
@@ -1,5 +1,5 @@
1
- import { ATTR_PRODUCT_IMAGE as p, ATTR_PRODUCT_BUTTON as C, ATTR_PRODUCT_OLD_PRICE as f, ATTR_PRODUCT_PRICE as m } from "../../constants/selectors.js";
2
- import { buildSpacer as I, DEFAULT_CARD_COMPOSITION as g, buildElementRenderer as E, buildCellOptions as a, resolveInlinePriceOrder as w, DEFAULT_CARD_VISIBILITY as y } from "../utils.js";
1
+ import { ATTR_PRODUCT_IMAGE as p, ATTR_PRODUCT_BUTTON as C, ATTR_PRODUCT_OLD_PRICE as A, ATTR_PRODUCT_PRICE as m } from "../../constants/selectors.js";
2
+ import { buildSpacer as I, DEFAULT_CARD_COMPOSITION as g, buildElementRenderer as E, buildCellOptions as i, resolveInlinePriceOrder as w, DEFAULT_CARD_VISIBILITY as y } from "../utils.js";
3
3
  import { listElementRenderer as L, renderInlineListPriceRow as O } from "./elementRenderer.js";
4
4
  const S = "0 5px";
5
5
  function U(l, r, n) {
@@ -27,40 +27,40 @@ const N = `
27
27
  </td>
28
28
  </tr>
29
29
  `;
30
- function $(l, r = g, n = {}, e = {}) {
30
+ function x(l, r = g, n = {}, e = {}) {
31
31
  const {
32
32
  cellPadding: o = S,
33
33
  cardBackgroundColor: d,
34
34
  visibility: c,
35
- priceInline: i = !1
36
- } = e, u = d ? ` style="background-color: ${d};"` : "", s = E(L, r, n), P = s[p](l, a(p, e)), R = w(r), T = `
35
+ priceInline: a = !1
36
+ } = e, u = d ? ` style="table-layout: fixed; background-color: ${d};"` : ' style="table-layout: fixed;"', s = E(L, r, n), P = s[p](l, i(p, e)), R = w(r), T = `
37
37
  <td class="product-info-cell" valign="middle" style="padding: 15px;">
38
38
  <table cellpadding="0" cellspacing="0" role="presentation" width="100%" style="table-layout: fixed;">
39
39
  <tbody>
40
- ${r.filter((t) => t !== p && t !== C).filter((t) => !(i && t === R.skip)).filter((t) => s[t]).map((t) => {
41
- const b = (c == null ? void 0 : c[t]) ?? y[t] ?? !0, A = i && t === R.anchor ? O(
40
+ ${r.filter((t) => t !== p && t !== C).filter((t) => !(a && t === R.skip)).filter((t) => s[t]).map((t) => {
41
+ const b = (c == null ? void 0 : c[t]) ?? y[t] ?? !0, f = a && t === R.anchor ? O(
42
42
  l,
43
43
  R.originalFirst,
44
- a(m, e),
45
- a(f, e)
46
- ) : s[t](l, a(t, e));
47
- return U(A, t, b);
44
+ i(m, e),
45
+ i(A, e)
46
+ ) : s[t](l, i(t, e));
47
+ return U(f, t, b);
48
48
  }).join(`
49
49
  `)}
50
50
  </tbody>
51
51
  </table>
52
52
  </td>
53
- `, _ = s[C](l, a(C, e)), D = P + T + _;
53
+ `, _ = s[C](l, i(C, e)), D = P + T + _;
54
54
  return N.replace("{-{-CARD_PADDING-}-}", o).replace("{-{-WRAPPER_STYLE-}-}", u).replace("{-{-PRODUCT_CONTENT-}-}", D);
55
55
  }
56
56
  function W(l, r, n = {}, e = {}) {
57
57
  const o = I(e.rowSpacingPx);
58
58
  return l.map((d, c) => {
59
- const i = $(d, r, n, e);
60
- return c > 0 ? o + i : i;
59
+ const a = x(d, r, n, e);
60
+ return c > 0 ? o + a : a;
61
61
  }).join("");
62
62
  }
63
63
  export {
64
- $ as getListProductCard,
64
+ x as getListProductCard,
65
65
  W as prepareProductRows
66
66
  };
@@ -33,13 +33,4 @@ export declare class ItemsBlock extends Block {
33
33
  * Guarded to the nodeConfig-empty case so it runs once and never loops.
34
34
  */
35
35
  onDocumentChanged(node: ImmutableHtmlNode): void;
36
- /**
37
- * Bakes the compiler-read DOM attributes (`data-type`, `data-number`) onto the
38
- * `.ins-product-td` container from the recovered config. Required for saved modules:
39
- * `migrate()` (which backfills these) only runs at template load — never when a module
40
- * is dropped into a live editor — so this is the one place the namespace + index get
41
- * restored before export. The name `<a>` carries no data-type/data-number of its own and
42
- * relies on this td-level fallback in pairProductVariables.
43
- */
44
- private _stampProductTdDomAttributes;
45
36
  }
@@ -3,13 +3,6 @@ declare const migrationTemplate = "ADD YOUR MIGRATION HERE";
3
3
  type ProductType = 'CART_ITEMS' | 'BROWSED_ITEMS' | 'PURCHASED_ITEMS';
4
4
  type OrientationType = 'vertical' | 'horizontal';
5
5
  type PriceOrientationType = 'vertical' | 'horizontal';
6
- /**
7
- * Wraps a bare migrate-block `<td>` in a `<tr>` so it forms a valid table row.
8
- * Stripo renders its `BlockType.*` tags as full rows, so both the migrate template
9
- * (here) and the orientation-change rebuild (settingsControl._reOrderTemplate) must
10
- * emit `<tr><td>` — otherwise the code editor flags the bare cell as invalid.
11
- */
12
- export declare const wrapInTableRow: (html: string) => string;
13
6
  type TemplateParameters = {
14
7
  orientation: OrientationType;
15
8
  itemsType: ProductType;
@@ -40,18 +40,6 @@ export declare function generateBlockInstanceId(): string;
40
40
  * Prevents currency symbols like "$", "R$", "HK$" from being interpreted as special replacement patterns.
41
41
  */
42
42
  export declare const escapeReplacement: (str: string) => string;
43
- /**
44
- * Derives a card's 1-based product index from its `itemsSelectValue`.
45
- * Prefers the position within ItemInCartOptions for the type; falls back to the
46
- * `(N)` token in the value (e.g. "{{Browsed Item (3) Url}}" -> "3"); defaults to "1".
47
- *
48
- * Single source of truth so block.ts, settingsControl and template.ts stay in sync —
49
- * the number feeds `data-number`, which pairProductVariables reads to index merge tags.
50
- *
51
- * `itemsSelectValue` is typed loosely because callers pass it straight from parsed
52
- * configs where the field can be absent — the runtime guard below is load-bearing.
53
- */
54
- export declare function deriveItemNumber(itemsSelectValue: string | undefined, itemsType: ProductType): string;
55
43
  /**
56
44
  * Returns default ItemsBlockConfig values.
57
45
  * These are used when initializing a new block or when migrating from legacy format.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.9.0-beta.c84fcd0",
3
+ "version": "3.9.0-beta.dd40fcd",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",