@useinsider/guido 3.17.0-beta.bc6e089 → 3.17.0-beta.c93afa9
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/dist/composables/useModuleRepair.js +33 -0
- package/dist/composables/useStripo.js +1 -1
- package/dist/config/migrator/itemsBlockMigrator.js +156 -204
- package/dist/extensions/Blocks/Items/block.js +118 -49
- package/dist/extensions/Blocks/Items/constants/currency.js +25 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +17 -18
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -11
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +55 -58
- package/dist/extensions/Blocks/Items/enums/productEnums.js +9 -14
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +9 -11
- package/dist/extensions/Blocks/Items/template.js +236 -243
- package/dist/src/composables/useModuleRepair.d.ts +18 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +35 -0
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +43 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +0 -3
- package/dist/src/utils/itemsCurrencyRepair.d.ts +17 -0
- package/dist/utils/itemsCurrencyRepair.js +39 -0
- package/dist/utils/pairProductVariables.js +66 -66
- package/package.json +1 -1
- package/dist/composables/useModuleDynamicContentRepair.js +0 -37
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +0 -20
- package/dist/src/composables/useModuleDynamicContentRepair.d.ts +0 -13
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +0 -44
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ModuleAddData, ModuleModifier } from '@@/Types/stripo';
|
|
2
|
+
export declare const UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY = "dynamic-content.unresolved-attributes-on-drop";
|
|
3
|
+
/**
|
|
4
|
+
* Repairs saved modules as they are dropped or copied into the editor, in one pass
|
|
5
|
+
* over the module HTML. Two independent repairs run through a single write-back:
|
|
6
|
+
*
|
|
7
|
+
* - Dynamic content: saved modules serialize merge-tag chips by their display label
|
|
8
|
+
* (`{{ Phone Number }}`); this maps them back to their canonical token
|
|
9
|
+
* (`{{phone_number}}`) using the account's dynamic-content list.
|
|
10
|
+
* - Items currency: v2 Items blocks can carry price `data-curency` /
|
|
11
|
+
* `data-currency_symbol` attrs that drifted from their `esd-ext-config`; these are
|
|
12
|
+
* healed from config (the export contract reads those exact attrs).
|
|
13
|
+
*
|
|
14
|
+
* Wired into Stripo via the `onModuleAdd` init callback (see `useStripo`).
|
|
15
|
+
*/
|
|
16
|
+
export declare const useModuleRepair: () => {
|
|
17
|
+
handleModuleAdd: (data: ModuleAddData, modifier: ModuleModifier) => void;
|
|
18
|
+
};
|
|
@@ -16,6 +16,10 @@ export declare const BLOCK_ID: BlockId;
|
|
|
16
16
|
* - Onboarding support
|
|
17
17
|
*/
|
|
18
18
|
export declare class ItemsBlock extends Block {
|
|
19
|
+
/** Block instances whose currency attrs were already self-healed this session (SD-147588 — undo-safe). */
|
|
20
|
+
private _currencyHealed;
|
|
21
|
+
/** blockInstanceIds already claimed by a live block this session (SD-147588 collision detection). */
|
|
22
|
+
private _seenInstanceIds;
|
|
19
23
|
getId(): string;
|
|
20
24
|
getIcon(): string;
|
|
21
25
|
getBlockCompositionType(): BlockCompositionType;
|
|
@@ -42,4 +46,35 @@ export declare class ItemsBlock extends Block {
|
|
|
42
46
|
* relies on this td-level fallback in pairProductVariables.
|
|
43
47
|
*/
|
|
44
48
|
private _stampProductTdDomAttributes;
|
|
49
|
+
/**
|
|
50
|
+
* Whether a currency self-heal pass should run for this block (SD-147588). The only gate here is
|
|
51
|
+
* once-per-session: heal each instance at most once, so the auto-fix can't fight undo (undo
|
|
52
|
+
* re-drifts the attr, which would otherwise re-trigger the heal forever). The position-vs-symbol
|
|
53
|
+
* authority split lives in `_reconcileCurrencyDomAttributes` — position is always authoritative,
|
|
54
|
+
* the symbol write alone is skipped for the 'USD' sentinel — so we must NOT gate the whole pass
|
|
55
|
+
* on symbol customization here, or a default-symbol block with a toggled location never heals.
|
|
56
|
+
*/
|
|
57
|
+
private _shouldReconcileCurrency;
|
|
58
|
+
/** Marks a block instance's currency as reconciled so it is not healed again (undo-safe). */
|
|
59
|
+
private _markCurrencyHealed;
|
|
60
|
+
/**
|
|
61
|
+
* Resolves the id for a just-created block to one that is unique per live instance.
|
|
62
|
+
* A saved module serializes its blockInstanceId, so every re-drop of the same module
|
|
63
|
+
* arrives with an id already owned by a live instance — reusing it collides both the
|
|
64
|
+
* currency heal guard and settings-panel switch detection. Mint a fresh id on absence
|
|
65
|
+
* or collision, otherwise keep the existing one. Registers the result as claimed.
|
|
66
|
+
*/
|
|
67
|
+
private _resolveInstanceId;
|
|
68
|
+
/**
|
|
69
|
+
* Stamps the export-read currency attrs onto every price `<p>` from config, so a template whose
|
|
70
|
+
* attrs drifted (e.g. a location toggle before the sync fix) self-heals to match the editor.
|
|
71
|
+
* Config is the source of truth — never derive from visible text.
|
|
72
|
+
*
|
|
73
|
+
* Authority split lives in `currencyAttrTargets` (SD-147588) — position only when a location
|
|
74
|
+
* is recorded, symbol only when customized — so this heal and the module-drop repair can't drift.
|
|
75
|
+
*
|
|
76
|
+
* Returns true only when an attr actually changed, so the caller can skip an empty apply that
|
|
77
|
+
* would otherwise re-trigger onDocumentChanged and loop.
|
|
78
|
+
*/
|
|
79
|
+
private _reconcileCurrencyDomAttributes;
|
|
45
80
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single owner for the Items price currency export contract (SD-147588).
|
|
3
|
+
*
|
|
4
|
+
* `data-curency` is deliberately misspelled (one `r`) — it is the attribute the
|
|
5
|
+
* server-side export transform (pairProductVariables) actually reads, so every
|
|
6
|
+
* layer that writes it and the live reader (template, controls, block self-heal,
|
|
7
|
+
* pairProductVariables) MUST go through these constants. A typo fix or mapping change
|
|
8
|
+
* in one of them would otherwise silently break sync with the others and ship the wrong
|
|
9
|
+
* currency position/token to the inbox. Mirrors the Recommendation block's `CURRENCY_ATTR`.
|
|
10
|
+
*
|
|
11
|
+
* Exception: the legacy migrator reads the raw misspelled string on purpose — it parses
|
|
12
|
+
* old templates frozen with that exact attr name, so it must NOT follow a future rename here.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ITEMS_CURRENCY_ATTR: {
|
|
15
|
+
readonly POSITION: "data-curency";
|
|
16
|
+
readonly SYMBOL: "data-currency_symbol";
|
|
17
|
+
};
|
|
18
|
+
/** Currency location select value `'1'` = after (price then symbol), anything else = before. */
|
|
19
|
+
export declare function currencyPositionFromLocation(location: string | undefined): 'after' | 'before';
|
|
20
|
+
/**
|
|
21
|
+
* Whether a currency symbol is a partner customization vs the 'USD' default sentinel (SD-144644).
|
|
22
|
+
* The default value means "use the catalog currency", so it is treated as NOT customized — the one
|
|
23
|
+
* rule shared by the export transform (pairProductVariables) and the block self-heal, kept here so
|
|
24
|
+
* the two layers can never drift. Trims first so a whitespace-only value is not read as custom.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isCustomCurrencySymbol(symbol: string | null | undefined): boolean;
|
|
27
|
+
export interface CurrencyAttrTargets {
|
|
28
|
+
/** Desired `data-curency`; `undefined` = leave the DOM attr as-is (no location recorded). */
|
|
29
|
+
position?: 'before' | 'after';
|
|
30
|
+
/** Desired `data-currency_symbol`; `undefined` = leave it (empty / the 'USD' sentinel). */
|
|
31
|
+
symbol?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The single authority rule for which price currency attrs a config wants written,
|
|
35
|
+
* shared by the block self-heal (Items/block.ts) and the module-drop repair
|
|
36
|
+
* (itemsCurrencyRepair) so the two can never drift (SD-147588). Position is authoritative
|
|
37
|
+
* only when a location is explicitly recorded (an absent value is "unknown", not 'before');
|
|
38
|
+
* the symbol is written only for a custom value (never the 'USD' default sentinel).
|
|
39
|
+
*/
|
|
40
|
+
export declare function currencyAttrTargets(config: {
|
|
41
|
+
priceCurrencyLocation?: string;
|
|
42
|
+
priceCurrencySymbol?: string;
|
|
43
|
+
}): CurrencyAttrTargets;
|
|
@@ -39,17 +39,14 @@ export declare const productPairs: {
|
|
|
39
39
|
CART_ITEMS: {
|
|
40
40
|
ATTR: string;
|
|
41
41
|
DEFAULT: string;
|
|
42
|
-
LEGACY_DEFAULTS: readonly string[];
|
|
43
42
|
};
|
|
44
43
|
BROWSED_ITEMS: {
|
|
45
44
|
ATTR: string;
|
|
46
45
|
DEFAULT: string;
|
|
47
|
-
LEGACY_DEFAULTS: readonly string[];
|
|
48
46
|
};
|
|
49
47
|
PURCHASED_ITEMS: {
|
|
50
48
|
ATTR: string;
|
|
51
49
|
DEFAULT: string;
|
|
52
|
-
LEGACY_DEFAULTS: readonly string[];
|
|
53
50
|
};
|
|
54
51
|
};
|
|
55
52
|
price: {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heals stale price currency attributes on every v2 Items block inside a dropped
|
|
3
|
+
* saved module, driving `data-curency` / `data-currency_symbol` from each block's
|
|
4
|
+
* `esd-ext-config`. A saved module can serialize attrs that no longer match its
|
|
5
|
+
* config; the server-side export reads those exact attrs, so left stale they ship
|
|
6
|
+
* the wrong currency position/symbol.
|
|
7
|
+
*
|
|
8
|
+
* Pure `string → string`. Returns the original string untouched when nothing needs
|
|
9
|
+
* healing (0 blocks, all in sync) so the caller's `html !== currentHtml` guard stays
|
|
10
|
+
* meaningful. Fail-open: any parse fault returns the input unchanged.
|
|
11
|
+
*
|
|
12
|
+
* The module `<td>` stripe has no table context, so it is wrapped before parsing —
|
|
13
|
+
* a bare `<td>` root is otherwise dropped by the HTML parser (same reason
|
|
14
|
+
* recommendationMigrator wraps). If the wrap fails to capture the blocks (non-`<td>`
|
|
15
|
+
* root foster-parented out), it bails to the original string.
|
|
16
|
+
*/
|
|
17
|
+
export declare function repairItemsCurrencyAttributes(html: string): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { currencyAttrTargets as u, ITEMS_CURRENCY_ATTR as c } from "../extensions/Blocks/Items/constants/currency.js";
|
|
2
|
+
import { ItemsBlockId as l } from "../extensions/Blocks/Items/enums/controlEnums.js";
|
|
3
|
+
const s = "items-block-v2";
|
|
4
|
+
function f(e) {
|
|
5
|
+
const i = e.getAttribute("esd-ext-config");
|
|
6
|
+
if (!i)
|
|
7
|
+
return !1;
|
|
8
|
+
let t, r;
|
|
9
|
+
try {
|
|
10
|
+
({ position: t, symbol: r } = u(JSON.parse(i)));
|
|
11
|
+
} catch {
|
|
12
|
+
return !1;
|
|
13
|
+
}
|
|
14
|
+
let o = !1;
|
|
15
|
+
return e.querySelectorAll(`.${l.PRICE} p`).forEach((n) => {
|
|
16
|
+
t !== void 0 && n.getAttribute(c.POSITION) !== t && (n.setAttribute(c.POSITION, t), o = !0), r !== void 0 && n.getAttribute(c.SYMBOL) !== r && (n.setAttribute(c.SYMBOL, r), o = !0);
|
|
17
|
+
}), o;
|
|
18
|
+
}
|
|
19
|
+
function S(e) {
|
|
20
|
+
if (typeof e != "string" || !e.includes(s))
|
|
21
|
+
return e;
|
|
22
|
+
try {
|
|
23
|
+
const t = new DOMParser().parseFromString(
|
|
24
|
+
`<table><tbody><tr>${e}</tr></tbody></table>`,
|
|
25
|
+
"text/html"
|
|
26
|
+
).querySelector("tr"), r = t.querySelectorAll(`.${s}`);
|
|
27
|
+
if (r.length === 0)
|
|
28
|
+
return e;
|
|
29
|
+
let o = !1;
|
|
30
|
+
return r.forEach((n) => {
|
|
31
|
+
f(n) && (o = !0);
|
|
32
|
+
}), o ? t.innerHTML : e;
|
|
33
|
+
} catch (i) {
|
|
34
|
+
return console.error("Failed to repair items currency on module add:", i), e;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
S as repairItemsCurrencyAttributes
|
|
39
|
+
};
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
+
import { ITEMS_CURRENCY_ATTR as D, isCustomCurrencySymbol as G } from "../extensions/Blocks/Items/constants/currency.js";
|
|
1
2
|
import { productPairs as L } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
2
|
-
import { DefaultConfigValues as G } from "../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
3
3
|
import { escapeReplacement as X } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
|
|
4
|
-
import { preserveTextStyles as
|
|
5
|
-
import { unwrapProductNameLinks as
|
|
6
|
-
const
|
|
4
|
+
import { preserveTextStyles as F } from "./preserveTextStyles.js";
|
|
5
|
+
import { unwrapProductNameLinks as Y } from "./unwrapProductNameLink.js";
|
|
6
|
+
const x = {
|
|
7
7
|
CART_ITEMS: "ins_apr",
|
|
8
8
|
BROWSED_ITEMS: "browsed_item",
|
|
9
9
|
PURCHASED_ITEMS: "purchased_item"
|
|
10
|
-
},
|
|
11
|
-
function
|
|
12
|
-
let h =
|
|
10
|
+
}, O = (S) => S.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
11
|
+
function v(S, y, b) {
|
|
12
|
+
let h = y;
|
|
13
13
|
for (; h > 0 && /\s/.test(S[h - 1]); )
|
|
14
14
|
h -= 1;
|
|
15
|
-
return
|
|
15
|
+
return b.some((I) => S.endsWith(I, h));
|
|
16
16
|
}
|
|
17
17
|
function K(S) {
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const y = O(S), b = new DOMParser().parseFromString(y, "text/html");
|
|
19
|
+
Y(b);
|
|
20
20
|
const h = L.PAIRS_FOR_EXTENSION;
|
|
21
21
|
Object.entries(h).forEach(([n, d]) => {
|
|
22
|
-
|
|
22
|
+
b.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
23
23
|
const E = r.getAttribute("data-number") || "1", m = r.getAttribute("data-type") || "CART_ITEMS";
|
|
24
24
|
r.querySelectorAll(`[product-attr="${n}"]`).forEach((t) => {
|
|
25
|
-
var $,
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
25
|
+
var $, H, N;
|
|
26
|
+
const g = t.getAttribute("data-type") || m, o = t.getAttribute("data-number") || E, u = d[g];
|
|
27
|
+
if (u)
|
|
28
28
|
switch (n) {
|
|
29
29
|
case "imageSrc": {
|
|
30
|
-
let e = null,
|
|
31
|
-
if (t.tagName === "IMG" ? (e = t,
|
|
30
|
+
let e = null, s = null;
|
|
31
|
+
if (t.tagName === "IMG" ? (e = t, s = e.closest("a")) : (e = t.querySelector("img"), s = t.querySelector("a") || t.closest("a")), !e)
|
|
32
32
|
break;
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
return
|
|
39
|
-
}) && (e.src = `{{${
|
|
33
|
+
const a = u.DEFAULT, l = u.ATTR;
|
|
34
|
+
if (a && e.src) {
|
|
35
|
+
const i = e.src;
|
|
36
|
+
a.some((_) => {
|
|
37
|
+
const f = _.split("/").pop() || "", P = i.split("/").pop() || "";
|
|
38
|
+
return i.includes(_) || i.includes(f) || P === f;
|
|
39
|
+
}) && (e.src = `{{${l}_${o}}}`);
|
|
40
40
|
}
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
(
|
|
41
|
+
const c = (H = ($ = h.name) == null ? void 0 : $[g]) == null ? void 0 : H.ATTR;
|
|
42
|
+
if (c && e.setAttribute("alt", `{{${c}_${o}}}`), s) {
|
|
43
|
+
const i = (N = h.itemLink) == null ? void 0 : N[g];
|
|
44
|
+
if (i) {
|
|
45
|
+
const R = i.HREF, _ = i.DEFAULT_HREF || "#!", f = s.href;
|
|
46
|
+
(f === "#" || f === "" || f.endsWith("#!") || f.endsWith(_) || f === `${window.location.href}${_}` || !f || f === window.location.href) && (s.href = `{{${R}_${o}}}`);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
break;
|
|
50
50
|
}
|
|
51
51
|
case "name": {
|
|
52
|
-
const e =
|
|
53
|
-
t.textContent && (t.innerHTML =
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
const
|
|
57
|
-
(
|
|
52
|
+
const e = u, s = e.ATTR, a = e.DEFAULT_HREF || "#!", l = e.HREF;
|
|
53
|
+
t.textContent && (t.innerHTML = F(t, `{{${s}_${o}}}`));
|
|
54
|
+
const c = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
55
|
+
if (c && l) {
|
|
56
|
+
const i = c.href, R = `${window.location.href}${a}`;
|
|
57
|
+
(i === R || i.endsWith(a)) && (c.href = `{{${l}_${o}}}`);
|
|
58
58
|
}
|
|
59
59
|
break;
|
|
60
60
|
}
|
|
61
61
|
case "price":
|
|
62
62
|
case "originalPrice": {
|
|
63
|
-
const e =
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
let
|
|
68
|
-
const
|
|
63
|
+
const e = u, s = t.getAttribute("data-formated"), a = t.getAttribute("data-single_price"), l = s === "true", c = a === "true", i = t.getAttribute(D.POSITION) || "before";
|
|
64
|
+
let R;
|
|
65
|
+
c ? R = l ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : R = l ? e.PRICE_FORMATTED : e.PRICE;
|
|
66
|
+
const _ = e.CURRENCY;
|
|
67
|
+
let f = `{{${R}_${o}}}`;
|
|
68
|
+
const P = (t.getAttribute(D.SYMBOL) || "").trim(), V = G(P);
|
|
69
69
|
let C = "";
|
|
70
|
-
V ? C =
|
|
70
|
+
V ? C = P : _ && (C = `{{${_}_${o}}}`), C && (f = i === "after" ? `${f} ${C}` : `${C} ${f}`), t.innerHTML = F(t, f);
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
73
73
|
case "quantity": {
|
|
74
|
-
const e =
|
|
75
|
-
|
|
74
|
+
const e = u, s = e.ATTR, a = e.DEFAULT;
|
|
75
|
+
t.textContent && t.textContent.trim() === a && (t.innerHTML = F(t, `{{${s}_${o}}}`));
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
78
|
case "button": {
|
|
79
|
-
const e =
|
|
80
|
-
if (
|
|
81
|
-
const
|
|
82
|
-
(
|
|
79
|
+
const e = u, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t.tagName === "A" ? t : t.querySelector("a");
|
|
80
|
+
if (l) {
|
|
81
|
+
const c = l.href || "", i = `${window.location.href}${a}`;
|
|
82
|
+
(c === "" || c === "#" || c === i || c.endsWith(a) || c.endsWith("#!") || c === window.location.href) && (l.href = `{{${s}_${o}}}`);
|
|
83
83
|
}
|
|
84
84
|
break;
|
|
85
85
|
}
|
|
86
86
|
case "itemLink": {
|
|
87
|
-
const e =
|
|
88
|
-
if (
|
|
89
|
-
const
|
|
90
|
-
(
|
|
87
|
+
const e = u, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t;
|
|
88
|
+
if (l.href) {
|
|
89
|
+
const c = l.href, i = `${window.location.href}${a}`;
|
|
90
|
+
(c === i || c.endsWith(a)) && (l.href = `{{${s}_${o}}}`);
|
|
91
91
|
}
|
|
92
92
|
break;
|
|
93
93
|
}
|
|
94
94
|
default: {
|
|
95
|
-
if ("ATTR" in
|
|
96
|
-
const e =
|
|
97
|
-
t.textContent && (t.innerHTML =
|
|
95
|
+
if ("ATTR" in u) {
|
|
96
|
+
const e = u.ATTR;
|
|
97
|
+
t.textContent && (t.innerHTML = F(t, `{{${e}_${o}}}`));
|
|
98
98
|
}
|
|
99
99
|
break;
|
|
100
100
|
}
|
|
@@ -102,8 +102,8 @@ function K(S) {
|
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
|
-
const
|
|
106
|
-
` : "", U =
|
|
105
|
+
const I = y.match(/<!DOCTYPE[^>]*>/i), q = I ? `${I[0]}
|
|
106
|
+
` : "", U = b.querySelectorAll(".ins-product-td"), M = [];
|
|
107
107
|
U.forEach((n) => {
|
|
108
108
|
const d = n.getAttribute("data-type") || "CART_ITEMS", p = n.getAttribute("data-number") || "1", r = n.outerHTML;
|
|
109
109
|
M.push({
|
|
@@ -113,19 +113,19 @@ function K(S) {
|
|
|
113
113
|
number: p
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
|
-
let A =
|
|
116
|
+
let A = q + b.documentElement.outerHTML;
|
|
117
117
|
M.reverse().forEach(({ outerHtml: n, type: d, number: p }) => {
|
|
118
|
-
const r =
|
|
118
|
+
const r = x[d], E = r ? `${r}_total_product_kind` : "";
|
|
119
119
|
if (E) {
|
|
120
120
|
const T = parseInt(p) - 1, o = `${`{% if ${E} > ${T} %}`}${n}{% endif %}`;
|
|
121
121
|
A = A.replace(n, X(o));
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
|
-
const W =
|
|
124
|
+
const W = b.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set();
|
|
125
125
|
return W.forEach((n) => {
|
|
126
126
|
var t;
|
|
127
127
|
const d = n.getAttribute("data-number"), p = n.getAttribute("data-type");
|
|
128
|
-
if (!d || !
|
|
128
|
+
if (!d || !x[p])
|
|
129
129
|
return;
|
|
130
130
|
const r = n.closest(".product-original-price-class");
|
|
131
131
|
if (!r || k.has(r))
|
|
@@ -136,13 +136,13 @@ function K(S) {
|
|
|
136
136
|
}), w.forEach(({ number: n, type: d, wrap: p }, r) => {
|
|
137
137
|
if (r.includes("{% if") || !p.some(Boolean))
|
|
138
138
|
return;
|
|
139
|
-
const E = L.PAIRS_FOR_EXTENSION.price[d].PRICE, m = L.PAIRS_FOR_EXTENSION.originalPrice[d].PRICE, T = `{% if ${E}_${n} != ${m}_${n} %}`, t = [T,
|
|
140
|
-
let
|
|
139
|
+
const E = L.PAIRS_FOR_EXTENSION.price[d].PRICE, m = L.PAIRS_FOR_EXTENSION.originalPrice[d].PRICE, T = `{% if ${E}_${n} != ${m}_${n} %}`, t = [T, O(T)];
|
|
140
|
+
let g = "", o = 0, u = 0, $ = A.indexOf(r);
|
|
141
141
|
for (; $ !== -1; ) {
|
|
142
|
-
const
|
|
143
|
-
|
|
142
|
+
const H = p[u] === !0 && !v(A, $, t);
|
|
143
|
+
g += A.slice(o, $) + (H ? `${T}${r}{% endif %}` : r), o = $ + r.length, u += 1, $ = A.indexOf(r, o);
|
|
144
144
|
}
|
|
145
|
-
A =
|
|
145
|
+
A = g + A.slice(o);
|
|
146
146
|
}), A.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
147
147
|
}
|
|
148
148
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.17.0-beta.
|
|
3
|
+
"version": "3.17.0-beta.c93afa9",
|
|
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",
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useConfig as C } from "./useConfig.js";
|
|
2
|
-
import { useToaster as D } from "./useToaster.js";
|
|
3
|
-
import { useTranslations as T } from "./useTranslations.js";
|
|
4
|
-
import { ToasterTypeOptions as g } from "../enums/toaster.js";
|
|
5
|
-
import { buildDynamicContentLookup as h, convertModuleDynamicContent as O } from "../utils/dynamicContentConverter.js";
|
|
6
|
-
import { flattenDynamicContentList as f } from "../utils/genericUtil.js";
|
|
7
|
-
const M = "dynamic-content.unresolved-attributes-on-drop", b = () => {
|
|
8
|
-
const { template: i, isFeatureEnabled: p } = C(), { showToaster: m } = D(), a = T();
|
|
9
|
-
return { handleModuleAdd: (n, o) => {
|
|
10
|
-
var s, c, l;
|
|
11
|
-
try {
|
|
12
|
-
if ((n == null ? void 0 : n.action) !== "ADD" && (n == null ? void 0 : n.action) !== "COPY")
|
|
13
|
-
return;
|
|
14
|
-
const e = h(f((s = i.value) == null ? void 0 : s.dynamicContentList));
|
|
15
|
-
if (e.size === 0)
|
|
16
|
-
return;
|
|
17
|
-
const t = (c = o == null ? void 0 : o.getTargetNode) == null ? void 0 : c.call(o), r = (l = t == null ? void 0 : t.getOuterHTML) == null ? void 0 : l.call(t);
|
|
18
|
-
if (!t || typeof r != "string")
|
|
19
|
-
return;
|
|
20
|
-
const { html: u, unresolved: y } = O(
|
|
21
|
-
r,
|
|
22
|
-
e,
|
|
23
|
-
p("liquidSyntax")
|
|
24
|
-
);
|
|
25
|
-
u !== r && o.modifyHtml(t).replaceWith(u), y.length > 0 && m({
|
|
26
|
-
type: g.Warning,
|
|
27
|
-
message: a(M)
|
|
28
|
-
});
|
|
29
|
-
} catch (e) {
|
|
30
|
-
console.error("Failed to repair dynamic content on module add:", e);
|
|
31
|
-
}
|
|
32
|
-
} };
|
|
33
|
-
};
|
|
34
|
-
export {
|
|
35
|
-
M as UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY,
|
|
36
|
-
b as useModuleDynamicContentRepair
|
|
37
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SETTINGS_ENUMS as L } from "../enums/settingsEnums.js";
|
|
2
|
-
const c = "130px", O = "100%", t = (e) => e === L.ORIENTATION.HORIZONTAL ? c : O, n = {
|
|
3
|
-
VERTICAL: "es-p5b es-p5t",
|
|
4
|
-
HORIZONTAL: "es-p5l es-p5r"
|
|
5
|
-
}, o = "data-items-cell-pad", R = (e) => `${o}="${e ? "v" : "h"}"`, E = (e) => e ? ` ${n.VERTICAL}` : ` ${n.HORIZONTAL}`, N = (e, A) => {
|
|
6
|
-
if (!e.includes(o))
|
|
7
|
-
return e;
|
|
8
|
-
const T = A ? n.HORIZONTAL : n.VERTICAL, s = A ? n.VERTICAL : n.HORIZONTAL, I = A ? "v" : "h";
|
|
9
|
-
return e.replace(T, s).replace(new RegExp(`${o}="[hv]"`), `${o}="${I}"`);
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
n as BLOCK_CELL_PADDING,
|
|
13
|
-
o as BLOCK_CELL_PAD_ATTR,
|
|
14
|
-
c as NAME_HORIZONTAL_MAX_WIDTH,
|
|
15
|
-
O as NAME_VERTICAL_MAX_WIDTH,
|
|
16
|
-
R as blockCellPadMarker,
|
|
17
|
-
E as blockCellPaddingFor,
|
|
18
|
-
t as nameMaxWidthFor,
|
|
19
|
-
N as reorientBlockCellPadding
|
|
20
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ModuleAddData, ModuleModifier } from '@@/Types/stripo';
|
|
2
|
-
export declare const UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY = "dynamic-content.unresolved-attributes-on-drop";
|
|
3
|
-
/**
|
|
4
|
-
* Repairs label-form dynamic-content tokens in saved modules as they are dropped
|
|
5
|
-
* or copied into the editor. Saved modules serialize merge-tag chips by their
|
|
6
|
-
* display label (`{{ Phone Number }}`); this maps them back to their canonical
|
|
7
|
-
* token (`{{phone_number}}`) using the account's dynamic-content list.
|
|
8
|
-
*
|
|
9
|
-
* Wired into Stripo via the `onModuleAdd` init callback (see `useStripo`).
|
|
10
|
-
*/
|
|
11
|
-
export declare const useModuleDynamicContentRepair: () => {
|
|
12
|
-
handleModuleAdd: (data: ModuleAddData, modifier: ModuleModifier) => void;
|
|
13
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Single owner for the Items card orientation-dependent layout contract (SD-149368).
|
|
3
|
-
*
|
|
4
|
-
* Two things depend on a card's orientation and are written across several layers:
|
|
5
|
-
*
|
|
6
|
-
* 1. Name column width — a horizontal card lays the name in a narrow side-by-side
|
|
7
|
-
* column, so it is capped; a vertical card gives it a full-width row.
|
|
8
|
-
* 2. Block-cell padding — the collapsible price / original-price block-cell carries its
|
|
9
|
-
* own inter-cell spacing (horizontal cards pad left/right, vertical cards pad
|
|
10
|
-
* top/bottom) so a hidden element removes its own spacing instead of leaving a gap.
|
|
11
|
-
*
|
|
12
|
-
* Every layer that writes these — template render, layouts/horizontal.html,
|
|
13
|
-
* NameTrimmingControl (trimming toggle) and settingsControl (orientation change) — MUST
|
|
14
|
-
* derive them here, or a migrated / re-toggled card silently drifts out of sync with
|
|
15
|
-
* freshly generated markup (convention B1: cross-layer literals live in one module).
|
|
16
|
-
*/
|
|
17
|
-
export declare const NAME_HORIZONTAL_MAX_WIDTH = "130px";
|
|
18
|
-
export declare const NAME_VERTICAL_MAX_WIDTH = "100%";
|
|
19
|
-
/** Name max-width for a card orientation. Non-horizontal (incl. undefined) → full width. */
|
|
20
|
-
export declare const nameMaxWidthFor: (orientation?: string) => string;
|
|
21
|
-
/** Orientation-dependent inter-cell padding classes for a collapsible block-cell. */
|
|
22
|
-
export declare const BLOCK_CELL_PADDING: {
|
|
23
|
-
readonly VERTICAL: "es-p5b es-p5t";
|
|
24
|
-
readonly HORIZONTAL: "es-p5l es-p5r";
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Attribute the block-cell carries to mark its LAYOUT-owned padding orientation ('v'|'h').
|
|
28
|
-
* The orientation toggle keys off this marker so it only ever rewrites the padding the
|
|
29
|
-
* layout itself baked — a user's own es-p* padding classes are never matched or clobbered
|
|
30
|
-
* (SD-149368 F1), and a cell without the marker is left untouched rather than mis-swapped.
|
|
31
|
-
*/
|
|
32
|
-
export declare const BLOCK_CELL_PAD_ATTR = "data-items-cell-pad";
|
|
33
|
-
/** Marker attribute (`data-items-cell-pad="v|h"`) for a block-cell in the given orientation. */
|
|
34
|
-
export declare const blockCellPadMarker: (isVertical: boolean) => string;
|
|
35
|
-
/** Padding classes (leading space included) for a block-cell in the given orientation. */
|
|
36
|
-
export declare const blockCellPaddingFor: (isVertical: boolean) => string;
|
|
37
|
-
/**
|
|
38
|
-
* Rewrites a block-cell's LAYOUT-owned padding classes to the target orientation, keyed off
|
|
39
|
-
* the BLOCK_CELL_PAD_ATTR marker. The orientation-change rebuild re-injects existing cells
|
|
40
|
-
* via getOuterHTML(), which still carry the previous orientation's padding — swap only the
|
|
41
|
-
* layout pair (and flip the marker) so price/original-price cells stay padded after a toggle
|
|
42
|
-
* (SD-149368 F3), while a user's own padding and any unmarked cell are left alone (F1).
|
|
43
|
-
*/
|
|
44
|
-
export declare const reorientBlockCellPadding: (html: string, toVertical: boolean) => string;
|