@useinsider/guido 3.1.1-beta.dee5e9c → 3.1.1-beta.e00a22b
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/README.md +1 -0
- package/dist/@types/config/schemas.js +69 -59
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +81 -91
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +7 -7
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +12 -20
- package/dist/components/organisms/header/EditorActions.vue.js +2 -2
- package/dist/components/organisms/header/EditorActions.vue2.js +45 -35
- package/dist/components/organisms/header/RightSlot.vue.js +10 -10
- package/dist/components/organisms/header/RightSlot.vue2.js +16 -13
- package/dist/composables/useHtmlCompiler.js +23 -21
- package/dist/composables/usePreviewMode.js +20 -16
- package/dist/composables/useSave.js +23 -15
- package/dist/composables/useStripo.js +44 -41
- package/dist/composables/validators/useLiquidValidator.js +42 -0
- package/dist/config/compiler/liquidCompilerRules.js +15 -0
- package/dist/config/migrator/checkboxMigrator.js +5 -3
- package/dist/config/migrator/radioButtonMigrator.js +14 -12
- package/dist/extensions/Blocks/CouponBlock/template.js +24 -13
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +27 -11
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +185 -172
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +94 -92
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +31 -31
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +7 -5
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -29
- package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -7
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +3 -1
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +20 -20
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -50
- package/dist/extensions/DynamicContent/dynamic-content.js +17 -12
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +218 -324
- package/dist/package.json.js +1 -1
- package/dist/services/recommendationApi.js +13 -11
- package/dist/src/@types/config/index.d.ts +1 -1
- package/dist/src/@types/config/schemas.d.ts +24 -0
- package/dist/src/@types/config/types.d.ts +3 -1
- package/dist/src/@types/generic.d.ts +0 -1
- package/dist/src/composables/useConfig.d.ts +10 -0
- package/dist/src/composables/validators/useLiquidValidator.d.ts +3 -0
- package/dist/src/config/compiler/liquidCompilerRules.d.ts +2 -0
- package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +20 -3
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +3 -3
- package/dist/src/stores/config.d.ts +90 -0
- package/dist/src/stores/preview.d.ts +3 -0
- package/dist/src/utils/genericUtil.d.ts +1 -1
- package/dist/src/utils/htmlCompiler.d.ts +2 -1
- package/dist/static/styles/base.css.js +2 -7
- package/dist/static/styles/components/button.css.js +7 -13
- package/dist/static/styles/components/narrow-panel.css.js +0 -52
- package/dist/stores/preview.js +4 -3
- package/dist/utils/genericUtil.js +42 -20
- package/dist/utils/htmlCompiler.js +48 -41
- package/dist/utils/templatePreparation.js +20 -20
- package/dist/utils/tooltipUtils.js +4 -5
- package/package.json +5 -4
package/dist/package.json.js
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
import { useHttp as c } from "../composables/useHttp.js";
|
|
2
|
-
import { URLS as
|
|
2
|
+
import { URLS as i } from "../enums/extensions/recommendationBlock.js";
|
|
3
3
|
const f = () => {
|
|
4
|
-
const { get:
|
|
4
|
+
const { get: r } = c(), a = "6KcLM9TwheVB1mgK";
|
|
5
5
|
return {
|
|
6
6
|
fetchRecommendationCreateData: async () => {
|
|
7
7
|
try {
|
|
8
|
-
return (await
|
|
8
|
+
return (await r("/newsletter/recommendations/create-data")).data;
|
|
9
9
|
} catch (e) {
|
|
10
10
|
throw console.error("fetchUserModalState error:", e), e;
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
fetchRecommendationFilters: async () => {
|
|
14
14
|
try {
|
|
15
|
-
const { data: e } = await
|
|
15
|
+
const { data: e } = await r("/stripo/email-recommendation-attributes");
|
|
16
16
|
return e;
|
|
17
17
|
} catch (e) {
|
|
18
18
|
throw console.error("fetchRecommendationFilters error:", e), e;
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
fetchRecommendationProducts: async (e,
|
|
21
|
+
fetchRecommendationProducts: async (e, s) => {
|
|
22
22
|
var n;
|
|
23
23
|
try {
|
|
24
|
-
const t = decodeURIComponent(new URLSearchParams(Object.entries(
|
|
24
|
+
const t = decodeURIComponent(new URLSearchParams(Object.entries(s)).toString());
|
|
25
25
|
console.debug("🏁 Recommendation API Query:", t);
|
|
26
|
-
const { get:
|
|
27
|
-
headers: {
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const { get: m } = c({
|
|
27
|
+
headers: {
|
|
28
|
+
"X-CLIENT-ID": a
|
|
29
|
+
}
|
|
30
|
+
}), o = await m(
|
|
31
|
+
`${i.RECOMMENDATION_API_URL}/v2/${e}?${t}`
|
|
30
32
|
);
|
|
31
|
-
return ((n =
|
|
33
|
+
return ((n = o == null ? void 0 : o.data) == null ? void 0 : n.data) ?? [];
|
|
32
34
|
} catch (t) {
|
|
33
35
|
throw console.error("fetchRecommendationProducts error:", t), t;
|
|
34
36
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - Validation utilities
|
|
9
9
|
*/
|
|
10
10
|
export { MessageType, ProductType, GuidoConfigSchema, IdentitySchema, PartnerSchema, TemplateSchema, EditorSchema, UISchema, FeaturesSchema, BlocksSchema, CompilerSchema, CallbacksSchema, DynamicContentSchema, EmailHeaderSchema, DefaultBlockTypeSchema, CustomBlockTypeSchema, CompilerRuleSchema, CompilerRuleTypeSchema, ReplaceRuleSchema, RegexRuleSchema, RemoveRuleSchema, CustomRuleSchema, } from './schemas';
|
|
11
|
-
export type { GuidoConfig, GuidoConfigInput, IdentityConfig, IdentityConfigInput, PartnerConfig, PartnerConfigInput, TemplateConfig, TemplateConfigInput, EditorConfig, EditorConfigInput, UIConfig, UIConfigInput, FeaturesConfig, FeaturesConfigInput, BlocksConfig, BlocksConfigInput, CompilerConfig, CompilerConfigInput, CallbacksConfig, CallbacksConfigInput, ExternalValidationHandler, EmailHeader, DynamicContent, DefaultBlockType, CustomBlockType, BlockType, FeatureName, CompilerRule, ReplaceRule, RegexRule, RemoveRule, CustomRule, DeepPartial, ConfigOverrides, } from './types';
|
|
11
|
+
export type { GuidoConfig, GuidoConfigInput, IdentityConfig, IdentityConfigInput, PartnerConfig, PartnerConfigInput, FallbackFont, TemplateConfig, TemplateConfigInput, EditorConfig, EditorConfigInput, UIConfig, UIConfigInput, FeaturesConfig, FeaturesConfigInput, BlocksConfig, BlocksConfigInput, CompilerConfig, CompilerConfigInput, CallbacksConfig, CallbacksConfigInput, ExternalValidationHandler, EmailHeader, DynamicContent, DefaultBlockType, CustomBlockType, BlockType, FeatureName, CompilerRule, ReplaceRule, RegexRule, RemoveRule, CustomRule, DeepPartial, ConfigOverrides, } from './types';
|
|
12
12
|
export { DEFAULT_EMAIL_HEADER, DEFAULT_TEMPLATE, DEFAULT_EDITOR, DEFAULT_UI, DEFAULT_FEATURES, DEFAULT_BLOCKS, DEFAULT_COMPILER, DEFAULT_PRODUCT_TYPE, DEFAULT_MESSAGE_TYPE, DEFAULT_USERNAME, EDITOR_TYPE, TEST_PARTNERS, isTestPartner, } from './defaults';
|
|
13
13
|
export { validateConfig, parseConfig, parseConfigSafe, getValidationErrors, isValidConfig, validateIdentity, validatePartner, } from './validator';
|
|
14
14
|
export type { ValidationResult, ValidationError, } from './validator';
|
|
@@ -47,6 +47,12 @@ export declare const IdentitySchema: v.ObjectSchema<{
|
|
|
47
47
|
/**
|
|
48
48
|
* Partner configuration - organization and product context
|
|
49
49
|
*/
|
|
50
|
+
export declare const FallbackFontSchema: v.ObjectSchema<{
|
|
51
|
+
/** Fallback font name (e.g., "Georgia") */
|
|
52
|
+
readonly name: v.StringSchema<undefined>;
|
|
53
|
+
/** Fallback font family (e.g., "serif" or "sans-serif") */
|
|
54
|
+
readonly family: v.StringSchema<undefined>;
|
|
55
|
+
}, undefined>;
|
|
50
56
|
export declare const PartnerSchema: v.ObjectSchema<{
|
|
51
57
|
/** Partner/organization name (required) */
|
|
52
58
|
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "partner.name is required">]>;
|
|
@@ -56,6 +62,13 @@ export declare const PartnerSchema: v.ObjectSchema<{
|
|
|
56
62
|
readonly messageType: v.OptionalSchema<v.PicklistSchema<[1, 2], undefined>, 1>;
|
|
57
63
|
/** Display name for the current user */
|
|
58
64
|
readonly username: v.OptionalSchema<v.StringSchema<undefined>, "Guido User">;
|
|
65
|
+
/** Fallback font settings from partner settings — used to match backend size calculation */
|
|
66
|
+
readonly fallbackFont: v.OptionalSchema<v.ObjectSchema<{
|
|
67
|
+
/** Fallback font name (e.g., "Georgia") */
|
|
68
|
+
readonly name: v.StringSchema<undefined>;
|
|
69
|
+
/** Fallback font family (e.g., "serif" or "sans-serif") */
|
|
70
|
+
readonly family: v.StringSchema<undefined>;
|
|
71
|
+
}, undefined>, undefined>;
|
|
59
72
|
}, undefined>;
|
|
60
73
|
/**
|
|
61
74
|
* Dynamic content item schema
|
|
@@ -163,6 +176,8 @@ export declare const FeaturesSchema: v.ObjectSchema<{
|
|
|
163
176
|
readonly unsubscribe: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
164
177
|
/** Disable modules panel in the editor */
|
|
165
178
|
readonly modulesDisabled: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
179
|
+
/** Enable Liquid template syntax */
|
|
180
|
+
readonly liquidSyntax: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
166
181
|
}, undefined>;
|
|
167
182
|
/**
|
|
168
183
|
* Default block types available in Stripo
|
|
@@ -403,6 +418,13 @@ export declare const GuidoConfigSchema: v.ObjectSchema<{
|
|
|
403
418
|
readonly messageType: v.OptionalSchema<v.PicklistSchema<[1, 2], undefined>, 1>;
|
|
404
419
|
/** Display name for the current user */
|
|
405
420
|
readonly username: v.OptionalSchema<v.StringSchema<undefined>, "Guido User">;
|
|
421
|
+
/** Fallback font settings from partner settings — used to match backend size calculation */
|
|
422
|
+
readonly fallbackFont: v.OptionalSchema<v.ObjectSchema<{
|
|
423
|
+
/** Fallback font name (e.g., "Georgia") */
|
|
424
|
+
readonly name: v.StringSchema<undefined>;
|
|
425
|
+
/** Fallback font family (e.g., "serif" or "sans-serif") */
|
|
426
|
+
readonly family: v.StringSchema<undefined>;
|
|
427
|
+
}, undefined>, undefined>;
|
|
406
428
|
}, undefined>;
|
|
407
429
|
/** Template content and presets */
|
|
408
430
|
readonly template: v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -477,6 +499,8 @@ export declare const GuidoConfigSchema: v.ObjectSchema<{
|
|
|
477
499
|
readonly unsubscribe: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
478
500
|
/** Disable modules panel in the editor */
|
|
479
501
|
readonly modulesDisabled: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
502
|
+
/** Enable Liquid template syntax */
|
|
503
|
+
readonly liquidSyntax: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
480
504
|
}, undefined>, {}>;
|
|
481
505
|
/** Block configuration */
|
|
482
506
|
readonly blocks: v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* This ensures type definitions are always in sync with validation.
|
|
6
6
|
* @module @types/config/types
|
|
7
7
|
*/
|
|
8
|
-
import type { GuidoConfigSchema, IdentitySchema, PartnerSchema, TemplateSchema, EditorSchema, UISchema, FeaturesSchema, BlocksSchema, CompilerSchema, CallbacksSchema, DynamicContentSchema, EmailHeaderSchema, CompilerRuleSchema, ReplaceRuleSchema, RegexRuleSchema, RemoveRuleSchema, CustomRuleSchema, DefaultBlockTypeSchema, CustomBlockTypeSchema, ExternalValidationHandler } from './schemas';
|
|
8
|
+
import type { GuidoConfigSchema, IdentitySchema, PartnerSchema, TemplateSchema, EditorSchema, UISchema, FeaturesSchema, BlocksSchema, CompilerSchema, CallbacksSchema, DynamicContentSchema, EmailHeaderSchema, CompilerRuleSchema, ReplaceRuleSchema, RegexRuleSchema, RemoveRuleSchema, CustomRuleSchema, DefaultBlockTypeSchema, CustomBlockTypeSchema, FallbackFontSchema, ExternalValidationHandler } from './schemas';
|
|
9
9
|
import type * as v from 'valibot';
|
|
10
10
|
/**
|
|
11
11
|
* Complete validated Guido configuration.
|
|
@@ -29,6 +29,8 @@ export type GuidoConfig = v.InferOutput<typeof GuidoConfigSchema>;
|
|
|
29
29
|
export type IdentityConfig = v.InferOutput<typeof IdentitySchema>;
|
|
30
30
|
/** Partner configuration (name, productType, messageType, username) */
|
|
31
31
|
export type PartnerConfig = v.InferOutput<typeof PartnerSchema>;
|
|
32
|
+
/** Fallback font settings for backend size calculation alignment */
|
|
33
|
+
export type FallbackFont = v.InferOutput<typeof FallbackFontSchema>;
|
|
32
34
|
/** Template configuration (html, css, dynamic content, unsubscribe pages) */
|
|
33
35
|
export type TemplateConfig = v.InferOutput<typeof TemplateSchema>;
|
|
34
36
|
/** Editor configuration (locale, translations, migration date, email header) */
|
|
@@ -17,6 +17,10 @@ export declare const useConfig: () => {
|
|
|
17
17
|
productType: 60 | 49 | 97;
|
|
18
18
|
messageType: 1 | 2;
|
|
19
19
|
username: string;
|
|
20
|
+
fallbackFont?: {
|
|
21
|
+
name: string;
|
|
22
|
+
family: string;
|
|
23
|
+
} | undefined;
|
|
20
24
|
};
|
|
21
25
|
template: {
|
|
22
26
|
html: string;
|
|
@@ -57,6 +61,7 @@ export declare const useConfig: () => {
|
|
|
57
61
|
displayConditions: boolean;
|
|
58
62
|
unsubscribe: boolean;
|
|
59
63
|
modulesDisabled: boolean;
|
|
64
|
+
liquidSyntax: boolean;
|
|
60
65
|
};
|
|
61
66
|
blocks: {
|
|
62
67
|
excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
|
|
@@ -109,6 +114,10 @@ export declare const useConfig: () => {
|
|
|
109
114
|
productType: 60 | 49 | 97;
|
|
110
115
|
messageType: 1 | 2;
|
|
111
116
|
username: string;
|
|
117
|
+
fallbackFont?: {
|
|
118
|
+
name: string;
|
|
119
|
+
family: string;
|
|
120
|
+
} | undefined;
|
|
112
121
|
} | null>;
|
|
113
122
|
template: import("vue").ComputedRef<{
|
|
114
123
|
html: string;
|
|
@@ -149,6 +158,7 @@ export declare const useConfig: () => {
|
|
|
149
158
|
displayConditions: boolean;
|
|
150
159
|
unsubscribe: boolean;
|
|
151
160
|
modulesDisabled: boolean;
|
|
161
|
+
liquidSyntax: boolean;
|
|
152
162
|
} | null>;
|
|
153
163
|
blocks: import("vue").ComputedRef<{
|
|
154
164
|
excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare const COUPON_PLACEHOLDER_DEFAULT = "{@COUPON_CODE}";
|
|
2
|
+
export declare const COUPON_PLACEHOLDER_LIQUID = "{{ins_coupon_code}}";
|
|
1
3
|
declare const migrationTemplate = "\n <td\n class=\"coupon-block coupon-block-v2 ins-coupon-code esd-block-text esd-extension-block\"\n esd-extension-block-id=\"coupon-block\"\n >\n <p class=\"ins-title\" contenteditable=\"false\">{@COUPON_CODE}</p>\n </td>\n";
|
|
2
4
|
export declare function getDefaultTemplate(): string;
|
|
3
5
|
export default migrationTemplate;
|
|
@@ -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, 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, } from './selectors';
|
|
11
|
+
export { BLOCK_ROOT_SELECTOR, CONTAINER_SELECTOR, DESKTOP_CONTAINER_SELECTOR, MOBILE_CONTAINER_SELECTOR, MOBILE_ROW_SELECTOR, 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';
|
|
@@ -50,3 +50,8 @@ export declare const ATTR_CUSTOM_PREFIX = "customAttr:";
|
|
|
50
50
|
export declare const ATTR_DATA_CUSTOM_ATTRIBUTES = "data-custom-attributes";
|
|
51
51
|
/** HTML attribute on <td> elements identifying the product attribute for compiler template variable generation */
|
|
52
52
|
export declare const ATTR_PRODUCT_ATTR = "product-attr";
|
|
53
|
+
/**
|
|
54
|
+
* Default attribute names that are already represented by built-in composition toggle items.
|
|
55
|
+
* Used to exclude these from the custom attribute dropdown to prevent duplication with toggles.
|
|
56
|
+
*/
|
|
57
|
+
export declare const BUILT_IN_DEFAULT_ATTRIBUTES: Set<string>;
|
|
@@ -170,6 +170,11 @@ export declare class RecommendationCardCompositionControl extends CommonControl
|
|
|
170
170
|
* When filterList changes (e.g. after async fetch), re-renders dropdowns with new options.
|
|
171
171
|
*/
|
|
172
172
|
private _subscribeToStoreChanges;
|
|
173
|
+
/**
|
|
174
|
+
* Returns filters eligible for the custom attribute dropdown,
|
|
175
|
+
* excluding default attributes already covered by built-in toggle items.
|
|
176
|
+
*/
|
|
177
|
+
private _getAddableFilters;
|
|
173
178
|
/**
|
|
174
179
|
* Looks up the display name for an attribute from the store's filterList.
|
|
175
180
|
* Falls back to Title Case conversion of the snake_case attribute name.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RecommendationProduct } from '@@/Types/recommendation';
|
|
1
|
+
import type { FiltersResponse, RecommendationProduct } from '@@/Types/recommendation';
|
|
2
2
|
import { type ElementRenderer } from '../utils';
|
|
3
3
|
/**
|
|
4
4
|
* Generates attribute-aligned product rows for grid layout.
|
|
@@ -9,7 +9,7 @@ import { type ElementRenderer } from '../utils';
|
|
|
9
9
|
* @param composition - Array defining order of card elements
|
|
10
10
|
* @returns HTML string for attribute-aligned rows
|
|
11
11
|
*/
|
|
12
|
-
export declare function prepareGridAttributeRows(products: RecommendationProduct[], productsPerRow: number, elementRenderer: ElementRenderer, composition?: string[]): string;
|
|
12
|
+
export declare function prepareGridAttributeRows(products: RecommendationProduct[], productsPerRow: number, elementRenderer: ElementRenderer, composition?: string[], filterList?: FiltersResponse): string;
|
|
13
13
|
/**
|
|
14
14
|
* Prepares grid product rows with attribute-aligned structure
|
|
15
15
|
* Groups products into rows, then generates attribute-aligned HTML for each group
|
|
@@ -19,7 +19,7 @@ export declare function prepareGridAttributeRows(products: RecommendationProduct
|
|
|
19
19
|
* @param composition - Array defining order of card elements
|
|
20
20
|
* @returns HTML string for all product rows
|
|
21
21
|
*/
|
|
22
|
-
export declare function prepareGridProductRows(products: RecommendationProduct[], productsPerRow: number, elementRenderer: ElementRenderer, composition?: string[]): string;
|
|
22
|
+
export declare function prepareGridProductRows(products: RecommendationProduct[], productsPerRow: number, elementRenderer: ElementRenderer, composition?: string[], filterList?: FiltersResponse): string;
|
|
23
23
|
/**
|
|
24
24
|
* Prepares grid product rows with attribute-aligned structure.
|
|
25
25
|
* Uses row-based rendering where each attribute type forms a single row across all products.
|
|
@@ -28,6 +28,6 @@ export declare function prepareGridProductRows(products: RecommendationProduct[]
|
|
|
28
28
|
* @param composition - Array defining element order
|
|
29
29
|
* @returns HTML string for product rows
|
|
30
30
|
*/
|
|
31
|
-
export declare function prepareProductRows(products: RecommendationProduct[], productsPerRow: number, composition?: string[]): string;
|
|
31
|
+
export declare function prepareProductRows(products: RecommendationProduct[], productsPerRow: number, composition?: string[], filterList?: FiltersResponse): string;
|
|
32
32
|
export declare function getDefaultTemplate(recommendationId?: number): string;
|
|
33
33
|
export declare function generateBlockTemplate(products: RecommendationProduct[], productsPerRow: number, title?: string, composition?: string[], mobileProductsPerRow?: number): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RecommendationProduct } from '@@/Types/recommendation';
|
|
1
|
+
import type { FiltersResponse, RecommendationProduct } from '@@/Types/recommendation';
|
|
2
2
|
/**
|
|
3
3
|
* Generates a list product card with 3-column layout
|
|
4
4
|
* Uses buildElementRenderer to render Image, Info content, and Button
|
|
@@ -11,7 +11,7 @@ import type { RecommendationProduct } from '@@/Types/recommendation';
|
|
|
11
11
|
* @param composition - Array defining order of card elements
|
|
12
12
|
* @returns HTML string for a single product card row
|
|
13
13
|
*/
|
|
14
|
-
export declare function getListProductCard(product: RecommendationProduct, composition?: string[]): string;
|
|
14
|
+
export declare function getListProductCard(product: RecommendationProduct, composition?: string[], filterList?: FiltersResponse): string;
|
|
15
15
|
/**
|
|
16
16
|
* Prepares list product rows
|
|
17
17
|
* Each product is a full-width row with 3-column layout
|
|
@@ -19,6 +19,6 @@ export declare function getListProductCard(product: RecommendationProduct, compo
|
|
|
19
19
|
* @param composition - Array defining order of card elements
|
|
20
20
|
* @returns HTML string for product rows
|
|
21
21
|
*/
|
|
22
|
-
export declare function prepareProductRows(products: RecommendationProduct[], composition?: string[]): string;
|
|
22
|
+
export declare function prepareProductRows(products: RecommendationProduct[], composition?: string[], filterList?: FiltersResponse): string;
|
|
23
23
|
export declare function getDefaultTemplate(): string;
|
|
24
24
|
export declare function generateBlockTemplate(products: RecommendationProduct[], title?: string, composition?: string[]): string;
|
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
import type { RecommendationProduct } from '@@/Types/recommendation';
|
|
1
|
+
import type { FiltersResponse, RecommendationProduct } from '@@/Types/recommendation';
|
|
2
2
|
import { 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 '../constants';
|
|
3
3
|
/**
|
|
4
4
|
* Converts a snake_case attribute name to Title Case display name.
|
|
5
5
|
* e.g., "rating_star" → "Rating Star"
|
|
6
6
|
*/
|
|
7
7
|
export declare function toDisplayName(attrName: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Checks whether an attribute is a default (top-level) product attribute
|
|
10
|
+
* vs a custom product attribute (nested under `product_attributes`).
|
|
11
|
+
* Returns false when filterList is empty or the attribute is not found.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isDefaultAttribute(attrName: string, filterList: FiltersResponse): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the `product-attr` HTML attribute value based on attribute type from the filter list.
|
|
16
|
+
* - Default attributes → attribute name directly (e.g., "brand") → compiles to `{{1_0_brand}}`
|
|
17
|
+
* - Product attributes → "product_attribute.<name>" (e.g., "product_attribute.rating_star")
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveProductAttrValue(attrName: string, filterList: FiltersResponse): string;
|
|
8
20
|
/**
|
|
9
21
|
* Callback that generates the cell HTML for a custom product attribute.
|
|
10
22
|
* Layout-specific: grid returns `<td>…`, list returns `<tr><td>…</td></tr>`.
|
|
23
|
+
* @param productAttrValue - The resolved `product-attr` value (e.g., "brand" or "product_attribute.rating_star")
|
|
24
|
+
* @param content - The display content for the cell
|
|
11
25
|
*/
|
|
12
|
-
export type CustomCellHtmlGetter = (
|
|
26
|
+
export type CustomCellHtmlGetter = (productAttrValue: string, content: string) => string;
|
|
13
27
|
/**
|
|
14
28
|
* Symbol key for embedding custom attribute HTML in an ElementRenderer.
|
|
15
29
|
* Grid and list renderers store their custom-attribute cell template under this key
|
|
@@ -28,8 +42,9 @@ export declare const CUSTOM_CELL_HTML: unique symbol;
|
|
|
28
42
|
* alongside built-in ones, so template code can use a uniform lookup for all attributes.
|
|
29
43
|
* @param baseRenderer - The built-in element renderer (grid or list), must include a [CUSTOM_CELL_HTML] entry
|
|
30
44
|
* @param composition - Array of attribute keys including `customAttr:*` entries
|
|
45
|
+
* @param filterList - Filter list from the store, used to determine attribute type for correct product-attr resolution
|
|
31
46
|
*/
|
|
32
|
-
export declare function buildElementRenderer(baseRenderer: ElementRenderer, composition: string[]): ElementRenderer;
|
|
47
|
+
export declare function buildElementRenderer(baseRenderer: ElementRenderer, composition: string[], filterList?: FiltersResponse): ElementRenderer;
|
|
33
48
|
export type Orientation = 'list' | 'grid';
|
|
34
49
|
/**
|
|
35
50
|
* Options for prepareProductRows unified function
|
|
@@ -41,6 +56,8 @@ export interface PrepareProductRowsOptions {
|
|
|
41
56
|
mobileProductsPerRow?: number;
|
|
42
57
|
/** Array defining order of card elements */
|
|
43
58
|
composition?: string[];
|
|
59
|
+
/** Filter list for attribute type resolution (default vs product attributes) */
|
|
60
|
+
filterList?: FiltersResponse;
|
|
44
61
|
}
|
|
45
62
|
/**
|
|
46
63
|
* Element renderer interface for product card elements.
|
|
@@ -15,7 +15,7 @@ export interface NodeWithGetStyle {
|
|
|
15
15
|
}
|
|
16
16
|
/** Interface for nodes with parent method */
|
|
17
17
|
export interface NodeWithParent {
|
|
18
|
-
parent: () => ImmutableHtmlNode |
|
|
18
|
+
parent: () => ImmutableHtmlNode | null;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Type guard to check if a node has getStyle method
|
|
@@ -38,13 +38,13 @@ export declare function isTdNode(node: unknown): node is ImmutableHtmlNode & Nod
|
|
|
38
38
|
* @param property - The CSS property name
|
|
39
39
|
* @returns The style value or null if not accessible
|
|
40
40
|
*/
|
|
41
|
-
export declare function safeGetStyle(node: ImmutableHtmlNode | null
|
|
41
|
+
export declare function safeGetStyle(node: ImmutableHtmlNode | null, property: string): string | null | undefined;
|
|
42
42
|
/**
|
|
43
43
|
* Safely retrieves the parent element of a node
|
|
44
44
|
* @param node - The node to get the parent from
|
|
45
45
|
* @returns The parent node or null if not accessible
|
|
46
46
|
*/
|
|
47
|
-
export declare function safeGetParent(node: ImmutableHtmlNode | null
|
|
47
|
+
export declare function safeGetParent(node: ImmutableHtmlNode | null): ImmutableHtmlNode | null;
|
|
48
48
|
/**
|
|
49
49
|
* Safely retrieves the tag name from a node.
|
|
50
50
|
* Handles both standard DOM tagName property and Stripo's getTagName() method.
|