@useinsider/guido 3.22.0-beta.3f91a42 → 3.22.0-beta.696e3c7

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 (84) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +41 -39
  3. package/dist/@types/display-condition.js +25 -0
  4. package/dist/components/Guido.vue.js +6 -6
  5. package/dist/components/Guido.vue2.js +84 -82
  6. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +20 -0
  7. package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +30 -0
  8. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
  9. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +71 -0
  10. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +34 -0
  11. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +57 -0
  12. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
  13. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
  14. package/dist/composables/useBlocksConfig.js +32 -24
  15. package/dist/composables/useDisplayConditions.js +109 -0
  16. package/dist/enums/academy.js +1 -0
  17. package/dist/enums/display-condition.js +12 -0
  18. package/dist/extensions/Blocks/Items/controls/button/link.js +17 -14
  19. package/dist/extensions/Blocks/Items/controls/cardComposition.js +17 -14
  20. package/dist/extensions/Blocks/Items/controls/image/link.js +17 -14
  21. package/dist/extensions/Blocks/Items/controls/name/trimming.js +10 -9
  22. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
  23. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +13 -12
  24. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +30 -29
  25. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +16 -15
  26. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +26 -25
  27. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +28 -27
  28. package/dist/extensions/Blocks/Items/controls/settingsControl.js +80 -75
  29. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +3 -3
  30. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +7 -7
  31. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +13 -13
  32. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +116 -121
  33. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
  34. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
  35. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +15 -15
  36. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +12 -12
  37. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +10 -10
  38. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +1 -1
  39. package/dist/extensions/Blocks/common-control.js +55 -62
  40. package/dist/extensions/DisplayConditions/bridge.js +18 -0
  41. package/dist/extensions/DisplayConditions/constants.js +17 -0
  42. package/dist/extensions/DisplayConditions/control.js +182 -0
  43. package/dist/extensions/DisplayConditions/display-conditions.css.js +201 -0
  44. package/dist/extensions/DisplayConditions/extension.js +28 -0
  45. package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
  46. package/dist/extensions/DisplayConditions/library.js +27 -0
  47. package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
  48. package/dist/guido.css +1 -1
  49. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +93 -92
  50. package/dist/node_modules/valibot/dist/index.js +297 -261
  51. package/dist/package.json.js +2 -2
  52. package/dist/services/displayConditionApi.js +39 -0
  53. package/dist/src/@types/config/schemas.d.ts +4 -0
  54. package/dist/src/@types/display-condition.d.ts +60 -0
  55. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
  56. package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +2 -0
  57. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
  58. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
  59. package/dist/src/composables/useConfig.d.ts +2 -0
  60. package/dist/src/composables/useDisplayConditions.d.ts +16 -0
  61. package/dist/src/enums/academy.d.ts +1 -0
  62. package/dist/src/enums/display-condition.d.ts +15 -0
  63. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +1 -0
  64. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -3
  65. package/dist/src/extensions/Blocks/common-control.d.ts +0 -2
  66. package/dist/src/extensions/DisplayConditions/bridge.d.ts +6 -0
  67. package/dist/src/extensions/DisplayConditions/constants.d.ts +14 -0
  68. package/dist/src/extensions/DisplayConditions/control.d.ts +23 -0
  69. package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
  70. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
  71. package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
  72. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
  73. package/dist/src/mock/api/display-conditions.d.ts +2 -0
  74. package/dist/src/services/displayConditionApi.d.ts +8 -0
  75. package/dist/src/stores/config.d.ts +166 -0
  76. package/dist/src/stores/display-condition.d.ts +84 -0
  77. package/dist/src/utils/displayCondition.d.ts +10 -0
  78. package/dist/src/utils/protectTableText.d.ts +2 -0
  79. package/dist/stores/config.js +13 -6
  80. package/dist/stores/display-condition.js +29 -0
  81. package/dist/utils/displayCondition.js +26 -0
  82. package/dist/utils/pairProductVariables.js +30 -29
  83. package/dist/utils/protectTableText.js +22 -0
  84. package/package.json +1 -1
@@ -0,0 +1,30 @@
1
+ import a from "./DisplayConditionCreateDrawer.vue2.js";
2
+ /* empty css */
3
+ import r from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var n = function() {
5
+ var i = this, t = i._self._c, e = i._self._setupProxy;
6
+ return t(e.WpDrawer, { attrs: { id: "guido__display-condition-create-drawer", "description-status": "", "class-name": "guido-display-condition-create-drawer", size: "large", "close-on-outside-click": !1, "description-text": e.descriptionText, "footer-button-group-options": e.footerButtonGroupOptions, status: e.store.isCreateOpen, "title-text": e.trans(`${e.KEY}.create-title`) }, on: { cancelOrBackButtonEvent: e.close, onCloseEvent: e.close, primaryButtonEvent: function(o) {
7
+ return e.submit("inline");
8
+ }, secondaryButtonEvent: function(o) {
9
+ return e.submit("save");
10
+ } } }, [t("div", { staticClass: "guido-display-condition-create" }, [t(e.InBasicTextInput, { staticClass: "mb-4 w-1", attrs: { id: "guido__display-condition-name-input", name: "displayConditionName", "character-counter-status": !1, "disabled-status": e.isSaving, "label-text": e.trans(`${e.KEY}.condition-name`), "max-character-length": e.DISPLAY_CONDITION_LIMITS.NAME_MAX, "placeholder-text": e.trans(`${e.KEY}.condition-name-placeholder`), "state-message": e.errors.name || "", states: e.errors.name ? "error" : "default", "tooltip-status": !1, value: e.draft.name }, on: { input: function(o) {
11
+ return e.updateField("name", o);
12
+ } } }), t(e.InBasicTextInput, { staticClass: "mb-4 w-1", attrs: { id: "guido__display-condition-description-input", name: "displayConditionDescription", "character-counter-status": !1, "disabled-status": e.isSaving, "label-text": e.descriptionLabel, "max-character-length": e.DISPLAY_CONDITION_LIMITS.DESCRIPTION_MAX, "placeholder-text": e.trans(`${e.KEY}.condition-description-placeholder`), "state-message": e.errors.description || "", states: e.errors.description ? "error" : "default", "tooltip-status": !1, value: e.draft.description }, on: { input: function(o) {
13
+ return e.updateField("description", o);
14
+ } } }), t("div", { staticClass: "guido-display-condition-create__separator" }), t("p", { staticClass: "guido-display-condition-create__method-title" }, [i._v(" " + i._s(e.trans(`${e.KEY}.select-method`)) + " ")]), t("div", { staticClass: "guido-display-condition-create__methods" }, [t(e.InRadioButton, { attrs: { id: "guido__display-condition-method-logic-builder", disable: "", disabled: "", name: "displayConditionMethod", selected: "codeOnly", value: "logicBuilder", label: e.trans(`${e.KEY}.logic-builder`) } }), t(e.InRadioButton, { attrs: { id: "guido__display-condition-method-code-only", name: "displayConditionMethod", selected: "codeOnly", value: "codeOnly", label: e.trans(`${e.KEY}.code-only`) } })], 1), t(e.CodeEditorField, { ref: "codeBeforeRef", staticClass: "mb-3", attrs: { id: "guido__display-condition-code-before", disabled: e.isSaving, error: e.errors.codeBefore, label: e.trans(`${e.KEY}.code-before`), placeholder: e.trans(`${e.KEY}.code-placeholder`), value: e.draft.codeBefore }, on: { input: function(o) {
15
+ return e.updateField("codeBefore", o);
16
+ } } }), t(e.CodeEditorField, { ref: "codeAfterRef", attrs: { id: "guido__display-condition-code-after", disabled: e.isSaving, error: e.errors.codeAfter, label: e.trans(`${e.KEY}.code-after`), placeholder: e.trans(`${e.KEY}.code-placeholder`), value: e.draft.codeAfter }, on: { input: function(o) {
17
+ return e.updateField("codeAfter", o);
18
+ } } })], 1)]);
19
+ }, s = [], d = /* @__PURE__ */ r(
20
+ a,
21
+ n,
22
+ s,
23
+ !1,
24
+ null,
25
+ "a4b2ccb9"
26
+ );
27
+ const f = d.exports;
28
+ export {
29
+ f as default
30
+ };
@@ -0,0 +1,71 @@
1
+ import { defineComponent as D, reactive as $, ref as s, watch as C, computed as u } from "vue";
2
+ import O from "../../wrappers/WpDrawer.vue.js";
3
+ import { useDisplayConditions as T } from "../../../composables/useDisplayConditions.js";
4
+ import { useTranslations as L } from "../../../composables/useTranslations.js";
5
+ import { ACADEMY_LINKS as x } from "../../../enums/academy.js";
6
+ import { DISPLAY_CONDITION_LIMITS as h } from "../../../enums/display-condition.js";
7
+ import { useDisplayConditionStore as k } from "../../../stores/display-condition.js";
8
+ import { InRadioButton as N, InBasicTextInput as w } from "@useinsider/design-system-vue";
9
+ import E from "./CodeEditorField.vue.js";
10
+ const J = /* @__PURE__ */ D({
11
+ __name: "DisplayConditionCreateDrawer",
12
+ setup(Y) {
13
+ const r = "email-editor.display-conditions", i = L(), c = k(), { validate: p, notifyInvalid: l, createInline: f, createAndSave: m, cancel: y } = T(), d = () => ({ name: "", description: "", codeBefore: "", codeAfter: "" }), e = $(d()), o = s({}), a = s(!1), v = s(), _ = s();
14
+ C(() => c.isCreateOpen, (n) => {
15
+ if (!n)
16
+ return;
17
+ const { editing: t } = c;
18
+ Object.assign(e, t ? {
19
+ name: t.name,
20
+ description: t.description,
21
+ codeBefore: t.beforeScript,
22
+ codeAfter: t.afterScript
23
+ } : d()), o.value = {}, a.value = !1;
24
+ }, { immediate: !0 });
25
+ const g = u(() => i(`${r}.create-description`, {
26
+ academyLink: `<a href="${x.EMAIL_DISPLAY_CONDITIONS}" class="guido-display-condition-academy" target="_blank">${i(`${r}.academy`)}</a>`
27
+ })), S = u(() => ({
28
+ cancelOrBackButton: {
29
+ styling: "ghost",
30
+ type: "secondary",
31
+ labelText: i(`${r}.cancel`),
32
+ disabledStatus: a.value
33
+ },
34
+ secondaryButton: {
35
+ styling: "solid",
36
+ type: "subtle-primary",
37
+ labelText: i(`${r}.create-and-save`),
38
+ loadingStatus: a.value
39
+ },
40
+ primaryButton: {
41
+ styling: "solid",
42
+ type: "primary",
43
+ labelText: i(`${r}.create`),
44
+ disabledStatus: a.value
45
+ }
46
+ })), B = (n, t) => {
47
+ t !== e[n] && (e[n] = t, o.value[n] && (o.value = { ...o.value, [n]: void 0 }));
48
+ }, A = u(() => `${i(`${r}.condition-description`)} <span class="guido-display-condition-create__optional">(${i(`${r}.optional`)})</span>`);
49
+ return { __sfc: !0, KEY: r, trans: i, store: c, validate: p, notifyInvalid: l, createInline: f, createAndSave: m, cancel: y, emptyDraft: d, draft: e, errors: o, isSaving: a, codeBeforeRef: v, codeAfterRef: _, descriptionText: g, footerButtonGroupOptions: S, updateField: B, descriptionLabel: A, submit: async (n) => {
50
+ var I, b;
51
+ if (a.value)
52
+ return;
53
+ if (e.codeBefore = ((I = v.value) == null ? void 0 : I.read()) ?? e.codeBefore, e.codeAfter = ((b = _.value) == null ? void 0 : b.read()) ?? e.codeAfter, o.value = p(e), Object.keys(o.value).length) {
54
+ l();
55
+ return;
56
+ }
57
+ if (n === "inline") {
58
+ f({ ...e });
59
+ return;
60
+ }
61
+ a.value = !0;
62
+ const t = await m({ ...e });
63
+ a.value = !1, o.value = t ?? {}, Object.keys(o.value).length && l();
64
+ }, close: () => {
65
+ a.value || y();
66
+ }, WpDrawer: O, DISPLAY_CONDITION_LIMITS: h, InBasicTextInput: w, InRadioButton: N, CodeEditorField: E };
67
+ }
68
+ });
69
+ export {
70
+ J as default
71
+ };
@@ -0,0 +1,34 @@
1
+ import a from "./DisplayConditionSelectDrawer.vue2.js";
2
+ /* empty css */
3
+ import o from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var d = function() {
5
+ var s = this, i = s._self._c, t = s._self._setupProxy;
6
+ return i("div", { staticClass: "guido-display-condition-select-root" }, [i(t.WpDrawer, { attrs: { id: "guido__display-condition-select-drawer", "description-status": "", "class-name": "guido-display-condition-select-drawer", size: "large", "description-text": t.descriptionText, "footer-button-group-options": t.footerButtonGroupOptions, status: t.store.isSelectOpen, "title-text": t.trans(`${t.KEY}.select-title`) }, on: { cancelOrBackButtonEvent: t.cancel, onCloseEvent: t.cancel } }, [i("div", { staticClass: "guido-display-condition-select" }, [t.store.listStatus === "loaded" && t.store.list.length ? i(t.InBasicTextInput, { staticClass: "mb-4 w-1", attrs: { id: "guido__display-condition-search-input", name: "displayConditionSearch", "character-counter-status": !1, "label-status": !1, "placeholder-text": t.trans(`${t.KEY}.search`), "tooltip-status": !1, value: t.search }, on: { input: function(e) {
7
+ t.search = e;
8
+ } } }) : s._e(), t.store.listStatus === "loading" || t.store.listStatus === "idle" ? i("div", { staticClass: "guido-display-condition-select__list", attrs: { "data-testid": "display-condition-loading" } }, s._l(t.SKELETON_HEIGHTS, function(e, n) {
9
+ return i(t.InSkeleton, { key: n, attrs: { sizing: { width: 856, height: e } } });
10
+ }), 1) : t.store.listStatus === "error" ? i(t.InNoData, { attrs: { id: "guido__display-condition-error", "button-status": "", icon: "no-data", "button-text": t.trans(`${t.KEY}.retry`), description: t.trans(`${t.KEY}.error-load`), title: t.trans(`${t.KEY}.error-load-title`) }, on: { click: t.loadList } }) : t.store.list.length ? t.filteredList.length ? i("ul", { staticClass: "guido-display-condition-select__list" }, s._l(t.filteredList, function(e) {
11
+ return i("li", { key: e.id, staticClass: "guido-display-condition-card", attrs: { "data-condition-id": e.id } }, [i("div", { staticClass: "guido-display-condition-card__header" }, [i("div", { staticClass: "guido-display-condition-card__text" }, [i("p", { staticClass: "guido-display-condition-card__name" }, [s._v(" " + s._s(e.name) + " ")]), e.description ? i("p", { staticClass: "guido-display-condition-card__description" }, [s._v(" " + s._s(e.description) + " ")]) : s._e()]), i("div", { staticClass: "guido-display-condition-card__actions" }, [i("div", { staticClass: "guido-display-condition-card__split" }, [i(t.InButtonV2, { attrs: { id: `guido__display-condition-select-${e.id}`, type: "subtle-primary", "label-text": t.trans(`${t.KEY}.select`) }, on: { click: function(n) {
12
+ return t.select(e);
13
+ } } }), i(t.InButtonV2, { attrs: { id: `guido__display-condition-menu-${e.id}`, "left-icon": "filled-dropdown-down", type: "subtle-primary", "label-text-status": !1 }, on: { click: function(n) {
14
+ return t.toggleMenu(e);
15
+ } } }), t.menuId === e.id ? i("div", { staticClass: "guido-display-condition-card__menu" }, [i("button", { staticClass: "guido-display-condition-card__menu-item", attrs: { id: `guido__display-condition-delete-${e.id}`, type: "button" }, on: { click: function(n) {
16
+ return t.requestDelete(e);
17
+ } } }, [s._v(" " + s._s(t.trans(`${t.KEY}.delete`)) + " ")])]) : s._e()], 1), i("span", { staticClass: "guido-display-condition-card__divider" }), i("button", { staticClass: "guido-display-condition-card__expand", attrs: { id: `guido__display-condition-expand-${e.id}`, type: "button", "aria-expanded": t.expandedId === e.id ? "true" : "false", "aria-label": t.trans(`${t.KEY}.preview`) }, on: { click: function(n) {
18
+ return t.toggleExpanded(e);
19
+ } } }, [i(t.InIcons, { attrs: { name: t.expandedId === e.id ? "filled-dropdown-up" : "filled-dropdown-down" } })], 1)])]), t.expandedId === e.id ? i("pre", { staticClass: "guido-display-condition-card__code" }, [s._v(s._s(t.codeOf(e)))]) : s._e()]);
20
+ }), 0) : i(t.InNoData, { attrs: { id: "guido__display-condition-no-result", icon: "no-data", title: t.trans(`${t.KEY}.no-result`) } }) : i(t.InNoData, { attrs: { id: "guido__display-condition-empty", "button-status": "", icon: "no-personalization", "button-text": t.trans(`${t.KEY}.create-new`), description: t.trans(`${t.KEY}.empty-description`), title: t.trans(`${t.KEY}.empty-title`) }, on: { click: function(e) {
21
+ return t.store.openCreate();
22
+ } } })], 1)]), t.store.pendingDelete ? i("div", { staticClass: "guido-display-condition-select__delete-modal" }, [i(t.WpModal, { attrs: { id: "guido__display-condition-delete-modal", size: "X-small", state: "danger", "close-on-outside-click": !1, "footer-button-options": t.deleteModalButtons, title: t.trans(`${t.KEY}.delete-confirm-title`) }, on: { close: t.closeDeleteModal, "primary-action": t.confirmDelete } }, [i("p", { staticClass: "guido-display-condition-select__delete-text" }, [s._v(" " + s._s(t.trans(`${t.KEY}.delete-confirm-description`, { name: t.store.pendingDelete.name })) + " ")])])], 1) : s._e()], 1);
23
+ }, l = [], c = /* @__PURE__ */ o(
24
+ a,
25
+ d,
26
+ l,
27
+ !1,
28
+ null,
29
+ "10ac7a13"
30
+ );
31
+ const y = c.exports;
32
+ export {
33
+ y as default
34
+ };
@@ -0,0 +1,57 @@
1
+ import { defineComponent as _, ref as i, watch as S, computed as c } from "vue";
2
+ import B from "../../wrappers/WpDrawer.vue.js";
3
+ import L from "../../wrappers/WpModal.vue.js";
4
+ import { useDisplayConditions as x } from "../../../composables/useDisplayConditions.js";
5
+ import { useTranslations as O } from "../../../composables/useTranslations.js";
6
+ import { ACADEMY_LINKS as T } from "../../../enums/academy.js";
7
+ import { useDisplayConditionStore as $ } from "../../../stores/display-condition.js";
8
+ import { InSkeleton as C, InNoData as E, InIcons as M, InButtonV2 as b, InBasicTextInput as k } from "@useinsider/design-system-vue";
9
+ const J = /* @__PURE__ */ _({
10
+ __name: "DisplayConditionSelectDrawer",
11
+ setup(h) {
12
+ const o = "email-editor.display-conditions", m = [40, 76, 76, 76], l = O(), t = $(), { loadList: d, select: f, deleteSaved: u, cancel: g } = x(), r = i(""), s = i(null), a = i(null), n = i(!1);
13
+ S(() => t.isSelectOpen, (e) => {
14
+ e && (r.value = "", s.value = null, a.value = null, d());
15
+ }, { immediate: !0 });
16
+ const D = c(() => {
17
+ const e = r.value.trim().toLocaleLowerCase();
18
+ return e ? t.list.filter((p) => `${p.name} ${p.description}`.toLocaleLowerCase().includes(e)) : t.list;
19
+ }), v = c(() => l(`${o}.select-description`, {
20
+ academyLink: `<a href="${T.EMAIL_DISPLAY_CONDITIONS}" class="guido-display-condition-academy" target="_blank">${l(`${o}.academy`)}</a>`
21
+ })), y = c(() => ({
22
+ cancelOrBackButton: {
23
+ styling: "ghost",
24
+ type: "secondary",
25
+ labelText: l(`${o}.back`),
26
+ leftIcon: "line-arrow-left"
27
+ }
28
+ })), I = c(() => ({
29
+ cancelOrBackButton: {
30
+ type: "secondary",
31
+ styling: "ghost",
32
+ labelText: l(`${o}.cancel`),
33
+ disabledStatus: n.value
34
+ },
35
+ primaryButton: {
36
+ type: "danger",
37
+ labelText: l(`${o}.delete`),
38
+ loadingStatus: n.value
39
+ }
40
+ }));
41
+ return { __sfc: !0, KEY: o, SKELETON_HEIGHTS: m, trans: l, store: t, loadList: d, select: f, deleteSaved: u, cancel: g, search: r, expandedId: s, menuId: a, isDeleting: n, filteredList: D, descriptionText: v, footerButtonGroupOptions: y, deleteModalButtons: I, toggleExpanded: (e) => {
42
+ s.value = s.value === e.id ? null : e.id;
43
+ }, toggleMenu: (e) => {
44
+ a.value = a.value === e.id ? null : e.id;
45
+ }, requestDelete: (e) => {
46
+ a.value = null, t.pendingDelete = e;
47
+ }, confirmDelete: async () => {
48
+ !t.pendingDelete || n.value || (n.value = !0, await u(t.pendingDelete), n.value = !1);
49
+ }, closeDeleteModal: () => {
50
+ n.value || (t.pendingDelete = null);
51
+ }, codeOf: (e) => [e.codeBefore, e.codeAfter].filter(Boolean).join(`
52
+ `), WpDrawer: B, WpModal: L, InBasicTextInput: k, InButtonV2: b, InIcons: M, InNoData: E, InSkeleton: C };
53
+ }
54
+ });
55
+ export {
56
+ J as default
57
+ };
@@ -0,0 +1,17 @@
1
+ import e from "./DisplayConditionsHost.vue2.js";
2
+ import n from "../../../_virtual/_plugin-vue2_normalizer.js";
3
+ var r = function() {
4
+ var s = this, o = s._self._c, t = s._self._setupProxy;
5
+ return o("div", { staticClass: "guido-display-conditions-host" }, [o(t.DisplayConditionCreateDrawer), o(t.DisplayConditionSelectDrawer)], 1);
6
+ }, i = [], a = /* @__PURE__ */ n(
7
+ e,
8
+ r,
9
+ i,
10
+ !1,
11
+ null,
12
+ null
13
+ );
14
+ const p = a.exports;
15
+ export {
16
+ p as default
17
+ };
@@ -0,0 +1,22 @@
1
+ import { defineComponent as i, onMounted as s, onBeforeUnmount as m } from "vue";
2
+ import { useDisplayConditions as p } from "../../../composables/useDisplayConditions.js";
3
+ import { DisplayConditionEvent as n } from "../../../enums/display-condition.js";
4
+ import { useDisplayConditionStore as a } from "../../../stores/display-condition.js";
5
+ import d from "./DisplayConditionCreateDrawer.vue.js";
6
+ import f from "./DisplayConditionSelectDrawer.vue.js";
7
+ const E = /* @__PURE__ */ i({
8
+ __name: "DisplayConditionsHost",
9
+ setup(l) {
10
+ const o = a(), { handleOpen: t } = p(), e = (r) => {
11
+ t(r.detail);
12
+ };
13
+ return s(() => {
14
+ o.$reset(), document.addEventListener(n.OPEN, e);
15
+ }), m(() => {
16
+ document.removeEventListener(n.OPEN, e), o.$reset();
17
+ }), { __sfc: !0, store: o, handleOpen: t, onOpen: e, DisplayConditionCreateDrawer: d, DisplayConditionSelectDrawer: f };
18
+ }
19
+ });
20
+ export {
21
+ E as default
22
+ };
@@ -1,6 +1,6 @@
1
- import r from "../extensions/ModulesTabIcons/extension.js";
2
- import { useConfigStore as l } from "../stores/config.js";
3
- const a = {
1
+ import l from "../extensions/ModulesTabIcons/extension.js";
2
+ import { useConfigStore as c } from "../stores/config.js";
3
+ const s = {
4
4
  "amp-accordion": "ampAccordionEnabled",
5
5
  "amp-carousel": "ampCarouselEnabled",
6
6
  "amp-form-controls": "ampFormControlsEnabled",
@@ -14,7 +14,7 @@ const a = {
14
14
  "text-block": "textEnabled",
15
15
  "timer-block": "timerEnabled",
16
16
  "video-block": "videoEnabled"
17
- }, s = {
17
+ }, i = {
18
18
  "dynamic-content": () => import("../extensions/DynamicContent/extension.js"),
19
19
  "checkbox-block": () => import("../extensions/Blocks/Checkbox/extension.js"),
20
20
  "radio-button-block": () => import("../extensions/Blocks/RadioButton/extension.js"),
@@ -22,40 +22,48 @@ const a = {
22
22
  "unsubscribe-block": () => import("../extensions/Blocks/Unsubscribe/extension.js"),
23
23
  "coupon-block": () => import("../extensions/Blocks/CouponBlock/extension.js"),
24
24
  "items-block": () => import("../extensions/Blocks/Items/extension.js")
25
- }, i = (n) => {
26
- if (!n || !n.length)
25
+ }, b = (o) => {
26
+ if (!o || !o.length)
27
27
  return {};
28
28
  const t = {};
29
- return n.forEach((o) => {
30
- const e = a[o];
29
+ return o.forEach((n) => {
30
+ const e = s[n];
31
31
  e && (t[e] = !1);
32
32
  }), t;
33
- }, b = () => [r], m = async (n) => {
34
- const t = b();
35
- if (!n || !n.length)
36
- return t;
37
- const o = await Promise.all(
38
- n.map(async (e) => {
39
- const c = s[e];
40
- return c ? (await c()).default : null;
33
+ }, m = async (o) => {
34
+ if (!o)
35
+ return [l];
36
+ const t = await import("../extensions/DisplayConditions/extension.js");
37
+ return [l, t.default];
38
+ }, d = async (o, t = !1) => {
39
+ const n = await m(t);
40
+ if (!o || !o.length)
41
+ return n;
42
+ const e = await Promise.all(
43
+ o.map(async (r) => {
44
+ const a = i[r];
45
+ return a ? (await a()).default : null;
41
46
  })
42
47
  );
43
48
  return [
44
- ...t,
45
- ...o.filter((e) => e !== null)
49
+ ...n,
50
+ ...e.filter((r) => r !== null)
46
51
  ];
47
- }, E = () => {
48
- const n = l();
52
+ }, k = () => {
53
+ const o = c();
49
54
  return {
50
55
  getStripoBlocksConfig: async () => {
51
- const o = n.blocks;
56
+ const n = o.blocks;
52
57
  return {
53
- baseBlocks: i(o == null ? void 0 : o.excludeDefaults),
54
- extensions: await m(o == null ? void 0 : o.includeCustoms)
58
+ baseBlocks: b(n == null ? void 0 : n.excludeDefaults),
59
+ extensions: await d(
60
+ n == null ? void 0 : n.includeCustoms,
61
+ o.externalDisplayConditions
62
+ )
55
63
  };
56
64
  }
57
65
  };
58
66
  };
59
67
  export {
60
- E as useBlocksConfig
68
+ k as useBlocksConfig
61
69
  };
@@ -0,0 +1,109 @@
1
+ import { useToaster as x } from "./useToaster.js";
2
+ import { useTranslations as M } from "./useTranslations.js";
3
+ import { DISPLAY_CONDITION_LIMITS as s, DisplayConditionEvent as C } from "../enums/display-condition.js";
4
+ import { ToasterTypeOptions as l } from "../enums/toaster.js";
5
+ import { useDisplayConditionApi as N } from "../services/displayConditionApi.js";
6
+ import { useConfigStore as _ } from "../stores/config.js";
7
+ import { useDisplayConditionStore as O } from "../stores/display-condition.js";
8
+ import { findInvalidCodeFields as q, nextConditionId as w } from "../utils/displayCondition.js";
9
+ import { escapeHtml as L } from "../utils/htmlEscape.js";
10
+ import { computed as B } from "vue";
11
+ const i = "email-editor.display-conditions", P = 409, v = (n, m, r) => ({
12
+ id: w(),
13
+ name: n.name.trim(),
14
+ description: n.description.trim(),
15
+ beforeScript: n.codeBefore,
16
+ afterScript: n.codeAfter,
17
+ extraData: JSON.stringify(r === void 0 ? { source: m } : { source: m, savedId: r })
18
+ }), E = (n) => ({
19
+ name: n.name,
20
+ description: n.description,
21
+ codeBefore: n.codeBefore,
22
+ codeAfter: n.codeAfter
23
+ }), V = () => {
24
+ const n = O(), m = _(), r = N(), o = M(), { showToaster: p } = x(), u = B(() => {
25
+ var e;
26
+ return (e = m.features) != null && e.liquidSyntax ? "liquid" : "pongo";
27
+ }), f = (e) => {
28
+ const t = { condition: e };
29
+ return document.dispatchEvent(new CustomEvent(C.APPLY, { detail: t })), n.close(), t.applied === !0;
30
+ }, g = () => {
31
+ n.view !== "none" && (document.dispatchEvent(new CustomEvent(C.CANCEL)), n.close());
32
+ }, h = (e) => {
33
+ if (e.mode === "select") {
34
+ n.openSelect();
35
+ return;
36
+ }
37
+ n.openCreate(e.mode === "edit" ? e.current : null);
38
+ }, $ = async () => {
39
+ const e = ++n.listRequest;
40
+ n.listStatus = "loading";
41
+ try {
42
+ const t = await r.list(u.value);
43
+ e === n.listRequest && (n.list = t, n.listStatus = "loaded");
44
+ } catch (t) {
45
+ console.warn("Display conditions could not be loaded.", t), e === n.listRequest && (n.listStatus = "error");
46
+ }
47
+ }, I = (e) => {
48
+ const t = {}, d = e.name.trim();
49
+ d ? d.length < s.NAME_MIN ? t.name = o(`${i}.error-name-min`, { min: s.NAME_MIN }) : d.length > s.NAME_MAX && (t.name = o(`${i}.error-name-max`, { max: s.NAME_MAX })) : t.name = o(`${i}.error-name-required`);
50
+ const { DESCRIPTION_MAX: S } = s;
51
+ e.description.trim().length > S && (t.description = o(`${i}.error-description-max`, { max: S }));
52
+ const T = q(e.codeBefore, e.codeAfter);
53
+ return ["codeBefore", "codeAfter"].forEach((a) => {
54
+ e[a].trim() ? T.includes(a) ? t[a] = o(`${i}.error-code-invalid`) : e[a].length > s.CODE_MAX && (t[a] = o(`${i}.error-code-max`, { max: s.CODE_MAX })) : t[a] = o(`${i}.error-code-required`);
55
+ }), t;
56
+ }, y = (e, t) => {
57
+ p(e ? { type: l.Success, message: t } : { type: l.Error, message: o("common.something-went-wrong") });
58
+ }, D = () => {
59
+ p({ type: l.Error, message: o(`${i}.validation-failed`) });
60
+ }, c = (e) => ({ name: L(e) }), A = (e, t) => {
61
+ e != null && e.authReported || (console.warn(t, e), p({ type: l.Error, message: t }));
62
+ };
63
+ return {
64
+ syntax: u,
65
+ handleOpen: h,
66
+ cancel: g,
67
+ loadList: $,
68
+ validate: I,
69
+ notifyInvalid: D,
70
+ createInline: (e) => {
71
+ y(
72
+ f(v(e, "inline")),
73
+ o(`${i}.created`, c(e.name.trim()))
74
+ );
75
+ },
76
+ createAndSave: async (e) => {
77
+ try {
78
+ const t = await r.create(e, u.value);
79
+ return n.list = [t, ...n.list.filter((d) => d.id !== t.id)], y(
80
+ f(v(E(t), "saved", t.id)),
81
+ o(`${i}.created-and-saved`, c(t.name))
82
+ ), {};
83
+ } catch (t) {
84
+ return (t == null ? void 0 : t.status) === P ? { name: o(`${i}.error-name-exists`) } : (A(t, o(`${i}.save-failed`, c(e.name.trim()))), null);
85
+ }
86
+ },
87
+ select: (e) => {
88
+ y(
89
+ f(v(E(e), "saved", e.id)),
90
+ o(`${i}.applied`, c(e.name))
91
+ );
92
+ },
93
+ deleteSaved: async (e) => {
94
+ try {
95
+ await r.remove(e.id), n.list = n.list.filter((t) => t.id !== e.id), p({
96
+ type: l.Success,
97
+ message: o(`${i}.deleted`, c(e.name))
98
+ });
99
+ } catch (t) {
100
+ A(t, o(`${i}.delete-failed`));
101
+ } finally {
102
+ n.pendingDelete = null;
103
+ }
104
+ }
105
+ };
106
+ };
107
+ export {
108
+ V as useDisplayConditions
109
+ };
@@ -2,6 +2,7 @@ const e = "https://academy.insiderone.com", o = {
2
2
  EMAIL_EDITOR: `${e}/docs/email-drag-and-drop-editor`,
3
3
  GLOBAL_UNSUBSCRIBE: `${e}/docs/global-unsubscribe-preference-center`,
4
4
  AMP_FOR_EMAILS: `${e}/docs/amp-for-emails`,
5
+ EMAIL_DISPLAY_CONDITIONS: `${e}/docs/new-editor-add-display-conditions-to-an-email`,
5
6
  EMAIL_RECOMMENDATION_BLOCK: `${e}/docs/new-editor-email-recommendation-block`
6
7
  };
7
8
  export {
@@ -0,0 +1,12 @@
1
+ var N = /* @__PURE__ */ ((I) => (I.OPEN = "display-condition:open", I.APPLY = "display-condition:apply", I.CANCEL = "display-condition:cancel", I))(N || {}), A = /* @__PURE__ */ ((I) => (I.INLINE = "inline", I.SAVED = "saved", I))(A || {});
2
+ const M = {
3
+ NAME_MIN: 2,
4
+ NAME_MAX: 40,
5
+ DESCRIPTION_MAX: 200,
6
+ CODE_MAX: 65535
7
+ };
8
+ export {
9
+ M as DISPLAY_CONDITION_LIMITS,
10
+ N as DisplayConditionEvent,
11
+ A as DisplayConditionSourceType
12
+ };
@@ -1,28 +1,31 @@
1
- import { CommonControl as s } from "../../../common-control.js";
2
- import { ItemsBlockControlId as r } from "../../enums/controlEnums.js";
3
- import { getItemsBlockConfig as a } from "../../utils/nodeConfigUtils.js";
4
- const e = r.BUTTON_LINK, n = {
1
+ import { CommonControl as r } from "../../../common-control.js";
2
+ import { ItemsBlockControlId as i } from "../../enums/controlEnums.js";
3
+ import { getItemsBlockConfig as o } from "../../utils/nodeConfigUtils.js";
4
+ const s = i.BUTTON_LINK, n = {
5
5
  LINK: "link"
6
6
  };
7
- class L extends s {
7
+ class m extends r {
8
8
  getId() {
9
- return e;
9
+ return s;
10
10
  }
11
11
  getTemplate() {
12
12
  return `
13
- <div class="container ${e}">
13
+ <div class="container ${s}">
14
14
  ${this._getLink()}
15
15
  </div>
16
16
  `;
17
17
  }
18
18
  onRender() {
19
- this.forgetLastPanelNode();
19
+ const t = o(this.currentNode);
20
+ this.api.updateValues({
21
+ [n.LINK]: (t == null ? void 0 : t.buttonLink) ?? ""
22
+ });
20
23
  }
21
- onTemplateNodeUpdated(o) {
22
- super.onTemplateNodeUpdated(o), this.handleBlockInstanceChange(() => {
23
- const t = a(this.currentNode);
24
+ onTemplateNodeUpdated(t) {
25
+ super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
26
+ const e = o(this.currentNode);
24
27
  this.api.updateValues({
25
- [n.LINK]: (t == null ? void 0 : t.buttonLink) ?? ""
28
+ [n.LINK]: (e == null ? void 0 : e.buttonLink) ?? ""
26
29
  });
27
30
  });
28
31
  }
@@ -41,6 +44,6 @@ class L extends s {
41
44
  }
42
45
  }
43
46
  export {
44
- L as ButtonLinkControl,
45
- e as CONTROL_BLOCK_ID
47
+ m as ButtonLinkControl,
48
+ s as CONTROL_BLOCK_ID
46
49
  };
@@ -1,12 +1,12 @@
1
1
  var I = Object.defineProperty;
2
2
  var U = (d, a, t) => a in d ? I(d, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[a] = t;
3
- var y = (d, a, t) => U(d, typeof a != "symbol" ? a + "" : a, t);
3
+ var p = (d, a, t) => U(d, typeof a != "symbol" ? a + "" : a, t);
4
4
  import { ModificationDescription as c } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
5
  import { CommonControl as b } from "../../common-control.js";
6
6
  import { ItemsBlockId as r } from "../enums/controlEnums.js";
7
7
  import { SETTINGS_ENUMS as h } from "../enums/settingsEnums.js";
8
8
  import { getItemsBlockConfig as R, setItemsBlockConfig as m } from "../utils/nodeConfigUtils.js";
9
- const N = "ui-elements-items-card-composition-block", i = {
9
+ const g = "ui-elements-items-card-composition-block", i = {
10
10
  PRODUCT_IMAGE: "image",
11
11
  PRODUCT_NAME: "name",
12
12
  PRODUCT_QUANTITY: "quantity",
@@ -17,7 +17,7 @@ const N = "ui-elements-items-card-composition-block", i = {
17
17
  class M extends b {
18
18
  constructor() {
19
19
  super(...arguments);
20
- y(this, "visibilityState", {
20
+ p(this, "visibilityState", {
21
21
  [i.PRODUCT_IMAGE]: !0,
22
22
  [i.PRODUCT_NAME]: !0,
23
23
  [i.PRODUCT_QUANTITY]: !0,
@@ -27,7 +27,7 @@ class M extends b {
27
27
  });
28
28
  }
29
29
  getId() {
30
- return N;
30
+ return g;
31
31
  }
32
32
  getTemplate() {
33
33
  return `
@@ -44,7 +44,7 @@ class M extends b {
44
44
  `;
45
45
  }
46
46
  onRender() {
47
- this.forgetLastPanelNode(), this._listenToFormUpdates();
47
+ this._syncVisibilityFromAttributes(), this._handleBrowsedItemsQuantity(), this._initializeToggles(), this._listenToFormUpdates();
48
48
  }
49
49
  onTemplateNodeUpdated(t) {
50
50
  super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
@@ -61,6 +61,9 @@ class M extends b {
61
61
  </div>
62
62
  `;
63
63
  }
64
+ _initializeToggles() {
65
+ this._updateTogglesFromState();
66
+ }
64
67
  _updateTogglesFromState() {
65
68
  this.api.updateValues({
66
69
  [i.PRODUCT_IMAGE]: this.visibilityState[i.PRODUCT_IMAGE],
@@ -221,21 +224,21 @@ class M extends b {
221
224
  * - When both are visible, they share 50% each
222
225
  */
223
226
  _updatePriceCellWidthsForVerticalLayout(t) {
224
- var O, p;
227
+ var O, y;
225
228
  const e = R(this.currentNode);
226
229
  if (!((e == null ? void 0 : e.orientation) === h.ORIENTATION.VERTICAL))
227
230
  return;
228
- const n = (O = this.currentNode) == null ? void 0 : O.querySelectorAll(".product-price-class"), s = (p = this.currentNode) == null ? void 0 : p.querySelectorAll(".product-original-price-class"), l = (e == null ? void 0 : e.priceOrientation) === "vertical", P = this.visibilityState[i.PRODUCT_PRICE], C = this.visibilityState[i.PRODUCT_ORIGINAL_PRICE], T = t ?? this.api.getDocumentModifier();
231
+ const n = (O = this.currentNode) == null ? void 0 : O.querySelectorAll(".product-price-class"), s = (y = this.currentNode) == null ? void 0 : y.querySelectorAll(".product-original-price-class"), l = (e == null ? void 0 : e.priceOrientation) === "vertical", P = this.visibilityState[i.PRODUCT_PRICE], C = this.visibilityState[i.PRODUCT_ORIGINAL_PRICE], T = t ?? this.api.getDocumentModifier();
229
232
  if (n && n.length > 0) {
230
- const u = l || !C ? "100%" : "50%";
231
- n.forEach((_) => {
232
- T.modifyHtml(_).setStyle("width", u);
233
+ const _ = l || !C ? "100%" : "50%";
234
+ n.forEach((u) => {
235
+ T.modifyHtml(u).setStyle("width", _);
233
236
  });
234
237
  }
235
238
  if (s && s.length > 0) {
236
- const u = l || !P ? "100%" : "50%";
237
- s.forEach((_) => {
238
- T.modifyHtml(_).setStyle("width", u);
239
+ const _ = l || !P ? "100%" : "50%";
240
+ s.forEach((u) => {
241
+ T.modifyHtml(u).setStyle("width", _);
239
242
  });
240
243
  }
241
244
  t || T.apply(new c("Updated price cell widths for vertical layout"));
@@ -253,6 +256,6 @@ class M extends b {
253
256
  }
254
257
  }
255
258
  export {
256
- N as COMPOSITION_CONTROL_BLOCK_ID,
259
+ g as COMPOSITION_CONTROL_BLOCK_ID,
257
260
  M as ItemsBlockCardCompositionControl
258
261
  };