@useinsider/guido 2.0.0-beta.e73ba15 → 2.0.0-beta.edc1f0a
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/extensions/Blocks/Recommendation/constants/layout.js +9 -4
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +21 -41
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +37 -48
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +80 -39
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +22 -35
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +72 -70
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +71 -84
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +8 -4
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +16 -14
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +27 -16
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
- package/dist/extensions/Blocks/common-control.js +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +1 -5
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
- package/package.json +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
function a(t) {
|
|
2
|
+
return typeof t == "object" && t !== null && "tagName" in t && typeof t.tagName == "string";
|
|
3
|
+
}
|
|
4
|
+
function r(t) {
|
|
5
|
+
return typeof t == "object" && t !== null && "getTagName" in t && typeof t.getTagName == "function";
|
|
6
|
+
}
|
|
7
|
+
function n(t) {
|
|
8
|
+
return typeof t == "object" && t !== null && "getStyle" in t && typeof t.getStyle == "function";
|
|
9
|
+
}
|
|
10
|
+
function u(t) {
|
|
11
|
+
return typeof t == "object" && t !== null && "parent" in t && typeof t.parent == "function";
|
|
12
|
+
}
|
|
13
|
+
function g(t) {
|
|
14
|
+
return typeof t == "object" && t !== null && "tagName" in t && t.tagName === "TD";
|
|
15
|
+
}
|
|
16
|
+
function p(t, e) {
|
|
17
|
+
return !t || !n(t) ? null : t.getStyle(e);
|
|
18
|
+
}
|
|
19
|
+
function N(t) {
|
|
20
|
+
return !t || !u(t) ? null : t.parent();
|
|
21
|
+
}
|
|
22
|
+
function l(t, e = "UNKNOWN") {
|
|
23
|
+
return t ? a(t) ? t.tagName.toUpperCase() : r(t) ? t.getTagName().toUpperCase() : e : e;
|
|
24
|
+
}
|
|
25
|
+
const f = /* @__PURE__ */ new Set(["TD", "BLOCK_IMAGE", "BLOCK_BUTTON"]);
|
|
26
|
+
function i(t) {
|
|
27
|
+
return f.has(t.toUpperCase());
|
|
28
|
+
}
|
|
29
|
+
function c(t) {
|
|
30
|
+
const e = l(t);
|
|
31
|
+
return i(e);
|
|
32
|
+
}
|
|
33
|
+
function s(t) {
|
|
34
|
+
return c(t) ? "table-cell" : "table-row";
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
s as getTableDisplayValue,
|
|
38
|
+
l as getTagName,
|
|
39
|
+
n as hasGetStyle,
|
|
40
|
+
u as hasParent,
|
|
41
|
+
c as isTableCellNode,
|
|
42
|
+
i as isTableCellTag,
|
|
43
|
+
g as isTdNode,
|
|
44
|
+
N as safeGetParent,
|
|
45
|
+
p as safeGetStyle
|
|
46
|
+
};
|
|
@@ -52,7 +52,7 @@ class _ extends O {
|
|
|
52
52
|
const T = o !== this.lastBlockInstanceId;
|
|
53
53
|
return T ? (this.currentNode && e(this.currentNode), n(), this.lastBlockInstanceId = o) : n(), T;
|
|
54
54
|
}
|
|
55
|
-
_GuLabel({ text: e, name: n = "", position: E = "
|
|
55
|
+
_GuLabel({ text: e, name: n = "", position: E = "left" }) {
|
|
56
56
|
return `
|
|
57
57
|
<${t.LABEL}
|
|
58
58
|
style="${E === "top" ? "margin-bottom: 8px;" : ""}"
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
export { RecommendationBlockId } from './blockIds';
|
|
10
10
|
export { RecommendationControlId } from './controlIds';
|
|
11
11
|
export { CONTAINER_SELECTOR, ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT_OLD_PRICE, ATTR_PRODUCT_OMNIBUS_PRICE, ATTR_PRODUCT_OMNIBUS_DISCOUNT, ATTR_PRODUCT_BUTTON, } from './selectors';
|
|
12
|
-
export { DEFAULT_PRODUCTS_PER_ROW, DEFAULT_CARDS_IN_ROW, MAX_PRODUCT_COUNT, MIN_PRODUCT_COUNT, MAX_PRODUCTS_PER_ROW, MIN_PRODUCTS_PER_ROW, } from './layout';
|
|
12
|
+
export { DEFAULT_PRODUCTS_PER_ROW, DEFAULT_CARDS_IN_ROW, MAX_PRODUCT_COUNT, MIN_PRODUCT_COUNT, MAX_PRODUCTS_PER_ROW, MIN_PRODUCTS_PER_ROW, DEFAULT_COLUMN_SPACING, DEFAULT_ROW_SPACING, MIN_SPACING, MAX_SPACING, SPACING_STEP, } from './layout';
|
|
@@ -15,3 +15,13 @@ export declare const MIN_PRODUCT_COUNT = 1;
|
|
|
15
15
|
export declare const MAX_PRODUCTS_PER_ROW = 4;
|
|
16
16
|
/** Minimum number of products per row in vertical layout */
|
|
17
17
|
export declare const MIN_PRODUCTS_PER_ROW = 1;
|
|
18
|
+
/** Default column spacing between product cards (5px on each side = 10px total) */
|
|
19
|
+
export declare const DEFAULT_COLUMN_SPACING = 10;
|
|
20
|
+
/** Default row spacing between product rows */
|
|
21
|
+
export declare const DEFAULT_ROW_SPACING = 20;
|
|
22
|
+
/** Minimum spacing value */
|
|
23
|
+
export declare const MIN_SPACING = 0;
|
|
24
|
+
/** Maximum spacing value */
|
|
25
|
+
export declare const MAX_SPACING = 50;
|
|
26
|
+
/** Spacing adjustment step */
|
|
27
|
+
export declare const SPACING_STEP = 5;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Orientation } from '@@/Types/recommendation';
|
|
2
1
|
import { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
3
2
|
import { CommonControl } from '../../../common-control';
|
|
4
3
|
export declare const CARD_BACKGROUND_COLOR_CONTROL_ID = "recommendation-card-background-color-control";
|
|
@@ -12,15 +11,6 @@ export declare class CardBackgroundColorControl extends CommonControl {
|
|
|
12
11
|
onRender(): void;
|
|
13
12
|
onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
|
|
14
13
|
_setFormValues(): void;
|
|
15
|
-
/**
|
|
16
|
-
* Gets the block element - either currentNode itself or as a descendant
|
|
17
|
-
* The currentNode could BE the block element or contain it
|
|
18
|
-
*/
|
|
19
|
-
_getBlockElement(): ImmutableHtmlNode | null;
|
|
20
|
-
/**
|
|
21
|
-
* Gets the current layout orientation from the block's data attribute
|
|
22
|
-
*/
|
|
23
|
-
_getCurrentLayout(): Orientation;
|
|
24
14
|
/**
|
|
25
15
|
* Gets the appropriate selector based on layout
|
|
26
16
|
* Vertical: .product-card-segment (inner table per product cell)
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* - FiltersControl: Filter selection
|
|
16
16
|
* - ShuffleControl: Product shuffle toggle
|
|
17
17
|
*/
|
|
18
|
+
import { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
18
19
|
import { CommonControl } from '../../../common-control';
|
|
19
20
|
import { AlgorithmControl, ALGORITHM_CONTROL_ID } from './algorithm';
|
|
20
21
|
import { CurrencyControl, CURRENCY_CONTROL_ID } from './currency';
|
|
@@ -41,14 +42,21 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
41
42
|
getId(): string;
|
|
42
43
|
getTemplate(): string;
|
|
43
44
|
onRender(): Promise<void>;
|
|
45
|
+
onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
|
|
44
46
|
onDestroy(): void;
|
|
45
47
|
/**
|
|
46
48
|
* Initialize all sub-controls with the shared API context
|
|
47
49
|
* Each sub-control manages its own form values and event listeners
|
|
48
50
|
*/
|
|
49
51
|
_initializeSubControls(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Debounced product fetch to prevent rapid API calls during config changes
|
|
54
|
+
*/
|
|
55
|
+
private _debouncedFetchProducts;
|
|
50
56
|
/**
|
|
51
57
|
* Listen to store changes that require product refresh
|
|
58
|
+
* Only triggers for meaningful config changes (size, strategy, filters, etc.)
|
|
59
|
+
* Uses debounce to prevent rapid API calls
|
|
52
60
|
*/
|
|
53
61
|
_listenStateUpdates(): void;
|
|
54
62
|
}
|
|
@@ -21,7 +21,6 @@ export declare class ProductLayoutControl extends CommonControl {
|
|
|
21
21
|
onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
|
|
22
22
|
onDestroy(): void;
|
|
23
23
|
_setFormValues(): void;
|
|
24
|
-
_initializeCounterValues(): void;
|
|
25
24
|
/**
|
|
26
25
|
* Updates "Products in One Row" visibility based on layout orientation
|
|
27
26
|
* This control is hidden for horizontal layout (products always take full width)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Orientation } from '@@/Types/recommendation';
|
|
2
1
|
import { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
3
2
|
import { CommonControl } from '../../../common-control';
|
|
4
3
|
export declare const SPACING_CONTROL_ID = "recommendation-spacing-control";
|
|
@@ -14,10 +13,7 @@ export declare class SpacingControl extends CommonControl {
|
|
|
14
13
|
getTemplate(): string;
|
|
15
14
|
onRender(): void;
|
|
16
15
|
onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
|
|
17
|
-
|
|
18
|
-
* Gets the current layout orientation from the block's data attribute
|
|
19
|
-
*/
|
|
20
|
-
_getCurrentLayout(): Orientation;
|
|
16
|
+
onDestroy(): void;
|
|
21
17
|
/**
|
|
22
18
|
* Updates column spacing visibility based on layout orientation
|
|
23
19
|
* Column spacing is hidden for horizontal layout (products are stacked vertically)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Orientation, Languages, Currency, NumericSeparator, FiltersResponse, Filter, RecommendationProduct } from '@@/Types/recommendation';
|
|
2
2
|
interface StoreState {
|
|
3
|
+
/** Maps campaign URLs for recommendation blocks. Used by templateLibraryApi when saving templates. */
|
|
3
4
|
recommendationCampaignUrls: Record<string, string>;
|
|
4
5
|
recommendationConfigs: {
|
|
5
6
|
cardsInRow: number;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node Type Guards and Tag Name Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides type-safe utilities for working with ImmutableHtmlNode.
|
|
5
|
+
* Handles both standard DOM properties and Stripo's custom methods.
|
|
6
|
+
*/
|
|
7
|
+
import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
8
|
+
/** Interface for nodes with standard tagName property */
|
|
9
|
+
interface NodeWithTagName {
|
|
10
|
+
tagName: string;
|
|
11
|
+
}
|
|
12
|
+
/** Interface for nodes with getStyle method */
|
|
13
|
+
export interface NodeWithGetStyle {
|
|
14
|
+
getStyle: (property: string) => string | null | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** Interface for nodes with parent method */
|
|
17
|
+
export interface NodeWithParent {
|
|
18
|
+
parent: () => ImmutableHtmlNode | null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Type guard to check if a node has getStyle method
|
|
22
|
+
* @param node - The node to check
|
|
23
|
+
*/
|
|
24
|
+
export declare function hasGetStyle(node: unknown): node is NodeWithGetStyle;
|
|
25
|
+
/**
|
|
26
|
+
* Type guard to check if a node has parent method
|
|
27
|
+
* @param node - The node to check
|
|
28
|
+
*/
|
|
29
|
+
export declare function hasParent(node: unknown): node is NodeWithParent;
|
|
30
|
+
/**
|
|
31
|
+
* Type guard to check if a node is a TD element
|
|
32
|
+
* @param node - The node to check
|
|
33
|
+
*/
|
|
34
|
+
export declare function isTdNode(node: unknown): node is ImmutableHtmlNode & NodeWithTagName;
|
|
35
|
+
/**
|
|
36
|
+
* Safely retrieves a style value from a node
|
|
37
|
+
* @param node - The node to get the style from
|
|
38
|
+
* @param property - The CSS property name
|
|
39
|
+
* @returns The style value or null if not accessible
|
|
40
|
+
*/
|
|
41
|
+
export declare function safeGetStyle(node: ImmutableHtmlNode | null, property: string): string | null | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Safely retrieves the parent element of a node
|
|
44
|
+
* @param node - The node to get the parent from
|
|
45
|
+
* @returns The parent node or null if not accessible
|
|
46
|
+
*/
|
|
47
|
+
export declare function safeGetParent(node: ImmutableHtmlNode | null): ImmutableHtmlNode | null;
|
|
48
|
+
/**
|
|
49
|
+
* Safely retrieves the tag name from a node.
|
|
50
|
+
* Handles both standard DOM tagName property and Stripo's getTagName() method.
|
|
51
|
+
* @param node - The node to get the tag name from
|
|
52
|
+
* @param defaultValue - Default value if tag name cannot be determined (default: 'UNKNOWN')
|
|
53
|
+
* @returns The uppercase tag name
|
|
54
|
+
*/
|
|
55
|
+
export declare function getTagName(node: ImmutableHtmlNode | null | undefined, defaultValue?: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Checks if a tag name represents a table cell element.
|
|
58
|
+
* Includes standard TD and Stripo's custom block types (BLOCK_IMAGE, BLOCK_BUTTON).
|
|
59
|
+
* @param tagName - The tag name to check (case-insensitive)
|
|
60
|
+
* @returns True if the tag represents a table cell
|
|
61
|
+
*/
|
|
62
|
+
export declare function isTableCellTag(tagName: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Checks if a node is a table cell element.
|
|
65
|
+
* Combines getTagName and isTableCellTag for convenience.
|
|
66
|
+
* @param node - The node to check
|
|
67
|
+
* @returns True if the node is a table cell element
|
|
68
|
+
*/
|
|
69
|
+
export declare function isTableCellNode(node: ImmutableHtmlNode | null | undefined): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Gets the appropriate CSS display value for showing a table element.
|
|
72
|
+
* Table cells use 'table-cell', table rows use 'table-row'.
|
|
73
|
+
* @param node - The table element node
|
|
74
|
+
* @returns The CSS display value ('table-cell' or 'table-row')
|
|
75
|
+
*/
|
|
76
|
+
export declare function getTableDisplayValue(node: ImmutableHtmlNode | null | undefined): 'table-cell' | 'table-row';
|
|
77
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.edc1f0a",
|
|
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",
|