@useinsider/guido 3.0.0-beta.e99f1c8 → 3.0.0-beta.f195a1b

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.
Files changed (65) hide show
  1. package/dist/components/organisms/header/EditorActions.vue.js +10 -8
  2. package/dist/components/organisms/header/EditorActions.vue2.js +40 -30
  3. package/dist/components/organisms/header/MigrationConfirmModal.vue.js +17 -0
  4. package/dist/components/organisms/header/MigrationConfirmModal.vue2.js +39 -0
  5. package/dist/config/compiler/utils/recommendationCompilerUtils.js +29 -18
  6. package/dist/config/i18n/en/labels.json.js +8 -3
  7. package/dist/config/migrator/itemsBlockMigrator.js +135 -131
  8. package/dist/config/migrator/recommendationMigrator.js +58 -54
  9. package/dist/enums/block.js +4 -0
  10. package/dist/extensions/Blocks/Items/block.js +30 -21
  11. package/dist/extensions/Blocks/Items/iconsRegistry.js +7 -6
  12. package/dist/extensions/Blocks/Items/items.css.js +48 -0
  13. package/dist/extensions/Blocks/Recommendation/block.js +22 -13
  14. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +1 -1
  15. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  16. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +15 -12
  17. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +693 -144
  18. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +78 -0
  19. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +27 -24
  20. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +134 -126
  21. package/dist/extensions/Blocks/Recommendation/extension.js +18 -16
  22. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +5 -4
  23. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +174 -2
  24. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +124 -106
  25. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +8 -7
  26. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +63 -34
  27. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -33
  28. package/dist/extensions/Blocks/Recommendation/templates/index.js +8 -8
  29. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +28 -13
  30. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +25 -44
  31. package/dist/extensions/Blocks/Recommendation/templates/utils.js +62 -38
  32. package/dist/extensions/Blocks/common-control.js +12 -4
  33. package/dist/guido.css +1 -1
  34. package/dist/src/@types/extensions/block.d.ts +2 -0
  35. package/dist/src/App.vue.d.ts +3 -1
  36. package/dist/src/components/Guido.vue.d.ts +1 -1
  37. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
  38. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
  39. package/dist/src/components/organisms/header/MigrationConfirmModal.vue.d.ts +6 -0
  40. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
  41. package/dist/src/components/wrappers/WpModal.vue.d.ts +2 -2
  42. package/dist/src/enums/block.d.ts +4 -0
  43. package/dist/src/extensions/Blocks/Items/block.d.ts +3 -1
  44. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +3 -1
  45. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +2 -1
  46. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +8 -1
  47. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  48. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +10 -0
  49. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +134 -44
  50. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +105 -0
  51. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -0
  52. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +2 -0
  53. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
  54. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +1 -1
  55. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +1 -1
  56. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +10 -4
  57. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +37 -2
  58. package/dist/src/extensions/Blocks/common-control.d.ts +5 -0
  59. package/dist/src/stores/template.d.ts +29 -0
  60. package/dist/src/utils/migrationBannerHtml.d.ts +2 -0
  61. package/dist/static/assets/info.svg.js +5 -0
  62. package/dist/static/styles/variables.css.js +3 -0
  63. package/dist/stores/template.js +15 -0
  64. package/dist/utils/migrationBannerHtml.js +21 -0
  65. package/package.json +3 -2
@@ -1,18 +1,24 @@
1
1
  import type { RecommendationProduct } from '@@/Types/recommendation';
2
2
  /**
3
3
  * Generates a list product card with 3-column layout
4
- * Uses listElementRenderer to render Image, Info content, and Button
4
+ * Uses buildElementRenderer to render Image, Info content, and Button
5
5
  * Layout: [Image (120px)] [Info table (flexible)] [Button (100px)]
6
+ *
7
+ * The info cell rows are built dynamically from the composition array,
8
+ * supporting both built-in attributes and custom product attributes.
9
+ * Image and Button are always separate columns (not in the info cell).
6
10
  * @param product - The product data
11
+ * @param composition - Array defining order of card elements
7
12
  * @returns HTML string for a single product card row
8
13
  */
9
- export declare function getListProductCard(product: RecommendationProduct): string;
14
+ export declare function getListProductCard(product: RecommendationProduct, composition?: string[]): string;
10
15
  /**
11
16
  * Prepares list product rows
12
17
  * Each product is a full-width row with 3-column layout
13
18
  * @param products - Array of products to display
19
+ * @param composition - Array defining order of card elements
14
20
  * @returns HTML string for product rows
15
21
  */
16
- export declare function prepareProductRows(products: RecommendationProduct[]): string;
22
+ export declare function prepareProductRows(products: RecommendationProduct[], composition?: string[]): string;
17
23
  export declare function getDefaultTemplate(): string;
18
- export declare function generateBlockTemplate(products: RecommendationProduct[], title?: string): string;
24
+ export declare function generateBlockTemplate(products: RecommendationProduct[], title?: string, composition?: string[]): string;
@@ -1,5 +1,35 @@
1
1
  import type { 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
+ /**
4
+ * Converts a snake_case attribute name to Title Case display name.
5
+ * e.g., "rating_star" → "Rating Star"
6
+ */
7
+ export declare function toDisplayName(attrName: string): string;
8
+ /**
9
+ * Callback that generates the cell HTML for a custom product attribute.
10
+ * Layout-specific: grid returns `<td>…`, list returns `<tr><td>…</td></tr>`.
11
+ */
12
+ export type CustomCellHtmlGetter = (attrName: string, content: string) => string;
13
+ /**
14
+ * Symbol key for embedding custom attribute HTML in an ElementRenderer.
15
+ * Grid and list renderers store their custom-attribute cell template under this key
16
+ * so that `buildElementRenderer` can read it without a separate callback parameter.
17
+ *
18
+ * Using a Symbol avoids conflicts with the string index signature — call sites that
19
+ * access `renderer[stringKey]` always get `(product) => string` without type narrowing.
20
+ */
21
+ export declare const CUSTOM_CELL_HTML: unique symbol;
22
+ /**
23
+ * Extends a base element renderer with custom attribute entries from the composition.
24
+ * Each `customAttr:<name>` key in the composition gets a renderer closure that calls
25
+ * the layout-specific custom cell HTML getter stored in `baseRenderer[CUSTOM_CELL_HTML]`.
26
+ *
27
+ * This ensures that custom attribute renderers live inside the ElementRenderer object
28
+ * alongside built-in ones, so template code can use a uniform lookup for all attributes.
29
+ * @param baseRenderer - The built-in element renderer (grid or list), must include a [CUSTOM_CELL_HTML] entry
30
+ * @param composition - Array of attribute keys including `customAttr:*` entries
31
+ */
32
+ export declare function buildElementRenderer(baseRenderer: ElementRenderer, composition: string[]): ElementRenderer;
3
33
  export type Orientation = 'list' | 'grid';
4
34
  /**
5
35
  * Options for prepareProductRows unified function
@@ -13,8 +43,11 @@ export interface PrepareProductRowsOptions {
13
43
  composition?: string[];
14
44
  }
15
45
  /**
16
- * Element renderer interface for product card elements
17
- * Keys are ATTR_PRODUCT_* constants for consistent naming
46
+ * Element renderer interface for product card elements.
47
+ * Keys are ATTR_PRODUCT_* constants for built-in elements.
48
+ * The index signature allows dynamic custom attribute keys (e.g., "customAttr:rating_star").
49
+ * The Symbol-keyed [CUSTOM_CELL_HTML] entry stores the layout-specific HTML template
50
+ * for custom attributes — used by `buildElementRenderer` to create custom entries.
18
51
  */
19
52
  export interface ElementRenderer {
20
53
  [ATTR_PRODUCT_IMAGE]: (product: RecommendationProduct) => string;
@@ -24,6 +57,8 @@ export interface ElementRenderer {
24
57
  [ATTR_PRODUCT_OMNIBUS_PRICE]: (product: RecommendationProduct) => string;
25
58
  [ATTR_PRODUCT_OMNIBUS_DISCOUNT]: (product: RecommendationProduct) => string;
26
59
  [ATTR_PRODUCT_BUTTON]: (product: RecommendationProduct) => string;
60
+ [CUSTOM_CELL_HTML]?: CustomCellHtmlGetter;
61
+ [key: string]: (product: RecommendationProduct) => string;
27
62
  }
28
63
  /**
29
64
  * Product card getter function type
@@ -11,6 +11,10 @@ interface LabelProps {
11
11
  name?: string;
12
12
  position?: 'top' | 'left';
13
13
  }
14
+ interface IconProps {
15
+ src: string;
16
+ className?: string;
17
+ }
14
18
  interface IconButtonProps {
15
19
  name: string;
16
20
  icon: string;
@@ -89,6 +93,7 @@ export declare abstract class CommonControl extends Control {
89
93
  }): string;
90
94
  _GuRadioButton({ name, buttons, id }: RadioButtonProps): string;
91
95
  _GuButton({ name, label, id }: ButtonProps): string;
96
+ _GuIcon({ src, className }: IconProps): string;
92
97
  /**
93
98
  *
94
99
  * @param param0
@@ -0,0 +1,29 @@
1
+ import type { BlockId } from '@@/Types/extensions/block';
2
+ export declare const useTemplateStore: import("pinia").StoreDefinition<"guidoTemplate", {
3
+ migrations: Partial<Record<BlockId, number>>;
4
+ }, {
5
+ hasMigrations: (state: {
6
+ migrations: {
7
+ "recommendation-block"?: number | undefined;
8
+ "items-block"?: number | undefined;
9
+ };
10
+ } & import("pinia").PiniaCustomStateProperties<{
11
+ migrations: Partial<Record<BlockId, number>>;
12
+ }>) => boolean;
13
+ hasRecommendationMigrations: (state: {
14
+ migrations: {
15
+ "recommendation-block"?: number | undefined;
16
+ "items-block"?: number | undefined;
17
+ };
18
+ } & import("pinia").PiniaCustomStateProperties<{
19
+ migrations: Partial<Record<BlockId, number>>;
20
+ }>) => boolean;
21
+ hasItemsMigrations: (state: {
22
+ migrations: {
23
+ "recommendation-block"?: number | undefined;
24
+ "items-block"?: number | undefined;
25
+ };
26
+ } & import("pinia").PiniaCustomStateProperties<{
27
+ migrations: Partial<Record<BlockId, number>>;
28
+ }>) => boolean;
29
+ }, {}>;
@@ -0,0 +1,2 @@
1
+ import type { BlockId } from '@@/Types/extensions/block';
2
+ export declare function getMigrationBannerHtml(blockId: BlockId, blockName: string, infoText: string): string;
@@ -0,0 +1,5 @@
1
+ const a = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"><g transform="translate(3, 2.5)"><path fill="#258DDE" d="M6.878.142c3.91-.723 7.802 1.369 9.323 5.022 1.533 3.683.231 7.927-3.11 10.138a8.47 8.47 0 0 1-10.563-.983l-.067-.065A8.318 8.318 0 0 1 0 8.343V8.25C.05 4.305 2.878.927 6.787.16l.092-.018Zm7.713 5.682c-1.216-2.92-4.342-4.582-7.467-3.97-3.125.614-5.378 3.331-5.382 6.491a6.597 6.597 0 0 0 1.952 4.688 6.718 6.718 0 0 0 8.43.83 6.595 6.595 0 0 0 2.467-8.039Z"/><path fill="#258DDE" d="M12.52 13.58a.876.876 0 0 1 1.215-.017l.016.015 3.993 3.946a.86.86 0 0 1 .002 1.222.876.876 0 0 1-1.232.002l-3.992-3.946-.016-.015a.86.86 0 0 1 .014-1.206ZM6.713 5.43a.876.876 0 0 0-1.232 0 .86.86 0 0 0 0 1.221l1.232-1.222Zm1.09 3.525a.876.876 0 0 0 1.232 0 .86.86 0 0 0 0-1.222L7.804 8.955Zm1.232-1.222a.876.876 0 0 0-1.231 0 .86.86 0 0 0 0 1.222l1.231-1.222Zm1.091 3.526a.876.876 0 0 0 1.232 0 .86.86 0 0 0 0-1.222l-1.232 1.222Zm-1.09-2.304a.86.86 0 0 0 0-1.222.876.876 0 0 0-1.232 0l1.231 1.222ZM5.48 10.037a.86.86 0 0 0 0 1.222.876.876 0 0 0 1.232 0L5.48 10.037Zm2.323-2.304a.86.86 0 0 0 0 1.222.876.876 0 0 0 1.231 0L7.804 7.733Zm3.554-1.082a.86.86 0 0 0 0-1.222.876.876 0 0 0-1.232 0l1.232 1.222Zm-5.877 0 2.323 2.304 1.231-1.222L6.713 5.43 5.48 6.651Zm2.323 2.304 2.322 2.304 1.232-1.222-2.323-2.304-1.231 1.222Zm0-1.222L5.48 10.037l1.232 1.222 2.322-2.304-1.231-1.222Zm1.231 1.222 2.323-2.304-1.232-1.222-2.322 2.304 1.231 1.222Z"/></g></svg>
2
+ `;
3
+ export {
4
+ a as default
5
+ };
@@ -3,10 +3,13 @@ const o = `:host {
3
3
  --guido-color-primary-500: #0A2ECC;
4
4
  --guido-color-primary-200: #B5C1F1;
5
5
  --guido-color-primary-100: #DAE1FB;
6
+ --guido-color-primary-0: #F1F3FE;
6
7
  --guido-color-gray-800: #292929;
7
8
  --guido-color-gray-700: #989898;
8
9
  --guido-color-gray-600: #666666;
10
+ --guido-color-gray-500: #989898;
9
11
  --guido-color-gray-300: #E1E1E1;
12
+ --guido-color-gray-100: #F5F5F5;
10
13
  --guido-color-gray-1: #F0F0F0;
11
14
  --guido-color-gray-0: #F9F9F9;
12
15
  --guido-color-neutral-800: #222938;
@@ -0,0 +1,15 @@
1
+ import { BlockId as e } from "../enums/block.js";
2
+ import { defineStore as i } from "pinia";
3
+ const a = i("guidoTemplate", {
4
+ state: () => ({
5
+ migrations: {}
6
+ }),
7
+ getters: {
8
+ hasMigrations: (t) => Object.values(t.migrations).some((o) => (o ?? 0) > 0),
9
+ hasRecommendationMigrations: (t) => (t.migrations[e.Recommendation] ?? 0) > 0,
10
+ hasItemsMigrations: (t) => (t.migrations[e.Items] ?? 0) > 0
11
+ }
12
+ });
13
+ export {
14
+ a as useTemplateStore
15
+ };
@@ -0,0 +1,21 @@
1
+ import { useTemplateStore as o } from "../stores/template.js";
2
+ import { UIElementType as i, UEAttr as r } from "../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
+ function g(t, n, e) {
4
+ return (o().migrations[t] ?? 0) <= 0 ? "" : `<div>
5
+ <div style="display: flex; align-items: center;">
6
+ <span>${n}</span>
7
+ </div>
8
+ <div class="${t}-migration-info">
9
+ <${i.ICON}
10
+ ${r.ICON.src}="migration-info-icon"
11
+ class="${t}-migration-info__icon">
12
+ </${i.ICON}>
13
+ <p class="${t}-migration-info__text">
14
+ ${e}
15
+ </p>
16
+ </div>
17
+ </div>`;
18
+ }
19
+ export {
20
+ g as getMigrationBannerHtml
21
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.0.0-beta.e99f1c8",
3
+ "version": "3.0.0-beta.f195a1b",
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",
@@ -25,7 +25,8 @@
25
25
  "lint:fix": "NODE_OPTIONS=--max-old-space-size=2048 eslint --fix ./",
26
26
  "type-check": "vue-tsc --noEmit --project tsconfig.config.json && vue-tsc --noEmit --project tsconfig.app.json",
27
27
  "test:visual-update": "npx playwright test --update-snapshots --reporter html",
28
- "prepare": "husky"
28
+ "prepare": "husky",
29
+ "preinstall": "rm -rf ./node_modules/.vite"
29
30
  },
30
31
  "keywords": [],
31
32
  "author": "",