@useinsider/guido 3.17.0-beta.8dc8fbb → 3.17.0-beta.978ff7e

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 (38) hide show
  1. package/dist/composables/useStripo.js +14 -14
  2. package/dist/config/migrator/index.js +9 -8
  3. package/dist/config/migrator/recommendation/compositionMapper.js +20 -20
  4. package/dist/config/migrator/recommendation/extractors.js +29 -24
  5. package/dist/config/migrator/recommendation/htmlBuilder.js +116 -130
  6. package/dist/config/migrator/recommendationMigrator.js +30 -25
  7. package/dist/config/migrator/recommendationTitleMigrator.js +119 -0
  8. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +1 -1
  9. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  10. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +19 -17
  11. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +34 -28
  12. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +310 -238
  13. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +9 -8
  14. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +1 -0
  15. package/dist/extensions/Blocks/Recommendation/controls/title/index.js +44 -0
  16. package/dist/extensions/Blocks/Recommendation/extension.js +31 -29
  17. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +23 -4
  18. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -3
  19. package/dist/extensions/Blocks/Recommendation/templates/titleRows.js +33 -0
  20. package/dist/extensions/Blocks/Recommendation/templates/utils.js +85 -107
  21. package/dist/src/config/migrator/recommendation/extractors.d.ts +8 -0
  22. package/dist/src/config/migrator/recommendationTitleMigrator.d.ts +5 -0
  23. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +2 -1
  24. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +7 -0
  25. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +1 -0
  26. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  27. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +10 -0
  28. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +11 -0
  29. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -0
  30. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +1 -0
  31. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +86 -0
  32. package/dist/src/extensions/Blocks/Recommendation/templates/titleRows.d.ts +13 -0
  33. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  34. package/dist/static/styles/customEditorStyle.css.js +3 -1
  35. package/dist/utils/genericUtil.js +55 -58
  36. package/package.json +1 -1
  37. package/dist/src/utils/liquidDynamicContent.d.ts +0 -20
  38. package/dist/utils/liquidDynamicContent.js +0 -15
@@ -10,5 +10,6 @@ export declare enum RecommendationBlockId {
10
10
  OMNIBUS_PRICE = "recommendation-block-omnibus-price",
11
11
  OMNIBUS_DISCOUNT = "recommendation-block-omnibus-discount",
12
12
  IMAGE = "recommendation-block-image",
13
- CUSTOM_ATTRIBUTE = "recommendation-block-custom-attribute"
13
+ CUSTOM_ATTRIBUTE = "recommendation-block-custom-attribute",
14
+ TITLE = "recommendation-block-title"
14
15
  }
@@ -65,5 +65,12 @@ export declare enum RecommendationControlId {
65
65
  CUSTOM_ATTR_SIZE = "recommendation-block-custom-attr-size-control",
66
66
  CUSTOM_ATTR_STYLE = "recommendation-block-custom-attr-style-control",
67
67
  CUSTOM_ATTR_TEXT_TRIM = "recommendation-block-custom-attr-text-trim-control",
68
+ TITLE_ALIGN = "recommendation-block-title-align-control",
69
+ TITLE_BACKGROUND = "recommendation-block-title-background-control",
70
+ TITLE_COLOR = "recommendation-block-title-color-control",
71
+ TITLE_FONT_FAMILY = "recommendation-block-title-font-family-control",
72
+ TITLE_PADDINGS = "recommendation-block-title-paddings-control",
73
+ TITLE_SIZE = "recommendation-block-title-size-control",
74
+ TITLE_STYLE = "recommendation-block-title-style-control",
68
75
  SYNC_INFO_MESSAGE = "recommendation-block-sync-info-message"
69
76
  }
@@ -32,6 +32,7 @@ export declare const DEFAULT_COMPOSITION: string[];
32
32
  /**
33
33
  * Default visibility settings for card elements
34
34
  * Omnibus elements are hidden by default (not all regions require them)
35
+ * The block-level title is visible on a fresh drop.
35
36
  */
36
37
  export declare const DEFAULT_VISIBILITY: Record<string, boolean>;
37
38
  /**
@@ -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, 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_CARD_COMPOSITION, ATTR_DATA_CUSTOM_ATTRIBUTES, ATTR_PRODUCT_ATTR, SELECTOR_ATTRIBUTE_ROW, ATTR_DATA_ATTRIBUTE_TYPE, PRODUCT_ATTRIBUTE_PREFIX, 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_RECOMMENDATION_TITLE, SELECTOR_TITLE_CELL, ATTR_CUSTOM_PREFIX, ATTR_DATA_CARD_COMPOSITION, ATTR_DATA_CUSTOM_ATTRIBUTES, ATTR_PRODUCT_ATTR, CSS_CLASS_ATTRIBUTE_ROW, CSS_CLASS_SPACER, SELECTOR_ATTRIBUTE_ROW, ATTR_DATA_ATTRIBUTE_TYPE, ATTR_DATA_VISIBILITY, PRODUCT_ATTRIBUTE_PREFIX, 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';
@@ -58,6 +58,10 @@ export declare const ATTR_PRODUCT_OLD_PRICE = "productOldPrice";
58
58
  export declare const ATTR_PRODUCT_OMNIBUS_PRICE = "productOmnibusPrice";
59
59
  export declare const ATTR_PRODUCT_OMNIBUS_DISCOUNT = "productOmnibusDiscount";
60
60
  export declare const ATTR_PRODUCT_BUTTON = "productButton";
61
+ export declare const ATTR_RECOMMENDATION_TITLE = "recommendationTitle";
62
+ export declare const CSS_CLASS_TITLE_CELL = "ins-recommendation-title";
63
+ /** Title cell — the only `esd-block-text` living outside the product containers. */
64
+ export declare const SELECTOR_TITLE_CELL = ".ins-recommendation-title";
61
65
  /**
62
66
  * Custom attribute constants
63
67
  * Used for dynamically added product attributes in Card Composition
@@ -70,10 +74,16 @@ export declare const ATTR_DATA_CUSTOM_ATTRIBUTES = "data-custom-attributes";
70
74
  export declare const ATTR_DATA_CARD_COMPOSITION = "data-card-composition";
71
75
  /** HTML attribute on <td> elements identifying the product attribute for compiler template variable generation */
72
76
  export declare const ATTR_PRODUCT_ATTR = "product-attr";
77
+ /** Class every composition attribute row carries — the visibility toggle and the compiler both key on it */
78
+ export declare const CSS_CLASS_ATTRIBUTE_ROW = "recommendation-attribute-row";
73
79
  /** Row wrapper of one composition entry inside a product card */
74
80
  export declare const SELECTOR_ATTRIBUTE_ROW = ".recommendation-attribute-row";
75
81
  /** HTML attribute on an attribute row holding its composition key */
76
82
  export declare const ATTR_DATA_ATTRIBUTE_TYPE = "data-attribute-type";
83
+ /** HTML attribute on an attribute row holding its visibility (`1` / `0`) */
84
+ export declare const ATTR_DATA_VISIBILITY = "data-visibility";
85
+ /** Class on the spacer cell of the row that trails a title */
86
+ export declare const CSS_CLASS_SPACER = "spacer";
77
87
  /** Prefix `resolveProductAttrValue` puts on custom (non-default) product attributes in `product-attr` values */
78
88
  export declare const PRODUCT_ATTRIBUTE_PREFIX = "product_attribute.";
79
89
  /**
@@ -33,6 +33,8 @@ export declare class RecommendationCardCompositionControl extends CommonControl
33
33
  private _normalizeComposition;
34
34
  private _readCustomAttributesFromNode;
35
35
  private _readVisibilityFromRows;
36
+ private _withTitlePresence;
37
+ private _hasTitle;
36
38
  private _getDefaultVisibilities;
37
39
  private _extractVisibilityFromRows;
38
40
  private _parseVisibilityValue;
@@ -187,6 +189,15 @@ export declare class RecommendationCardCompositionControl extends CommonControl
187
189
  */
188
190
  private _buildCompositionHtml;
189
191
  private _applyVisibilityToBlock;
192
+ private _applyTitleVisibilityToBlock;
193
+ private _resolveTitleInjection;
194
+ private _readTitleHtml;
195
+ private _findTitleRows;
196
+ private _findTitleRowsByClass;
197
+ private _isSpacerRow;
198
+ private _findTitleContainerBody;
199
+ private _readInnerHtml;
200
+ private _defaultTitleParagraph;
190
201
  /**
191
202
  * Finds the composition array index for the Nth custom attribute (0-based).
192
203
  * Scans left-to-right, counting only entries with the custom prefix.
@@ -11,6 +11,7 @@
11
11
  */
12
12
  export { RecommendationBlockControl, CONTROL_BLOCK_ID, AlgorithmControl, ALGORITHM_CONTROL_ID, LocaleControl, LOCALE_CONTROL_ID, CurrencyControl, CURRENCY_CONTROL_ID, ProductCountControl, PRODUCT_COUNT_CONTROL_ID, ProductLayoutControl, PRODUCT_LAYOUT_CONTROL_ID, FiltersControl, FILTERS_CONTROL_ID, ShuffleControl, SHUFFLE_CONTROL_ID, LayoutOrientationControl, LAYOUT_ORIENTATION_CONTROL_ID, PricePlacementControl, PRICE_PLACEMENT_CONTROL_ID, } from './main';
13
13
  export * from './main/utils';
14
+ export { TitleControls } from './title';
14
15
  export { NameControls } from './name';
15
16
  export { PriceControls } from './price';
16
17
  export { OldPriceControls } from './oldPrice';
@@ -70,6 +70,7 @@ export interface RegenerateProductRowsOptions {
70
70
  /** Optional: pass composition directly to avoid stale DOM reads after setAttribute */
71
71
  composition?: string[];
72
72
  }
73
+ export declare function getMainContainerTbody(currentNode: ImmutableHtmlNode): ImmutableHtmlNode | null;
73
74
  /**
74
75
  * Regenerates only the mobile product container rows and commits in a single apply().
75
76
  * Standalone entry point for callers that change mobile-only settings
@@ -0,0 +1,86 @@
1
+ export declare const TitleControls: {
2
+ readonly align: {
3
+ new (): {
4
+ getId(): string;
5
+ getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
6
+ getParentControlId(): string;
7
+ api: import("@stripoinc/ui-editor-extensions").ControlApi;
8
+ getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
9
+ getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
10
+ getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
11
+ isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
12
+ };
13
+ };
14
+ readonly color: {
15
+ new (): {
16
+ getId(): string;
17
+ getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
18
+ getParentControlId(): string;
19
+ api: import("@stripoinc/ui-editor-extensions").ControlApi;
20
+ getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
21
+ getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
22
+ getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
23
+ isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
24
+ };
25
+ };
26
+ readonly size: {
27
+ new (): {
28
+ getId(): string;
29
+ getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
30
+ getParentControlId(): string;
31
+ api: import("@stripoinc/ui-editor-extensions").ControlApi;
32
+ getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
33
+ getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
34
+ getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
35
+ isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
36
+ };
37
+ };
38
+ readonly style: {
39
+ new (): {
40
+ getId(): string;
41
+ getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
42
+ getParentControlId(): string;
43
+ api: import("@stripoinc/ui-editor-extensions").ControlApi;
44
+ getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
45
+ getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
46
+ getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
47
+ isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
48
+ };
49
+ };
50
+ readonly fontFamily: {
51
+ new (): {
52
+ getId(): string;
53
+ getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
54
+ getParentControlId(): string;
55
+ api: import("@stripoinc/ui-editor-extensions").ControlApi;
56
+ getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
57
+ getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
58
+ getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
59
+ isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
60
+ };
61
+ };
62
+ readonly background: {
63
+ new (): {
64
+ getId(): string;
65
+ getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
66
+ getAdditionalModifications(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
67
+ getParentControlId(): string;
68
+ api: import("@stripoinc/ui-editor-extensions").ControlApi;
69
+ getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
70
+ getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
71
+ isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
72
+ };
73
+ };
74
+ readonly paddings: {
75
+ new (): {
76
+ getId(): string;
77
+ getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
78
+ getParentControlId(): string;
79
+ api: import("@stripoinc/ui-editor-extensions").ControlApi;
80
+ getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
81
+ getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
82
+ getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
83
+ isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
84
+ };
85
+ };
86
+ };
@@ -0,0 +1,13 @@
1
+ export declare const DEFAULT_TITLE_TEXT = "You May Also Like!";
2
+ export declare const DEFAULT_TITLE_PARAGRAPH: string;
3
+ /**
4
+ * Builds the two block-level title rows: the title itself and the spacer below it.
5
+ * Both carry the same `recommendation-attribute-row` tagging a card attribute row has,
6
+ * so the Card Composition toggle hides the pair together and the compiler's
7
+ * `[data-visibility="0"]` sweep drops both — no leading gap when the title is off.
8
+ * @param paragraphHtml - Full `<p>` markup rendered inside the title cell
9
+ * @param visible - Whether the title starts visible
10
+ * @param spacerHeightPx - Height of the spacer row below the title
11
+ * @returns HTML string with the title row followed by its spacer row
12
+ */
13
+ export declare function buildTitleRows(paragraphHtml?: string, visible?: boolean, spacerHeightPx?: number): string;
@@ -138,6 +138,12 @@ export interface RecommendationNodeConfig {
138
138
  * Keys are ATTR_PRODUCT_* constants
139
139
  */
140
140
  visibility: Record<string, boolean>;
141
+ /**
142
+ * Snapshot of the block title's row markup before it's removed.
143
+ * Restored verbatim when the title is re-enabled.
144
+ * @default ''
145
+ */
146
+ previousTitleHtml: string;
141
147
  /**
142
148
  * Omnibus price text configuration
143
149
  * For EU Omnibus Directive compliance
@@ -43,7 +43,9 @@ const n = `.esd-x,
43
43
  .recommendation-block-v2 .product-omnibus-discount ue-node-actions,
44
44
  .recommendation-block-v2 .product-omnibus-discount ue-node-panel,
45
45
  .recommendation-block-v2 .product-button ue-node-actions,
46
- .recommendation-block-v2 .product-button ue-node-panel {
46
+ .recommendation-block-v2 .product-button ue-node-panel,
47
+ .recommendation-block-v2 .ins-recommendation-title ue-node-actions,
48
+ .recommendation-block-v2 .ins-recommendation-title ue-node-panel {
47
49
  display: none !important;
48
50
  }
49
51
 
@@ -1,71 +1,68 @@
1
- import { formatToLiquidFilter as v, quoteArgument as b, liquidFilterToFormat as h } from "./liquidDynamicContent.js";
2
- const k = (a) => {
3
- if (!a.includes("="))
4
- return null;
5
- const [e, t] = a.split("=");
6
- return { key: e.trim(), value: t.trim() };
7
- }, c = "default:", f = (a) => {
8
- if (!a.startsWith(c))
9
- return a;
10
- const e = a.slice(c.length).trim(), t = (r) => e.length >= 2 && e.startsWith(r) && e.endsWith(r);
11
- return t('"') || t("'") ? e.slice(1, -1) : e;
12
- }, d = (a) => {
13
- const t = a.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((l) => l.trim()), [r] = t, s = {
14
- text: a.label,
15
- value: r || ""
1
+ const o = (l) => {
2
+ const a = l.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((t) => t.trim()), [c] = a, r = {
3
+ text: l.label,
4
+ value: c || ""
16
5
  };
17
- if (t.length >= 2) {
18
- const [, l, n] = t;
19
- if (l.startsWith(c))
20
- s.fallback = f(l);
21
- else {
22
- const u = h(l) ?? k(l);
23
- u ? s.format = u : n || (s.fallback = l), n && (s.fallback = f(n));
6
+ if (a.length >= 2) {
7
+ const [, t, e] = a;
8
+ if (t.startsWith("default:")) {
9
+ let n = t.slice(8).trim();
10
+ n.startsWith('"') && n.endsWith('"') && (n = n.slice(1, -1)), r.fallback = n;
11
+ } else {
12
+ const n = t.includes("=") ? { key: t.split("=")[0].trim(), value: t.split("=")[1].trim() } : null;
13
+ n ? r.format = n : e || (r.fallback = t), e && (r.fallback = e);
24
14
  }
25
15
  }
26
- return s;
27
- }, m = (a) => {
28
- const t = !Number.isNaN(Number(a)) && a.trim() !== "" ? a : b(a);
29
- return t === null ? null : `${c} ${t}`;
30
- }, g = (a) => {
31
- const e = a.format ? v(a.format) : null, t = a.fallback ? m(a.fallback) : null, r = [a.value, e, t].filter(Boolean);
16
+ return r;
17
+ }, f = (l, s = !1) => l.map((a) => {
18
+ if (a.format)
19
+ return {
20
+ label: `${a.text} | ${a.format.key}=${a.format.value}`,
21
+ value: `{{${a.value}|${a.format.key}=${a.format.value}}}`
22
+ };
23
+ if (s) {
24
+ if (!a.fallback)
25
+ return {
26
+ label: a.text,
27
+ value: `{{ ${a.value} }}`
28
+ };
29
+ const r = !Number.isNaN(Number(a.fallback)) && a.fallback.trim() !== "" ? a.fallback : `"${a.fallback}"`;
30
+ return {
31
+ label: `${a.text} | ${a.fallback}`,
32
+ value: `{{ ${a.value} | default: ${r} }}`
33
+ };
34
+ }
32
35
  return {
33
- label: [a.text, e, t && a.fallback].filter(Boolean).join(" | "),
34
- value: `{{ ${r.join(" | ")} }}`
36
+ label: a.fallback ? `${a.text} | ${a.fallback}` : a.text,
37
+ value: a.fallback ? `{{${a.value}|${a.fallback}}}` : `{{${a.value}}}`
35
38
  };
36
- }, i = (a, e = !1) => a.map((t) => e ? g(t) : t.format ? {
37
- label: `${t.text} | ${t.format.key}=${t.format.value}`,
38
- value: `{{${t.value}|${t.format.key}=${t.format.value}}}`
39
- } : {
40
- label: t.fallback ? `${t.text} | ${t.fallback}` : t.text,
41
- value: t.fallback ? `{{${t.value}|${t.fallback}}}` : `{{${t.value}}}`
42
- }), y = (a) => {
43
- const e = [], t = /* @__PURE__ */ new Set(), r = (l) => {
44
- Array.isArray(l) && l.forEach((n) => {
45
- const u = [...n.children ?? [], ...n.select_items ?? []];
46
- if (u.length > 0) {
47
- r(u);
39
+ }), b = (l) => {
40
+ const s = [], a = /* @__PURE__ */ new Set(), c = (t) => {
41
+ Array.isArray(t) && t.forEach((e) => {
42
+ const n = [...e.children ?? [], ...e.select_items ?? []];
43
+ if (n.length > 0) {
44
+ c(n);
48
45
  return;
49
46
  }
50
- const o = n.text || n.tag_text;
51
- o && n.value && !t.has(n.value) && (t.add(n.value), e.push({ text: o, value: n.value }));
47
+ const u = e.text || e.tag_text;
48
+ u && e.value && !a.has(e.value) && (a.add(e.value), s.push({ text: u, value: e.value }));
52
49
  });
53
- }, [s] = Object.values(a ?? {});
54
- return r(s), e;
55
- }, p = (a, e, t = !1) => {
56
- const r = new Set(a.map((l) => l.value)), s = e.filter((l) => r.has(l.value) ? !1 : (r.add(l.value), !0));
50
+ }, [r] = Object.values(l ?? {});
51
+ return c(r), s;
52
+ }, v = (l, s, a = !1) => {
53
+ const c = new Set(l.map((t) => t.value)), r = s.filter((t) => c.has(t.value) ? !1 : (c.add(t.value), !0));
57
54
  return [
58
- ...i(a, t),
59
- ...i(s, t)
55
+ ...f(l, a),
56
+ ...f(r, a)
60
57
  ];
61
- }, F = () => {
62
- var a;
63
- return ((a = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : a.getAttribute("content")) ?? "";
58
+ }, i = () => {
59
+ var l;
60
+ return ((l = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : l.getAttribute("content")) ?? "";
64
61
  };
65
62
  export {
66
- p as buildMergeTagEntries,
67
- i as dynamicContentToMergeTags,
68
- y as flattenDynamicContentList,
69
- F as getCsrfToken,
70
- d as mergeTagToDynamicContent
63
+ v as buildMergeTagEntries,
64
+ f as dynamicContentToMergeTags,
65
+ b as flattenDynamicContentList,
66
+ i as getCsrfToken,
67
+ o as mergeTagToDynamicContent
71
68
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.17.0-beta.8dc8fbb",
3
+ "version": "3.17.0-beta.978ff7e",
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,20 +0,0 @@
1
- import type { BaseDynamicContent } from '@@/Types/generic';
2
- export type DynamicContentFormat = NonNullable<BaseDynamicContent['format']>;
3
- /** Format key the dynamic-content picker sends for a custom date/time format. */
4
- export declare const TIME_FORMAT_KEY = "time-format";
5
- /** Wraps a Liquid filter argument in whichever quote style the value itself does not use. */
6
- export declare const quoteArgument: (value: string) => string | null;
7
- /**
8
- * `{ key: 'time-format', value: '%Y-%m-%d' }` -> `date: "%Y-%m-%d"`.
9
- *
10
- * Only a custom date/time strftime pattern has a Liquid equivalent. Anything else returns null so
11
- * the caller emits a plain tag rather than one that silently lost — or literally printed — its
12
- * format.
13
- * @example formatToLiquidFilter({ key: 'time-format', value: '%b %-d, %Y' }) -> date: "%b %-d, %Y"
14
- */
15
- export declare const formatToLiquidFilter: (format: DynamicContentFormat) => string | null;
16
- /**
17
- * Inverse of `formatToLiquidFilter` — reads the picker format back out of one filter segment, so a
18
- * reopened tag restores its selection in the host's format dropdown.
19
- */
20
- export declare const liquidFilterToFormat: (segment: string) => DynamicContentFormat | null;
@@ -1,15 +0,0 @@
1
- const E = "time-format", r = "date", u = new RegExp(`^${r}\\s*:\\s*(?:"([^"]*)"|'([^']*)')$`), s = /%[-_0^#]?\d*[a-zA-Z%]/, c = new RegExp(s, "g"), l = /\b(?:Y{2,4}|M{2,4}|D{1,4}|d{3,4}|H{2}|h{2}|m{2}|s{2}|S{1,3}|A|a)\b/, T = (t) => t.includes('"') ? t.includes("'") ? null : `'${t}'` : `"${t}"`, i = (t) => s.test(t) && !l.test(t.replace(c, "")), R = (t) => {
2
- if (t.key !== E || !i(t.value ?? ""))
3
- return null;
4
- const n = T(t.value);
5
- return n === null ? null : `${r}: ${n}`;
6
- }, _ = (t) => {
7
- const [, n, o] = t.match(u) ?? [], e = n ?? o;
8
- return e ? { key: E, value: e } : null;
9
- };
10
- export {
11
- E as TIME_FORMAT_KEY,
12
- R as formatToLiquidFilter,
13
- _ as liquidFilterToFormat,
14
- T as quoteArgument
15
- };