@useinsider/guido 3.6.0-beta.a8be7f8 → 3.6.0-beta.b75de0e
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/useHtmlValidator.js +131 -102
- package/dist/composables/useRecommendation.js +34 -33
- package/dist/composables/useStripoEventHandler.js +15 -20
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +28 -27
- package/dist/config/compiler/utils/recommendationIgnoreUtils.js +15 -0
- package/dist/config/migrator/recommendation/extractors.js +44 -22
- package/dist/config/migrator/recommendation/htmlBuilder.js +175 -169
- package/dist/config/migrator/recommendationMigrator.js +30 -31
- package/dist/enums/toaster.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +16 -35
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +21 -15
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +38 -24
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +39 -38
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +45 -34
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +3 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +62 -52
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +74 -67
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +7 -6
- package/dist/extensions/Blocks/Recommendation/extension.js +6 -5
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +14 -9
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -2
- package/dist/extensions/Blocks/Recommendation/templates/index.js +5 -4
- package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +21 -0
- package/dist/src/composables/useHtmlValidator.d.ts +9 -0
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +17 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +8 -0
- package/dist/src/enums/toaster.d.ts +1 -2
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -13
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +21 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerCustomizations.d.ts +7 -0
- package/package.json +1 -1
- package/dist/extensions/Blocks/Recommendation/useRecommendationBlockWarning.js +0 -16
- package/dist/extensions/Blocks/Recommendation/utils/recommendationBlockCount.js +0 -9
- package/dist/src/extensions/Blocks/Recommendation/useRecommendationBlockWarning.d.ts +0 -11
- package/dist/src/extensions/Blocks/Recommendation/utils/recommendationBlockCount.d.ts +0 -28
- /package/dist/src/{extensions/Blocks/Recommendation/block.test.d.ts → composables/useHtmlValidator.test.d.ts} +0 -0
- /package/dist/src/{extensions/Blocks/Recommendation/utils/recommendationBlockCount.test.d.ts → config/compiler/utils/recommendationIgnoreUtils.test.d.ts} +0 -0
|
@@ -8,4 +8,12 @@ export declare function buildBlockHtml(params: {
|
|
|
8
8
|
extraClasses?: string;
|
|
9
9
|
legacyId?: string;
|
|
10
10
|
legacyBgColor?: string;
|
|
11
|
+
/**
|
|
12
|
+
* When set, the block's existing inner HTML is preserved verbatim instead
|
|
13
|
+
* of regenerating product rows — used for partner-customized blocks so
|
|
14
|
+
* their hand-authored `{{...}}` variables survive migration.
|
|
15
|
+
*/
|
|
16
|
+
preserveInnerHtml?: string;
|
|
17
|
+
/** Adds the `ins-skip-compile` opt-out class to the migrated block. */
|
|
18
|
+
skipCompile?: boolean;
|
|
11
19
|
}): string;
|
|
@@ -55,19 +55,6 @@ export declare class RecommendationBlock extends Block {
|
|
|
55
55
|
* @param node - The block node being deleted
|
|
56
56
|
*/
|
|
57
57
|
onDelete(node: ImmutableHtmlNode): void;
|
|
58
|
-
/**
|
|
59
|
-
* Warns (dark advisory toaster) when the design holds more than one live
|
|
60
|
-
* recommendation block. Triggered from the user-add paths only (fresh drop
|
|
61
|
-
* and duplicate) — never from document-load/migration, so opening a template
|
|
62
|
-
* that already has multiple blocks does not fire it.
|
|
63
|
-
*
|
|
64
|
-
* Counting lives in `useRecommendationBlockWarning` so the same DOM-based
|
|
65
|
-
* logic (which ignores the empty shells deletions leave behind, SD-143028)
|
|
66
|
-
* is shared with the `module_dropped` handler — recommendation blocks can
|
|
67
|
-
* also arrive inside a saved structure. Wrapped in try/catch because the
|
|
68
|
-
* document root may be unavailable during initial load.
|
|
69
|
-
*/
|
|
70
|
-
private _warnIfMultipleBlocks;
|
|
71
58
|
/**
|
|
72
59
|
* Generates the next unique recommendation ID by scanning all existing blocks
|
|
73
60
|
* in the document and finding the maximum existing ID + 1.
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { RecommendationBlockId } from './blockIds';
|
|
10
10
|
export { RecommendationControlId } from './controlIds';
|
|
11
|
-
export { BLOCK_ROOT_SELECTOR, CONTAINER_SELECTOR, DESKTOP_CONTAINER_SELECTOR, MOBILE_CONTAINER_SELECTOR, MOBILE_ROW_SELECTOR, CSS_CLASS_RECO_BUTTON, CURRENCY_ATTR, ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT_OLD_PRICE, ATTR_PRODUCT_OMNIBUS_PRICE, ATTR_PRODUCT_OMNIBUS_DISCOUNT, ATTR_PRODUCT_BUTTON, ATTR_CUSTOM_PREFIX, ATTR_DATA_CUSTOM_ATTRIBUTES, ATTR_PRODUCT_ATTR, BUILT_IN_DEFAULT_ATTRIBUTES, } from './selectors';
|
|
11
|
+
export { BLOCK_ROOT_SELECTOR, CONTAINER_SELECTOR, DESKTOP_CONTAINER_SELECTOR, MOBILE_CONTAINER_SELECTOR, MOBILE_ROW_SELECTOR, CSS_CLASS_RECO_BUTTON, CSS_CLASS_SKIP_COMPILE, RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES, CURRENCY_ATTR, ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT_OLD_PRICE, ATTR_PRODUCT_OMNIBUS_PRICE, ATTR_PRODUCT_OMNIBUS_DISCOUNT, ATTR_PRODUCT_BUTTON, ATTR_CUSTOM_PREFIX, ATTR_DATA_CUSTOM_ATTRIBUTES, ATTR_PRODUCT_ATTR, BUILT_IN_DEFAULT_ATTRIBUTES, } from './selectors';
|
|
12
12
|
export { LAYOUT_VALUES, LAYOUT_OPTIONS, DEFAULT_PRODUCTS_PER_ROW, DEFAULT_CARDS_IN_ROW, DEFAULT_MOBILE_CARDS_IN_ROW, MAX_PRODUCT_COUNT, MIN_PRODUCT_COUNT, MAX_PRODUCTS_PER_ROW, MIN_PRODUCTS_PER_ROW, MAX_MOBILE_PRODUCTS_PER_ROW, MIN_MOBILE_PRODUCTS_PER_ROW, DEFAULT_COLUMN_SPACING, DEFAULT_ROW_SPACING, DEFAULT_MOBILE_COLUMN_SPACING, DEFAULT_MOBILE_ROW_SPACING, MIN_SPACING, MAX_SPACING, SPACING_STEP, } from './layout';
|
|
13
13
|
export { DEFAULT_NODE_CONFIG, DEFAULT_CURRENCY, DEFAULT_COMPOSITION, DEFAULT_VISIBILITY, CURRENT_CONFIG_VERSION, EXCLUDED_ALGORITHM_IDS, } from './defaultConfig';
|
|
@@ -23,6 +23,18 @@ export declare const MOBILE_ROW_SELECTOR = ".ins-recommendation-mobile-row";
|
|
|
23
23
|
* `{{cId_pIdx_url}}` template variable.
|
|
24
24
|
*/
|
|
25
25
|
export declare const CSS_CLASS_RECO_BUTTON = "reco-v3-button";
|
|
26
|
+
/**
|
|
27
|
+
* Opt-out class for partners who want to inject their own template variables
|
|
28
|
+
* into a recommendation block. When present on `.recommendation-block-v2`,
|
|
29
|
+
* Guido skips ONLY its product-data → template-variable substitution
|
|
30
|
+
* (`replaceProductAttributes`) for that block — partners author their own
|
|
31
|
+
* `{{recoId_index_attribute}}` variables. Everything else (campaign URL
|
|
32
|
+
* building, hidden-row removal, Outlook image widths, text-trim CSS, discount
|
|
33
|
+
* conditions, store hydration, store-level config validation, and general HTML
|
|
34
|
+
* optimizations) still applies. The class is preserved in the final compiled
|
|
35
|
+
* output so partners may use it for their own styling.
|
|
36
|
+
*/
|
|
37
|
+
export declare const CSS_CLASS_SKIP_COMPILE = "ins-skip-compile";
|
|
26
38
|
/**
|
|
27
39
|
* Currency HTML attributes set on the block element
|
|
28
40
|
* These are read by the HTML compiler at runtime to format prices
|
|
@@ -61,3 +73,12 @@ export declare const ATTR_PRODUCT_ATTR = "product-attr";
|
|
|
61
73
|
* Used to exclude these from the custom attribute dropdown to prevent duplication with toggles.
|
|
62
74
|
*/
|
|
63
75
|
export declare const BUILT_IN_DEFAULT_ATTRIBUTES: Set<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Attribute names valid inside a `{{recoId_index_attributeName}}` template
|
|
78
|
+
* variable regardless of the account's custom attribute list. Every built-in
|
|
79
|
+
* composition attribute is valid, plus `currency` and `discount` which the
|
|
80
|
+
* compiler emits but are not composition toggles. Custom attributes are
|
|
81
|
+
* validated separately against the account's fetched attribute list
|
|
82
|
+
* (`stripo/email-recommendation-attributes`).
|
|
83
|
+
*/
|
|
84
|
+
export declare const RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES: Set<string>;
|
|
@@ -17,6 +17,13 @@ export declare class RecommendationCardCompositionControl extends CommonControl
|
|
|
17
17
|
getId(): string;
|
|
18
18
|
getTemplate(): string;
|
|
19
19
|
onRender(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Card composition restructures the block (toggles/reorders/adds attribute
|
|
22
|
+
* cells), which would corrupt a partner-managed (`ins-skip-compile`) block's
|
|
23
|
+
* preserved markup. There is no native tab-disable API, so the whole control
|
|
24
|
+
* container is rendered inert (greyed + non-interactive) instead.
|
|
25
|
+
*/
|
|
26
|
+
_syncDisabledState(): void;
|
|
20
27
|
onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
|
|
21
28
|
onDestroy(): void;
|
|
22
29
|
private _initializeComposition;
|
|
@@ -21,6 +21,11 @@ export declare class LayoutOrientationControl extends CommonControl {
|
|
|
21
21
|
getTemplate(): string;
|
|
22
22
|
onRender(): void;
|
|
23
23
|
onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
|
|
24
|
+
/**
|
|
25
|
+
* Layout orientation restructures the whole block, which is meaningless for
|
|
26
|
+
* partner-managed (`ins-skip-compile`) blocks — disable the control there.
|
|
27
|
+
*/
|
|
28
|
+
_syncDisabledState(): void;
|
|
24
29
|
_setFormValues(): void;
|
|
25
30
|
/**
|
|
26
31
|
* Handles layout change
|
|
@@ -30,6 +30,12 @@ export declare class ProductLayoutControl extends CommonControl {
|
|
|
30
30
|
getTemplate(): string;
|
|
31
31
|
onRender(): void;
|
|
32
32
|
onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
|
|
33
|
+
/**
|
|
34
|
+
* Products-per-row and mobile-layout restructure the block, which is
|
|
35
|
+
* meaningless for partner-managed (`ins-skip-compile`) blocks — disable
|
|
36
|
+
* these inputs there. Disabling coexists with the visibility logic above.
|
|
37
|
+
*/
|
|
38
|
+
_syncDisabledState(): void;
|
|
33
39
|
onDestroy(): void;
|
|
34
40
|
_setFormValues(): void;
|
|
35
41
|
/**
|
|
@@ -35,6 +35,15 @@ interface DocumentModifier {
|
|
|
35
35
|
* @returns The block element or null if not found
|
|
36
36
|
*/
|
|
37
37
|
export declare function getBlockElement(currentNode: ImmutableHtmlNode | null | undefined): ImmutableHtmlNode | null;
|
|
38
|
+
/**
|
|
39
|
+
* True when the recommendation block has opted out of Guido's content
|
|
40
|
+
* regeneration via the `ins-skip-compile` class. Partner-managed blocks carry
|
|
41
|
+
* hand-authored `{{...}}` variables in their cells, so Guido must never
|
|
42
|
+
* overwrite their content with product data (regenerate / in-place update).
|
|
43
|
+
* @param currentNode - The current template node
|
|
44
|
+
* @returns True if the block opted out of content regeneration
|
|
45
|
+
*/
|
|
46
|
+
export declare function isPartnerManagedBlock(currentNode: ImmutableHtmlNode | null | undefined): boolean;
|
|
38
47
|
/**
|
|
39
48
|
* Gets the current layout orientation from the block's data attribute
|
|
40
49
|
* Supports both old (horizontal/vertical) and new (list/grid) values for backward compatibility
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the extra recommendation feed query params for an account, if any.
|
|
3
|
+
* Accounts without customizations get an empty object.
|
|
4
|
+
* @param partnerName Account subdomain (`config.partner.name`)
|
|
5
|
+
* @param strategy Recommendation strategy key of the block
|
|
6
|
+
*/
|
|
7
|
+
export declare function getPartnerRecommendationParams(partnerName: string, strategy: string): Record<string, string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.6.0-beta.
|
|
3
|
+
"version": "3.6.0-beta.b75de0e",
|
|
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,16 +0,0 @@
|
|
|
1
|
-
import { useToaster as r } from "../../../composables/useToaster.js";
|
|
2
|
-
import { useTranslations as s } from "../../../composables/useTranslations.js";
|
|
3
|
-
import { ToasterTypeOptions as n } from "../../../enums/toaster.js";
|
|
4
|
-
import { countLiveRecommendationBlocks as i } from "./utils/recommendationBlockCount.js";
|
|
5
|
-
const a = "newsletter.multiple-reco-blocks-warning", f = () => {
|
|
6
|
-
const { showToaster: o } = r(), t = s();
|
|
7
|
-
return { warnIfMultipleBlocks: (e) => {
|
|
8
|
-
i(e) > 1 && o({
|
|
9
|
-
type: n.Dark,
|
|
10
|
-
message: t(a)
|
|
11
|
-
});
|
|
12
|
-
} };
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
f as useRecommendationBlockWarning
|
|
16
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const r = ".recommendation-block-v2", t = ".recommendation-product-row";
|
|
2
|
-
function n(o) {
|
|
3
|
-
return Array.from(o.querySelectorAll(r)).filter((e) => e.querySelector(t)).length;
|
|
4
|
-
}
|
|
5
|
-
export {
|
|
6
|
-
r as RECOMMENDATION_BLOCK_SELECTOR,
|
|
7
|
-
t as RECOMMENDATION_PRODUCT_ROW_SELECTOR,
|
|
8
|
-
n as countLiveRecommendationBlocks
|
|
9
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { QueryableRoot } from './utils/recommendationBlockCount';
|
|
2
|
-
/**
|
|
3
|
-
* Advisory shown when a design ends up with more than one recommendation block,
|
|
4
|
-
* since multiple blocks can slow campaign delivery. Shared by the block
|
|
5
|
-
* lifecycle (direct drop / duplicate, counting the editor's document root) and
|
|
6
|
-
* the `module_dropped` event (counting a parsed `getTemplateData()` document, so
|
|
7
|
-
* recommendation blocks that arrive inside a saved structure are also covered).
|
|
8
|
-
*/
|
|
9
|
-
export declare const useRecommendationBlockWarning: () => {
|
|
10
|
-
warnIfMultipleBlocks: (root: QueryableRoot) => void;
|
|
11
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Counts *live* recommendation blocks in a document.
|
|
3
|
-
*
|
|
4
|
-
* Deleting a recommendation block strips its inner content but leaves an empty
|
|
5
|
-
* `.recommendation-block-v2` container shell behind — present in every document
|
|
6
|
-
* representation the editor exposes (`getDocumentRoot`, `getDocumentRootHtmlNode`
|
|
7
|
-
* and even `getTemplateData`). A raw class count therefore over-reports after a
|
|
8
|
-
* delete→add cycle (SD-143028). The product row (`.recommendation-product-row`)
|
|
9
|
-
* is present on every live block from drop time (the default template ships
|
|
10
|
-
* product rows, both grid and list layouts) and is removed from a deleted
|
|
11
|
-
* block's leftover shell, so filtering by it cleanly separates live blocks from
|
|
12
|
-
* ghosts without reading any store.
|
|
13
|
-
*/
|
|
14
|
-
export declare const RECOMMENDATION_BLOCK_SELECTOR = ".recommendation-block-v2";
|
|
15
|
-
export declare const RECOMMENDATION_PRODUCT_ROW_SELECTOR = ".recommendation-product-row";
|
|
16
|
-
interface QueryableNode {
|
|
17
|
-
querySelector(selector: string): unknown;
|
|
18
|
-
}
|
|
19
|
-
export interface QueryableRoot {
|
|
20
|
-
querySelectorAll(selector: string): Iterable<QueryableNode>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Counts the live recommendation blocks reachable from `root`. Works on the
|
|
24
|
-
* editor's `ImmutableHtmlNode` document root (drop / duplicate paths) and on a
|
|
25
|
-
* DOM `Document` parsed from `getTemplateData()` HTML (saved-module drop path).
|
|
26
|
-
*/
|
|
27
|
-
export declare function countLiveRecommendationBlocks(root: QueryableRoot): number;
|
|
28
|
-
export {};
|
|
File without changes
|