@useinsider/guido 3.24.0-beta.adaba3e → 3.24.0-beta.d510b6c

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 (89) hide show
  1. package/README.md +6 -2
  2. package/dist/@types/config/schemas.js +37 -39
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +92 -98
  5. package/dist/composables/useActionsApi.js +2 -2
  6. package/dist/composables/useBlocksConfig.js +20 -31
  7. package/dist/composables/useEditorTrackingIds.js +49 -0
  8. package/dist/composables/useHtmlCompiler.js +2 -0
  9. package/dist/composables/useStripo.js +70 -70
  10. package/dist/composables/useTranslations.js +1 -2
  11. package/dist/config/compiler/htmlCompilerRules.js +14 -6
  12. package/dist/config/compiler/utils/itemsCompilerUtils.js +42 -43
  13. package/dist/config/compiler/utils/recommendationCompilerUtils.js +64 -67
  14. package/dist/config/migrator/unsubscribeMigrator.js +94 -98
  15. package/dist/enums/academy.js +0 -1
  16. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
  17. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
  18. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
  19. package/dist/extensions/Blocks/Unsubscribe/block.js +104 -96
  20. package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +4 -3
  21. package/dist/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.js +5 -0
  22. package/dist/guido.css +1 -1
  23. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +92 -93
  24. package/dist/node_modules/valibot/dist/index.js +261 -297
  25. package/dist/package.json.js +4 -4
  26. package/dist/services/templateLibraryApi.js +39 -36
  27. package/dist/src/@types/config/schemas.d.ts +0 -4
  28. package/dist/src/composables/useConfig.d.ts +0 -2
  29. package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
  30. package/dist/src/composables/useStripo.d.ts +1 -1
  31. package/dist/src/enums/academy.d.ts +0 -1
  32. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  33. package/dist/src/extensions/Blocks/Unsubscribe/utils/constants.d.ts +1 -0
  34. package/dist/src/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.d.ts +1 -0
  35. package/dist/src/stores/config.d.ts +0 -167
  36. package/dist/src/utils/linkTrackingIds.d.ts +24 -22
  37. package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
  38. package/dist/stores/config.js +6 -13
  39. package/dist/utils/linkTrackingIds.js +72 -72
  40. package/dist/utils/pairProductVariables.js +29 -30
  41. package/dist/utils/templatePreparation.js +59 -72
  42. package/dist/utils/trimHrefWhitespace.js +10 -0
  43. package/package.json +1 -1
  44. package/dist/@types/display-condition.js +0 -25
  45. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +0 -18
  46. package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +0 -41
  47. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +0 -30
  48. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +0 -81
  49. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +0 -34
  50. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +0 -63
  51. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +0 -17
  52. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +0 -22
  53. package/dist/composables/useDisplayConditions.js +0 -117
  54. package/dist/enums/display-condition.js +0 -12
  55. package/dist/extensions/DisplayConditions/bridge.js +0 -25
  56. package/dist/extensions/DisplayConditions/constants.js +0 -17
  57. package/dist/extensions/DisplayConditions/control.js +0 -200
  58. package/dist/extensions/DisplayConditions/display-conditions.css.js +0 -201
  59. package/dist/extensions/DisplayConditions/extension.js +0 -28
  60. package/dist/extensions/DisplayConditions/iconsRegistry.js +0 -20
  61. package/dist/extensions/DisplayConditions/library.js +0 -30
  62. package/dist/extensions/DisplayConditions/settingsPanel.js +0 -17
  63. package/dist/extensions/LinkTracking/extension.js +0 -17
  64. package/dist/extensions/LinkTracking/writer.js +0 -41
  65. package/dist/services/displayConditionApi.js +0 -39
  66. package/dist/src/@types/display-condition.d.ts +0 -59
  67. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +0 -43
  68. package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +0 -2
  69. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +0 -2
  70. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +0 -2
  71. package/dist/src/composables/useDisplayConditions.d.ts +0 -18
  72. package/dist/src/enums/display-condition.d.ts +0 -15
  73. package/dist/src/extensions/DisplayConditions/bridge.d.ts +0 -7
  74. package/dist/src/extensions/DisplayConditions/constants.d.ts +0 -14
  75. package/dist/src/extensions/DisplayConditions/control.d.ts +0 -25
  76. package/dist/src/extensions/DisplayConditions/extension.d.ts +0 -2
  77. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +0 -4
  78. package/dist/src/extensions/DisplayConditions/library.d.ts +0 -8
  79. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +0 -5
  80. package/dist/src/extensions/LinkTracking/extension.d.ts +0 -2
  81. package/dist/src/extensions/LinkTracking/writer.d.ts +0 -13
  82. package/dist/src/mock/api/display-conditions.d.ts +0 -2
  83. package/dist/src/services/displayConditionApi.d.ts +0 -8
  84. package/dist/src/stores/display-condition.d.ts +0 -84
  85. package/dist/src/utils/displayCondition.d.ts +0 -11
  86. package/dist/src/utils/protectTableText.d.ts +0 -2
  87. package/dist/stores/display-condition.js +0 -29
  88. package/dist/utils/displayCondition.js +0 -26
  89. package/dist/utils/protectTableText.js +0 -22
@@ -1,81 +0,0 @@
1
- import { defineComponent as w, reactive as L, ref as c, computed as u, watch as N } from "vue";
2
- import R from "../../wrappers/WpDrawer.vue.js";
3
- import { useDisplayConditions as k, DISPLAY_CONDITIONS_TRANS_KEY as i } from "../../../composables/useDisplayConditions.js";
4
- import { useTranslations as Y } from "../../../composables/useTranslations.js";
5
- import { DISPLAY_CONDITION_LIMITS as j } from "../../../enums/display-condition.js";
6
- import { useDisplayConditionStore as E } from "../../../stores/display-condition.js";
7
- import { InRadioButton as P, InBasicTextInput as F } from "@useinsider/design-system-vue";
8
- import G from "./CodeEditorField.vue.js";
9
- const Z = /* @__PURE__ */ w({
10
- __name: "DisplayConditionCreateDrawer",
11
- setup(K) {
12
- const n = Y(), p = E(), {
13
- validate: v,
14
- notifyInvalid: f,
15
- createInline: y,
16
- createAndSave: _,
17
- cancel: b,
18
- describeWithAcademyLink: B
19
- } = k(), m = () => ({ name: "", description: "", codeBefore: "", codeAfter: "" }), e = L(m()), o = c({}), r = c(!1), l = c(!1), s = u(() => r.value || l.value), g = c(), I = c();
20
- let d = 0;
21
- N(() => p.isCreateOpen, (a) => {
22
- if (d += 1, !a)
23
- return;
24
- const { editing: t } = p;
25
- Object.assign(e, t ? {
26
- name: t.name,
27
- description: t.description,
28
- codeBefore: t.beforeScript,
29
- codeAfter: t.afterScript
30
- } : m()), o.value = {}, r.value = !1;
31
- }, { immediate: !0 });
32
- const C = u(() => B("create-description")), D = u(() => ({
33
- cancelOrBackButton: {
34
- styling: "ghost",
35
- type: "secondary",
36
- labelText: n(`${i}.cancel`),
37
- disabledStatus: s.value
38
- },
39
- secondaryButton: {
40
- styling: "solid",
41
- type: "subtle-primary",
42
- labelText: n(`${i}.create-and-save`),
43
- loadingStatus: r.value
44
- },
45
- primaryButton: {
46
- styling: "solid",
47
- type: "primary",
48
- labelText: n(`${i}.create`),
49
- disabledStatus: s.value
50
- }
51
- })), O = (a, t) => {
52
- t !== e[a] && (e[a] = t, o.value[a] && (o.value = { ...o.value, [a]: void 0 }));
53
- }, T = u(() => `${n(`${i}.condition-description`)} <span class="guido-display-condition-create__optional">(${n(`${i}.optional`)})</span>`);
54
- return { __sfc: !0, trans: n, store: p, validate: v, notifyInvalid: f, createInline: y, createAndSave: _, cancel: b, describeWithAcademyLink: B, emptyDraft: m, draft: e, errors: o, isSaving: r, isReadingCode: l, isBusy: s, codeBeforeRef: g, codeAfterRef: I, openGeneration: d, descriptionText: C, footerButtonGroupOptions: D, updateField: O, descriptionLabel: T, submit: async (a) => {
55
- var S, A;
56
- if (s.value)
57
- return;
58
- const t = d;
59
- l.value = !0;
60
- const [$, x] = await Promise.all([(S = g.value) == null ? void 0 : S.read(), (A = I.value) == null ? void 0 : A.read()]);
61
- if (l.value = !1, t !== d)
62
- return;
63
- if (e.codeBefore = $ ?? e.codeBefore, e.codeAfter = x ?? e.codeAfter, o.value = v(e), Object.keys(o.value).length) {
64
- f();
65
- return;
66
- }
67
- if (a === "inline") {
68
- y({ ...e });
69
- return;
70
- }
71
- r.value = !0;
72
- const h = await _({ ...e });
73
- r.value = !1, o.value = h ?? {}, Object.keys(o.value).length && f();
74
- }, close: () => {
75
- s.value || b();
76
- }, WpDrawer: R, KEY: i, DISPLAY_CONDITION_LIMITS: j, InBasicTextInput: F, InRadioButton: P, CodeEditorField: G };
77
- }
78
- });
79
- export {
80
- Z as default
81
- };
@@ -1,34 +0,0 @@
1
- import a from "./DisplayConditionSelectDrawer.vue2.js";
2
- /* empty css */
3
- import d from "../../../_virtual/_plugin-vue2_normalizer.js";
4
- var o = 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 d-f f-d-c f-g-1" }, [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, { staticClass: "d-f f-d-c j-c-c f-g-1", 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, { staticClass: "d-f f-d-c j-c-c f-g-1", attrs: { id: "guido__display-condition-no-result", icon: "no-data", title: t.trans(`${t.KEY}.no-result`) } }) : i(t.InNoData, { staticClass: "d-f f-d-c j-c-c f-g-1", 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__ */ d(
24
- a,
25
- o,
26
- l,
27
- !1,
28
- null,
29
- "21acc8d8"
30
- );
31
- const f = c.exports;
32
- export {
33
- f as default
34
- };
@@ -1,63 +0,0 @@
1
- import { defineComponent as x, ref as a, watch as D, computed as r, onBeforeUnmount as M } from "vue";
2
- import b from "../../wrappers/WpDrawer.vue.js";
3
- import h from "../../wrappers/WpModal.vue.js";
4
- import { useDisplayConditions as C, DISPLAY_CONDITIONS_TRANS_KEY as c } from "../../../composables/useDisplayConditions.js";
5
- import { useTranslations as w } from "../../../composables/useTranslations.js";
6
- import { useDisplayConditionStore as k } from "../../../stores/display-condition.js";
7
- import { InSkeleton as A, InNoData as N, InIcons as $, InButtonV2 as K, InBasicTextInput as P } from "@useinsider/design-system-vue";
8
- const Q = /* @__PURE__ */ x({
9
- __name: "DisplayConditionSelectDrawer",
10
- setup(W) {
11
- const I = [40, 76, 76, 76], l = w(), t = k(), { loadList: m, select: y, deleteSaved: f, cancel: _, describeWithAcademyLink: v } = C(), u = a(""), i = a(null), n = a(null), o = a(!1);
12
- D(() => t.isSelectOpen, (e) => {
13
- e && (u.value = "", i.value = null, n.value = null, m());
14
- }, { immediate: !0 });
15
- const O = r(() => {
16
- const e = u.value.trim().toLocaleLowerCase();
17
- return e ? t.list.filter((d) => `${d.name} ${d.description}`.toLocaleLowerCase().includes(e)) : t.list;
18
- }), S = r(() => v("select-description")), B = r(() => ({
19
- cancelOrBackButton: {
20
- styling: "ghost",
21
- type: "secondary",
22
- labelText: l(`${c}.back`),
23
- leftIcon: "line-arrow-left"
24
- }
25
- })), L = r(() => ({
26
- cancelOrBackButton: {
27
- type: "secondary",
28
- styling: "ghost",
29
- labelText: l(`${c}.cancel`),
30
- disabledStatus: o.value
31
- },
32
- primaryButton: {
33
- type: "danger",
34
- labelText: l(`${c}.delete`),
35
- loadingStatus: o.value
36
- }
37
- })), E = (e) => {
38
- i.value = i.value === e.id ? null : e.id;
39
- }, T = (e) => {
40
- n.value = n.value === e.id ? null : e.id;
41
- }, s = (e) => {
42
- e.composedPath().some((p) => {
43
- var g;
44
- return p instanceof Element && p.matches(".guido-display-condition-card__split") && ((g = p.closest(".guido-display-condition-card")) == null ? void 0 : g.getAttribute("data-condition-id")) === String(n.value);
45
- }) || (n.value = null);
46
- };
47
- return D(n, (e) => {
48
- e === null ? document.removeEventListener("pointerdown", s, !0) : document.addEventListener("pointerdown", s, !0);
49
- }), M(() => {
50
- document.removeEventListener("pointerdown", s, !0);
51
- }), { __sfc: !0, SKELETON_HEIGHTS: I, trans: l, store: t, loadList: m, select: y, deleteSaved: f, cancel: _, describeWithAcademyLink: v, search: u, expandedId: i, menuId: n, isDeleting: o, filteredList: O, descriptionText: S, footerButtonGroupOptions: B, deleteModalButtons: L, toggleExpanded: E, toggleMenu: T, closeMenuOnOutsidePointer: s, requestDelete: (e) => {
52
- n.value = null, t.pendingDelete = e;
53
- }, confirmDelete: async () => {
54
- !t.pendingDelete || o.value || (o.value = !0, await f(t.pendingDelete), o.value = !1);
55
- }, closeDeleteModal: () => {
56
- o.value || (t.pendingDelete = null);
57
- }, codeOf: (e) => [e.codeBefore, e.codeAfter].filter(Boolean).join(`
58
- `), WpDrawer: b, WpModal: h, KEY: c, InBasicTextInput: P, InButtonV2: K, InIcons: $, InNoData: N, InSkeleton: A };
59
- }
60
- });
61
- export {
62
- Q as default
63
- };
@@ -1,17 +0,0 @@
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
- };
@@ -1,22 +0,0 @@
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,117 +0,0 @@
1
- import { useToaster as M } from "./useToaster.js";
2
- import { useTranslations as x } from "./useTranslations.js";
3
- import { ACADEMY_LINKS as L } from "../enums/academy.js";
4
- import { DisplayConditionSourceType as y, DISPLAY_CONDITION_LIMITS as s, DisplayConditionEvent as I } from "../enums/display-condition.js";
5
- import { ToasterTypeOptions as l } from "../enums/toaster.js";
6
- import { useDisplayConditionApi as O } from "../services/displayConditionApi.js";
7
- import { useConfigStore as q } from "../stores/config.js";
8
- import { useDisplayConditionStore as P } from "../stores/display-condition.js";
9
- import { findInvalidCodeFields as Y, nextConditionId as w } from "../utils/displayCondition.js";
10
- import { escapeHtml as R } from "../utils/htmlEscape.js";
11
- import { computed as B } from "vue";
12
- const X = "email-editor.display-conditions", i = X, b = 409, S = (n, m, r) => ({
13
- id: w(),
14
- name: n.name.trim(),
15
- description: n.description.trim(),
16
- beforeScript: n.codeBefore,
17
- afterScript: n.codeAfter,
18
- extraData: JSON.stringify(r === void 0 ? { source: m } : { source: m, savedId: r })
19
- }), v = (n) => ({
20
- name: n.name,
21
- description: n.description,
22
- codeBefore: n.codeBefore,
23
- codeAfter: n.codeAfter
24
- }), ne = () => {
25
- const n = P(), m = q(), r = O(), o = x(), { showToaster: p } = M(), u = B(() => {
26
- var e;
27
- return (e = m.features) != null && e.liquidSyntax ? "liquid" : "pongo";
28
- }), f = (e) => {
29
- const t = { condition: e };
30
- return document.dispatchEvent(new CustomEvent(I.APPLY, { detail: t })), n.close(), t.applied === !0;
31
- }, D = () => {
32
- n.view !== "none" && (document.dispatchEvent(new CustomEvent(I.CANCEL)), n.close());
33
- }, N = (e) => {
34
- if (e.mode === "select") {
35
- n.openSelect();
36
- return;
37
- }
38
- n.openCreate(e.mode === "edit" ? e.current : null);
39
- }, $ = async () => {
40
- const e = ++n.listRequest;
41
- n.listStatus = "loading";
42
- try {
43
- const t = await r.list(u.value);
44
- e === n.listRequest && (n.list = t, n.listStatus = "loaded");
45
- } catch (t) {
46
- console.warn("Display conditions could not be loaded.", t), e === n.listRequest && (n.listStatus = "error");
47
- }
48
- }, h = (e) => {
49
- const t = {}, d = e.name.trim();
50
- 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`);
51
- const { DESCRIPTION_MAX: C } = s;
52
- e.description.trim().length > C && (t.description = o(`${i}.error-description-max`, { max: C }));
53
- const g = Y(e.codeBefore, e.codeAfter, u.value);
54
- return ["codeBefore", "codeAfter"].forEach((a) => {
55
- e[a].trim() ? g.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`);
56
- }), t;
57
- }, A = (e, t) => {
58
- p(e ? { type: l.Success, message: t } : { type: l.Error, message: o("products.something-went-wrong") });
59
- }, T = (e) => o(
60
- `${i}.${e}`,
61
- {
62
- academyLink: `<a href="${L.EMAIL_DISPLAY_CONDITIONS}" target="_blank" style="color: #0A2ECC; text-decoration: underline;">${o(`${i}.academy`)}</a>`
63
- }
64
- ), _ = () => {
65
- p({ type: l.Error, message: o(`${i}.validation-failed`) });
66
- }, c = (e) => ({ name: R(e) }), E = (e, t) => {
67
- e != null && e.authReported || (console.warn(t, e), p({ type: l.Error, message: t }));
68
- };
69
- return {
70
- syntax: u,
71
- handleOpen: N,
72
- cancel: D,
73
- loadList: $,
74
- validate: h,
75
- notifyInvalid: _,
76
- describeWithAcademyLink: T,
77
- createInline: (e) => {
78
- A(
79
- f(S(e, y.INLINE)),
80
- o(`${i}.created`, c(e.name.trim()))
81
- );
82
- },
83
- createAndSave: async (e) => {
84
- try {
85
- const t = await r.create(e, u.value);
86
- return n.list = [t, ...n.list.filter((d) => d.id !== t.id)], A(
87
- f(S(v(t), y.SAVED, t.id)),
88
- o(`${i}.created-and-saved`, c(t.name))
89
- ), {};
90
- } catch (t) {
91
- return (t == null ? void 0 : t.status) === b ? { name: o(`${i}.error-name-exists`) } : (E(t, o(`${i}.save-failed`, c(e.name.trim()))), null);
92
- }
93
- },
94
- select: (e) => {
95
- A(
96
- f(S(v(e), y.SAVED, e.id)),
97
- o(`${i}.applied`, c(e.name))
98
- );
99
- },
100
- deleteSaved: async (e) => {
101
- try {
102
- await r.remove(e.id), n.list = n.list.filter((t) => t.id !== e.id), p({
103
- type: l.Success,
104
- message: o(`${i}.deleted`, c(e.name))
105
- });
106
- } catch (t) {
107
- E(t, o(`${i}.delete-failed`));
108
- } finally {
109
- n.pendingDelete = null;
110
- }
111
- }
112
- };
113
- };
114
- export {
115
- X as DISPLAY_CONDITIONS_TRANS_KEY,
116
- ne as useDisplayConditions
117
- };
@@ -1,12 +0,0 @@
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,25 +0,0 @@
1
- import { DisplayConditionEvent as i } from "../../enums/display-condition.js";
2
- let n = null;
3
- const d = () => {
4
- n == null || n.detach();
5
- }, L = (p, e) => {
6
- var C;
7
- const t = n;
8
- t == null || t.detach(), (C = t == null ? void 0 : t.onCancel) == null || C.call(t);
9
- let o = () => {
10
- };
11
- const l = (c) => {
12
- const m = c.detail;
13
- o(), m.applied = e.onApply(m.condition);
14
- }, a = () => {
15
- var c;
16
- o(), (c = e.onCancel) == null || c.call(e);
17
- };
18
- return o = () => {
19
- document.removeEventListener(i.APPLY, l), document.removeEventListener(i.CANCEL, a), (n == null ? void 0 : n.detach) === o && (n = null);
20
- }, document.addEventListener(i.APPLY, l), document.addEventListener(i.CANCEL, a), n = { detach: o, onCancel: e.onCancel }, document.dispatchEvent(new CustomEvent(i.OPEN, { detail: p })), o;
21
- };
22
- export {
23
- d as disposeDisplayConditionRequest,
24
- L as requestDisplayCondition
25
- };
@@ -1,17 +0,0 @@
1
- import { BlockType as o } from "../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- const n = "conditions", t = "guido-display-conditions-control", c = 10, s = [o.STRIPE, o.STRUCTURE, o.CONTAINER], d = {
3
- PLUS: "guido-display-condition-plus",
4
- EDIT: "guido-display-condition-edit",
5
- TRASH: "guido-display-condition-trash",
6
- CHEVRON: "guido-display-condition-chevron"
7
- }, e = ["applyConditionSwitcher", "applyCondition", "displayConditions"], I = "You can add Display Condition by selecting an existing condition or creating a new one to show specific content.", O = "You can create or select a display condition to control content visibility based on your recipients' properties or events.";
8
- export {
9
- O as APPLIED_DESCRIPTION,
10
- e as BUILT_IN_CONDITION_CONTROLS,
11
- t as CONDITIONS_CONTROL_ID,
12
- n as CONDITIONS_TAB_ID,
13
- s as CONDITION_BLOCK_TYPES,
14
- d as CONDITION_ICONS,
15
- I as EMPTY_DESCRIPTION,
16
- c as MAX_COLLAPSED_LINES
17
- };
@@ -1,200 +0,0 @@
1
- var $ = Object.defineProperty;
2
- var w = (s, a, i) => a in s ? $(s, a, { enumerable: !0, configurable: !0, writable: !0, value: i }) : s[a] = i;
3
- var c = (s, a, i) => w(s, typeof a != "symbol" ? a + "" : a, i);
4
- import { useToaster as S } from "../../composables/useToaster.js";
5
- import { useTranslations as N } from "../../composables/useTranslations.js";
6
- import { DisplayConditionSourceType as D } from "../../enums/display-condition.js";
7
- import { ToasterTypeOptions as I } from "../../enums/toaster.js";
8
- import { CommonControl as T } from "../Blocks/common-control.js";
9
- import { toAppliedCondition as E, parseSource as x } from "../../utils/displayCondition.js";
10
- import { escapeHtml as b } from "../../utils/htmlEscape.js";
11
- import { ModificationDescription as M, UIElementType as v, UEAttr as R } from "../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
12
- import { requestDisplayCondition as L } from "./bridge.js";
13
- import { CONDITIONS_CONTROL_ID as H, APPLIED_DESCRIPTION as q, EMPTY_DESCRIPTION as A, MAX_COLLAPSED_LINES as O, CONDITION_ICONS as g } from "./constants.js";
14
- const l = ".guido-display-conditions", k = { id: 0, name: "", description: "", beforeScript: "", afterScript: "" }, _ = (s) => `<${v.ICON} ${R.ICON.src}="${s}"></${v.ICON}>`, p = (s, a, i, t = !1) => `<button type="button" class="${a}" id="${s}"${t ? " hidden" : ""}>${i}</button>`;
15
- class K extends T {
16
- constructor() {
17
- super(...arguments);
18
- c(this, "expanded", !1);
19
- c(this, "listeners", []);
20
- c(this, "resizeObserver", null);
21
- c(this, "detachOutsideClick", null);
22
- c(this, "detachRequest", null);
23
- }
24
- getId() {
25
- return H;
26
- }
27
- getTemplate() {
28
- return `
29
- <div class="guido-display-conditions">
30
- <div class="guido-display-conditions__header">
31
- <p class="guido-display-conditions__title">${this.api.translate("Display Conditions")}</p>
32
- <p class="guido-display-conditions__description" data-dc-description></p>
33
- </div>
34
- <div class="guido-display-conditions__empty" data-dc-empty>
35
- ${p(
36
- "guido__btn-add-display-condition",
37
- "guido-display-conditions__add",
38
- `${_(g.PLUS)}<span>${this.api.translate("Add Display Condition")}</span>`
39
- )}
40
- <div class="guido-display-conditions__menu" data-dc-menu hidden>
41
- ${p(
42
- "guido__btn-display-condition-create",
43
- "guido-display-conditions__menu-item",
44
- this.api.translate("Create New Condition")
45
- )}
46
- ${p(
47
- "guido__btn-display-condition-select",
48
- "guido-display-conditions__menu-item",
49
- this.api.translate("Select Saved Condition")
50
- )}
51
- </div>
52
- </div>
53
- <div class="guido-display-conditions__applied" data-dc-applied hidden>
54
- <div class="guido-display-conditions__code-box">
55
- <p class="guido-display-conditions__name" data-dc-name></p>
56
- <div class="guido-display-conditions__sections" data-dc-sections>
57
- <p class="guido-display-conditions__section-label">
58
- ${this.api.translate("Code Before Module")}
59
- </p>
60
- <pre class="guido-display-conditions__code" data-dc-before></pre>
61
- <p class="guido-display-conditions__section-label" data-dc-after-label>
62
- ${this.api.translate("Code After Module")}
63
- </p>
64
- <pre class="guido-display-conditions__code" data-dc-after></pre>
65
- </div>
66
- ${p(
67
- "guido__btn-display-condition-toggle",
68
- "guido-display-conditions__toggle",
69
- `${_(g.CHEVRON)}<span data-dc-toggle-label></span>`,
70
- !0
71
- )}
72
- </div>
73
- <div class="guido-display-conditions__actions">
74
- ${p(
75
- "guido__btn-edit-display-condition",
76
- "guido-display-conditions__action guido-display-conditions__action--edit",
77
- `${_(g.EDIT)}<span>${this.api.translate("Edit")}</span>`
78
- )}
79
- ${p(
80
- "guido__btn-remove-display-condition",
81
- "guido-display-conditions__action guido-display-conditions__action--remove",
82
- `${_(g.TRASH)}<span>${this.api.translate("Remove")}</span>`
83
- )}
84
- </div>
85
- </div>
86
- </div>
87
- `;
88
- }
89
- onRender() {
90
- this.forgetLastPanelNode(), this.teardown(), this.wire("#guido__btn-add-display-condition", () => this.toggleMenu()), this.wire("#guido__btn-display-condition-create", () => this.openDrawer("create")), this.wire("#guido__btn-display-condition-select", () => this.openDrawer("select")), this.wire("#guido__btn-edit-display-condition", () => this.openDrawer("edit")), this.wire("#guido__btn-remove-display-condition", () => this.removeCondition()), this.wire("#guido__btn-display-condition-toggle", () => {
91
- this.expanded = !this.expanded, this.paint();
92
- }), this.observeCodeSize();
93
- }
94
- onTemplateNodeUpdated(i) {
95
- const t = i !== this.currentNode;
96
- super.onTemplateNodeUpdated(i), t && (this.expanded = !1, this.toggleMenu(!1)), this.paint();
97
- }
98
- onDestroy() {
99
- var i;
100
- super.onDestroy(), this.teardown(), (i = this.detachRequest) == null || i.call(this), this.detachRequest = null;
101
- }
102
- getCondition() {
103
- var t;
104
- const i = this.currentNode;
105
- return E((t = i == null ? void 0 : i.getDisplayCondition) == null ? void 0 : t.call(i));
106
- }
107
- toggleMenu(i) {
108
- var n, d, o;
109
- const t = (n = this.getContainer()) == null ? void 0 : n.querySelector(`${l} [data-dc-menu]`);
110
- if (!t)
111
- return;
112
- t.hidden = i === void 0 ? !t.hidden : !i, (d = this.detachOutsideClick) == null || d.call(this), t.hidden || this.listenOutsideClick();
113
- const e = (o = this.getContainer()) == null ? void 0 : o.querySelector(`${l} #guido__btn-add-display-condition`);
114
- t.style.width = !t.hidden && e ? `${e.getBoundingClientRect().width}px` : "";
115
- }
116
- listenOutsideClick() {
117
- var e;
118
- const i = ((e = this.getContainer()) == null ? void 0 : e.ownerDocument) ?? document, t = (n) => {
119
- n.composedPath().some((o) => o instanceof HTMLElement && o.matches(`${l} [data-dc-menu], ${l} #guido__btn-add-display-condition`)) || this.toggleMenu(!1);
120
- };
121
- i.addEventListener("pointerdown", t, !0), this.detachOutsideClick = () => {
122
- i.removeEventListener("pointerdown", t, !0), this.detachOutsideClick = null;
123
- };
124
- }
125
- openDrawer(i) {
126
- const t = this.currentNode;
127
- this.toggleMenu(!1), this.detachRequest = L(
128
- { mode: i, current: i === "edit" ? this.getCondition() : null },
129
- { onApply: (e) => this.applyCondition(e, t) }
130
- );
131
- }
132
- // The drawer flows toast through useDisplayConditions; Remove has no drawer, so it toasts here.
133
- removeCondition() {
134
- this.applyCondition(null) || S().showToaster({
135
- type: I.Error,
136
- message: N()("products.something-went-wrong")
137
- });
138
- }
139
- // The panel can move to another block while the drawer is open; apply onto the block it was opened for.
140
- applyCondition(i, t = this.currentNode) {
141
- if (!t)
142
- return !1;
143
- try {
144
- const e = this.api.getDocumentModifier().modifyHtml(t);
145
- return e.setDisplayCondition(i || k), e.apply(new M(
146
- i ? `Set display condition ${i.name}` : "Remove display condition"
147
- )), !0;
148
- } catch (e) {
149
- return console.warn("Display condition could not be applied.", e), !1;
150
- }
151
- }
152
- wire(i, t) {
153
- var n;
154
- const e = (n = this.getContainer()) == null ? void 0 : n.querySelector(`${l} ${i}`);
155
- e && (e.addEventListener("click", t), this.listeners.push({ element: e, handler: t }));
156
- }
157
- teardown() {
158
- var i, t;
159
- this.listeners.forEach(({ element: e, handler: n }) => e.removeEventListener("click", n)), this.listeners = [], (i = this.resizeObserver) == null || i.disconnect(), this.resizeObserver = null, (t = this.detachOutsideClick) == null || t.call(this);
160
- }
161
- // Line counts depend on layout: the panel font loads late and the panel can be resized.
162
- observeCodeSize() {
163
- var t;
164
- const i = (t = this.getContainer()) == null ? void 0 : t.querySelectorAll(`${l} .guido-display-conditions__code`);
165
- !(i != null && i.length) || typeof ResizeObserver > "u" || (this.resizeObserver = new ResizeObserver(() => this.paint()), i.forEach((e) => {
166
- var n;
167
- return (n = this.resizeObserver) == null ? void 0 : n.observe(e);
168
- }));
169
- }
170
- paint() {
171
- var C;
172
- const i = (C = this.getContainer()) == null ? void 0 : C.querySelector(l);
173
- if (!i)
174
- return;
175
- const t = this.getCondition(), e = (h) => i.querySelector(h);
176
- if (e("[data-dc-empty]").hidden = !!t, e("[data-dc-applied]").hidden = !t, e("[data-dc-description]").textContent = this.api.translate(t ? q : A), !t)
177
- return;
178
- e("[data-dc-name]").textContent = t.name;
179
- const n = x(t) === D.INLINE;
180
- e("#guido__btn-edit-display-condition").hidden = !n;
181
- const d = e("[data-dc-sections]"), o = e("[data-dc-before]"), r = e("[data-dc-after]");
182
- o.innerHTML = b(t.beforeScript), r.innerHTML = b(t.afterScript), r.hidden = !t.afterScript, e("[data-dc-after-label]").hidden = !t.afterScript, d.style.maxHeight = "";
183
- const u = parseFloat(getComputedStyle(o).lineHeight) || 24, y = (h) => h.hidden ? 0 : Math.round(h.scrollHeight / u), m = y(o) + y(r) > O, f = e("#guido__btn-display-condition-toggle");
184
- f.hidden = !m, f.classList.toggle("is-expanded", this.expanded), e("[data-dc-toggle-label]").textContent = this.api.translate(this.expanded ? "Show Less" : "Show More"), m && !this.expanded && (d.style.maxHeight = `${this.collapsedHeight(d, [o, r], u)}px`);
185
- }
186
- // Labels do not count toward the line limit, so the cut lands after the 10th rendered code line.
187
- collapsedHeight(i, t, e) {
188
- const { top: n } = i.getBoundingClientRect();
189
- let d = O, o = 0;
190
- return t.filter((r) => !r.hidden).forEach((r) => {
191
- if (d <= 0)
192
- return;
193
- const u = Math.min(d, Math.round(r.scrollHeight / e));
194
- o = r.getBoundingClientRect().top - n + u * e, d -= u;
195
- }), o;
196
- }
197
- }
198
- export {
199
- K as DisplayConditionsControl
200
- };